Skip to content

Commit

Permalink
[instagram] warn about private profiles (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Dec 19, 2020
1 parent e8c64dd commit 337b118
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions gallery_dl/extractor/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,11 @@ def _get_edge_data(self, user, key):
cursor = self.config("cursor")
if cursor:
return {
"edges": (),
"edges" : (),
"page_info": {
"end_cursor": cursor,
"end_cursor" : cursor,
"has_next_page": True,
"_virtual" : True,
},
}
return user[key]
Expand All @@ -338,6 +339,10 @@ def _pagination(self, query_hash, variables, data):
info = data["page_info"]
if not info["has_next_page"]:
return
elif not data["edges"] and "_virtual" not in info:
s = "" if self.user.endswith("s") else "s"
raise exception.StopExtraction(
"%s'%s posts are private", self.user, s)

variables["after"] = self._cursor = info["end_cursor"]
self.log.debug("Cursor: %s", self._cursor)
Expand Down Expand Up @@ -613,7 +618,10 @@ def posts(self):
"has_threaded_comments": True
}
data = self._graphql_request(query_hash, variables)
return (data["shortcode_media"],)
media = data.get("shortcode_media")
if not media:
raise exception.NotFoundError("post")
return (media,)


class InstagramStoriesExtractor(InstagramExtractor):
Expand Down

0 comments on commit 337b118

Please sign in to comment.