Skip to content

Commit

Permalink
[instagram] provide 'date' for 'carousel_media' files (#2660)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 7, 2022
1 parent 2064f20 commit 47a92c8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions gallery_dl/extractor/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,35 +288,35 @@ def _parse_post_graphql(self, post):
def _parse_post_api(self, post):

if "media" in post:
media = post["media"]
owner = media["user"]
post = post["media"]
data = {
"post_id" : media["pk"],
"post_shortcode": shortcode_from_id(media["pk"]),
"post_id" : post["pk"],
"post_shortcode": shortcode_from_id(post["pk"]),
}

if "carousel_media" in media:
post["items"] = media["carousel_media"]
if "carousel_media" in post:
items = post["carousel_media"]
data["sidecar_media_id"] = data["post_id"]
data["sidecar_shortcode"] = data["post_shortcode"]
else:
post["items"] = (media,)
items = (post,)

else:
items = post["items"]
reel_id = str(post["id"]).rpartition(":")[2]
owner = post["user"]
data = {
"expires" : text.parse_timestamp(post.get("expiring_at")),
"post_id" : reel_id,
"post_shortcode": shortcode_from_id(reel_id),
}

owner = post["user"]
data["owner_id"] = owner["pk"]
data["username"] = owner.get("username")
data["fullname"] = owner.get("full_name")
data["_files"] = files = []

for num, item in enumerate(post["items"], 1):
for num, item in enumerate(items, 1):

image = item["image_versions2"]["candidates"][0]

Expand All @@ -333,7 +333,8 @@ def _parse_post_api(self, post):
media = {
"num" : num,
"date" : text.parse_timestamp(item.get("taken_at") or
media.get("taken_at")),
media.get("taken_at") or
post.get("taken_at")),
"media_id" : item["pk"],
"shortcode" : (item.get("code") or
shortcode_from_id(item["pk"])),
Expand Down

0 comments on commit 47a92c8

Please sign in to comment.