[instagram] skip private check for avatars (#3255)

This commit is contained in:
Mike Fährmann
2022-11-19 11:10:18 +01:00
parent 08fd1ff835
commit 53a5d95b7d

View File

@@ -582,7 +582,7 @@ class InstagramAvatarExtractor(InstagramExtractor):
def posts(self):
if self._logged_in:
user_id = self.api.user_id(self.item)
user_id = self.api.user_id(self.item, check_private=False)
user = self.api.user_by_id(user_id)
avatar = (user.get("hd_profile_pic_url_info") or
user["hd_profile_pic_versions"][-1])
@@ -780,14 +780,15 @@ class InstagramRestAPI():
endpoint = "/v1/users/{}/info/".format(user_id)
return self._call(endpoint)["user"]
def user_id(self, screen_name):
def user_id(self, screen_name, check_private=True):
if screen_name.startswith("id:"):
return screen_name[3:]
user = self.user_by_name(screen_name)
if user is None:
raise exception.AuthorizationError(
"Login required to access this profile")
if user["is_private"] and not user["followed_by_viewer"]:
if check_private and user["is_private"] and \
not user["followed_by_viewer"]:
name = user["username"]
s = "" if name.endswith("s") else "s"
raise exception.StopExtraction("%s'%s posts are private", name, s)