From 1f1101d0dc8a0ee316540fc938edbaca43e4977b Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Tue, 21 Jul 2026 18:02:13 -0500 Subject: [PATCH] [ie/instagram] Fix logged-in extraction (#17278) Closes #17275 Authored by: bashonly --- yt_dlp/extractor/instagram.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/instagram.py b/yt_dlp/extractor/instagram.py index b44e5e0824..359d6186d2 100644 --- a/yt_dlp/extractor/instagram.py +++ b/yt_dlp/extractor/instagram.py @@ -42,7 +42,6 @@ def _id_to_pk(shortcode): class InstagramBaseIE(InfoExtractor): - _API_BASE_URL = 'https://i.instagram.com/api/v1' _BASE_URL = 'https://www.instagram.com/' _APP_IDS = { 'ios': '124024574287414', @@ -75,6 +74,12 @@ class InstagramBaseIE(InfoExtractor): def _is_web_app(self): return self._app_id == self._APP_IDS['web'] + @property + def _API_BASE_URL(self): + if not self._is_web_app: + return 'https://i.instagram.com/api/v1' + return 'https://www.instagram.com/api/v1' + @property def _api_headers(self): return { @@ -87,7 +92,8 @@ class InstagramBaseIE(InfoExtractor): @staticmethod def _is_login_redirect(url): - return urllib.parse.urlparse(url).path.startswith('/accounts/login') + path = urllib.parse.urlparse(url).path + return path.startswith('/accounts/login') or path == '/' def _get_count(self, media, kind, *keys): return traverse_obj(