Skip to content

Commit

Permalink
[instagram] fix 'pinned' values for '/reels' results (#6719)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Dec 25, 2024
1 parent 3024dce commit 99de0e1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion gallery_dl/extractor/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def _parse_post_rest(self, post):
"post_shortcode": post["code"],
"post_url": "{}/p/{}/".format(self.root, post["code"]),
"likes": post.get("like_count", 0),
"pinned": post.get("timeline_pinned_user_ids", ()),
"liked": post.get("has_liked", False),
"pinned": self._extract_pinned(post),
}

caption = post["caption"]
Expand Down Expand Up @@ -385,6 +385,10 @@ def _extract_tagged_users(src, dest):
"username" : user["username"],
"full_name": user["full_name"]})

def _extract_pinned(self, post):
return (post.get("timeline_pinned_user_ids") or
post.get("clips_tab_pinned_user_ids") or ())

def _init_cursor(self):
cursor = self.config("cursor", True)
if cursor is True:
Expand Down Expand Up @@ -451,6 +455,12 @@ def posts(self):
uid = self.api.user_id(self.item)
return self.api.user_feed(uid)

def _extract_pinned(self, post):
try:
return post["timeline_pinned_user_ids"]
except KeyError:
return ()


class InstagramReelsExtractor(InstagramExtractor):
"""Extractor for an Instagram user's reels"""
Expand All @@ -462,6 +472,12 @@ def posts(self):
uid = self.api.user_id(self.item)
return self.api.user_clips(uid)

def _extract_pinned(self, post):
try:
return post["clips_tab_pinned_user_ids"]
except KeyError:
return ()


class InstagramTaggedExtractor(InstagramExtractor):
"""Extractor for an Instagram user's tagged posts"""
Expand Down

0 comments on commit 99de0e1

Please sign in to comment.