[instagram] add 'stories-tray' extractor (#6582)

https://github.com/mikf/gallery-dl/issues/6582#issuecomment-3230919124
This commit is contained in:
Mike Fährmann
2025-08-28 10:51:33 +02:00
parent df158995f7
commit 188824c479
4 changed files with 26 additions and 2 deletions

View File

@@ -460,7 +460,7 @@ Consider all listed sites to potentially be NSFW.
<tr id="instagram" title="instagram">
<td>Instagram</td>
<td>https://www.instagram.com/</td>
<td>Avatars, Collections, Followers, Followed Users, Guides, Highlights, User Profile Information, Posts, Reels, Saved Posts, Stories, Tag Searches, Tagged Posts, User Profiles</td>
<td>Avatars, Collections, Followers, Followed Users, Guides, Highlights, User Profile Information, Posts, Reels, Saved Posts, Stories, Stories Home Tray, Tag Searches, Tagged Posts, User Profiles</td>
<td><a href="https://github.com/mikf/gallery-dl#cookies">Cookies</a></td>
</tr>
<tr id="issuu" title="issuu">

View File

@@ -568,6 +568,20 @@ class InstagramCollectionExtractor(InstagramExtractor):
return self.api.user_collection(self.collection_id)
class InstagramStoriesTrayExtractor(InstagramExtractor):
"""Extractor for your Instagram account's stories tray"""
subcategory = "stories-tray"
pattern = rf"{BASE_PATTERN}/stories/me/?$()"
example = "https://www.instagram.com/stories/me/"
def items(self):
base = f"{self.root}/stories/id:"
for story in self.api.reels_tray():
story["date"] = text.parse_timestamp(story["latest_reel_media"])
story["_extractor"] = InstagramStoriesExtractor
yield Message.Queue, f"{base}{story['id']}/", story
class InstagramStoriesExtractor(InstagramExtractor):
"""Extractor for Instagram stories"""
subcategory = "stories"
@@ -793,7 +807,11 @@ class InstagramRestAPI():
try:
return self._call(endpoint, params=params)["reels_media"]
except KeyError:
raise exception.AuthorizationError("Login required")
raise exception.AuthRequired("authenticated cookies")
def reels_tray(self):
endpoint = "/v1/feed/reels_tray/"
return self._call(endpoint)["tray"]
def tags_media(self, tag):
for section in self.tags_sections(tag):

View File

@@ -310,6 +310,7 @@ SUBCATEGORY_MAP = {
"posts": "",
"saved": "Saved Posts",
"tagged": "Tagged Posts",
"stories-tray": "Stories Home Tray",
},
"itaku": {
"posts": "",

View File

@@ -109,6 +109,11 @@ __tests__ = (
"#class" : instagram.InstagramStoriesExtractor,
},
{
"#url" : "https://www.instagram.com/stories/me/",
"#class" : instagram.InstagramStoriesTrayExtractor,
},
{
"#url" : "https://www.instagram.com/s/aGlnaGxpZ2h0OjE4MDQyNTA5NDg4MTcwMDk1",
"#category": ("", "instagram", "highlights"),