From 2ab7c62bcdc9ba0c0186259e7921822bdea2c2c9 Mon Sep 17 00:00:00 2001 From: Dan <31395415+cakedan@users.noreply.github.com> Date: Sun, 19 Feb 2023 12:49:22 -0700 Subject: [PATCH] Update instagram.py --- yt_dlp/extractor/instagram.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/instagram.py b/yt_dlp/extractor/instagram.py index c8ba76c9e..a47cf6302 100644 --- a/yt_dlp/extractor/instagram.py +++ b/yt_dlp/extractor/instagram.py @@ -59,7 +59,10 @@ class InstagramBaseIE(InfoExtractor): shared_data = self._parse_json(self._search_regex( r'\["XIGSharedData",\s*\[\],\s*({.+?}),\d+\]', login_webpage, 'shared data', default='{}'), None) - shared_data = shared_data.get('native', {}) + if shared_data.get('native', {}).get('config', {}).get('csrf_token'): + shared_data = shared_data['native'] + else: + shared_data = json.loads(shared_data.get('raw', '{}')) login = self._download_json( f'{self._LOGIN_URL}/ajax/', None, note='Logging in', headers={