From 6d190834eea7102cdf0821594c42c0eeb069188f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 28 Dec 2021 00:27:59 +0100 Subject: [PATCH] [instagram] fix error when PostPage data is not in GraphQL format (#2037) --- gallery_dl/extractor/instagram.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index e6b90d1c..781bf013 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -174,10 +174,16 @@ class InstagramExtractor(Extractor): if post.get("is_video") and "video_url" not in post: url = "{}/tv/{}/".format(self.root, post["shortcode"]) post = self._extract_post_page(url) + if "items" in post: + return self._parse_post_api({"media": post["items"][0]}) + post = post["graphql"]["shortcode_media"] elif typename == "GraphSidecar" and \ "edge_sidecar_to_children" not in post: url = "{}/p/{}/".format(self.root, post["shortcode"]) post = self._extract_post_page(url) + if "items" in post: + return self._parse_post_api({"media": post["items"][0]}) + post = post["graphql"]["shortcode_media"] owner = post["owner"] data = { @@ -347,7 +353,7 @@ class InstagramExtractor(Extractor): data = self._extract_shared_data(url)["entry_data"] if "HttpErrorPage" in data: raise exception.NotFoundError("post") - return data["PostPage"][0]["graphql"]["shortcode_media"] + return data["PostPage"][0] def _get_edge_data(self, user, key): cursor = self.config("cursor")