[instagram] Fix extraction when authenticated (closes #27422)
authorAndrew Udvare <audvare@gmail.com>
Mon, 28 Oct 2019 07:54:03 +0000 (03:54 -0400)
committerSergey M․ <dstftw@gmail.com>
Sat, 26 Dec 2020 15:31:55 +0000 (22:31 +0700)
youtube_dl/extractor/instagram.py

index b061850a187567e0d7ed18b5e64ce10e08927244..0755896de220b77560e1af6c31fa74c4f75e46f5 100644 (file)
@@ -137,6 +137,16 @@ class InstagramIE(InfoExtractor):
                 (lambda x: x['entry_data']['PostPage'][0]['graphql']['shortcode_media'],
                  lambda x: x['entry_data']['PostPage'][0]['media']),
                 dict)
+            if not media:
+                additional_data = self._parse_json(
+                    self._search_regex(r'window\.__additionalDataLoaded\(\'[^\']+\',\s*({.+?})\);',
+                                       webpage, 'additional data', default='{}'),
+                    video_id, fatal=False)
+                if additional_data:
+                    media = try_get(
+                        additional_data,
+                        lambda x: x['graphql']['shortcode_media'],
+                        dict)
             if media:
                 video_url = media.get('video_url')
                 height = int_or_none(media.get('dimensions', {}).get('height'))