Skip to content

Commit

Permalink
(instagram) Add tagged_users to keywords for stories (#2582)
Browse files Browse the repository at this point in the history
  • Loading branch information
Infinitay committed May 12, 2022
1 parent 9c8647a commit b803c23
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions gallery_dl/extractor/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def _parse_post_api(self, post):
video = None
media = image

files.append({
media = {
"num" : num,
"date" : text.parse_timestamp(item.get("taken_at") or
media.get("taken_at")),
Expand All @@ -319,7 +319,9 @@ def _parse_post_api(self, post):
"video_url" : video["url"] if video else None,
"width" : media["width"],
"height" : media["height"],
})
}
self._extract_tagged_users(item, media)
files.append(media)

return data

Expand All @@ -332,18 +334,20 @@ def _shortcode_from_id(post_id):
"0123456789-_")

def _extract_tagged_users(self, src, dest):
if "edge_media_to_tagged_user" not in src:
if "edge_media_to_tagged_user" not in src and "reel_mentions" not in src:
return
edges = src["edge_media_to_tagged_user"]["edges"]
edges = src["edge_media_to_tagged_user"]["edges"] if "edge_media_to_tagged_user" in src else src["reel_mentions"]
if edges:
dest["tagged_users"] = tagged_users = []
for edge in edges:
user = edge["node"]["user"]
tagged_users.append({
"id" : user["id"],
user = edge["node"]["user"] if "edge_media_to_tagged_user" in src else edge["user"]
tagged_user = {
"username" : user["username"],
"full_name": user["full_name"],
})
}
if "edge_media_to_tagged_user" in src:
tagged_user["id"] = user["id"]
tagged_users.append(tagged_user)

def _extract_shared_data(self, url):
page = self.request(url).text
Expand Down

0 comments on commit b803c23

Please sign in to comment.