[facebook] fix 'avatar' extraction for empty profiles (#7962)
This commit is contained in:
@@ -315,15 +315,16 @@ class FacebookExtractor(Extractor):
|
||||
|
||||
for _ in range(self.fallback_retries + 1):
|
||||
profile_photos_page = self.request(profile_photos_url).text
|
||||
if set_id := self._extract_profile_set_id(profile_photos_page):
|
||||
set_id = self._extract_profile_set_id(profile_photos_page)
|
||||
avatar_page_url = text.extr(
|
||||
profile_photos_page, ',"profilePhoto":{"url":"', '"')
|
||||
|
||||
if set_id or avatar_page_url:
|
||||
break
|
||||
self.log.debug("Got empty profile photos page, retrying...")
|
||||
else:
|
||||
raise exception.AbortExtraction("Failed to extract profile data")
|
||||
|
||||
avatar_page_url = text.extr(
|
||||
profile_photos_page, ',"profilePhoto":{"url":"', '"')
|
||||
|
||||
return set_id, avatar_page_url.replace("\\/", "/")
|
||||
|
||||
def _extract_profile_set_id(self, profile_photos_page):
|
||||
|
||||
@@ -78,6 +78,21 @@ __tests__ = (
|
||||
"username" : "Facebook",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.facebook.com/brando.cha.3/avatar",
|
||||
"#comment" : "empty '/photos_of' page (#7962)",
|
||||
"#class" : facebook.FacebookAvatarExtractor,
|
||||
"#count" : 1,
|
||||
|
||||
"date" : "dt:2020-01-23 17:54:22",
|
||||
"id" : "104622291093002",
|
||||
"set_id" : "a.104622317759666",
|
||||
"type" : "avatar",
|
||||
"user_id" : "100046356937542",
|
||||
"user_pfbid": "pfbid0uNaJ41o64vvHGCRnfZSYZkSm6yPnneBN947QdPw3F7iTsbgscr7ZZqLv7GvP2L8l",
|
||||
"username" : "Throwaway Idk",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.facebook.com/media/set/?set=a.10152716010956729&type=3",
|
||||
"#class" : facebook.FacebookSetExtractor,
|
||||
|
||||
Reference in New Issue
Block a user