From 467a2a4d35433c6f1aafc173c6b98f47860da13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 13 Jul 2022 15:54:08 +0200 Subject: [PATCH] [instagram] add 'pinned' metadata field (#2752) 'pinned' is a list of user IDs for which a post is pinned and empty if not pinned anywhere. --- gallery_dl/extractor/instagram.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index 31f5b320..4a2c3bb7 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -186,11 +186,17 @@ class InstagramExtractor(Extractor): media = next(self._media_by_id(post["id"])) return self._parse_post_api(media) + pinned = post.get("pinned_for_users", ()) + if pinned: + for index, user in enumerate(pinned): + pinned[index] = int(user["id"]) + owner = post["owner"] data = { "typename" : typename, "date" : text.parse_timestamp(post["taken_at_timestamp"]), "likes" : post["edge_media_preview_like"]["count"], + "pinned" : pinned, "owner_id" : owner["id"], "username" : owner.get("username"), "fullname" : owner.get("full_name"), @@ -263,6 +269,7 @@ class InstagramExtractor(Extractor): "post_id" : post["pk"], "post_shortcode": post["code"], "likes": post["like_count"], + "pinned": post.get("timeline_pinned_user_ids", ()), } caption = post["caption"]