[ie/instagram] Fix logged-in extraction (#17278)

Closes #17275
Authored by: bashonly
This commit is contained in:
bashonly
2026-07-21 23:02:13 +00:00
committed by GitHub
parent a8be438aac
commit 1f1101d0dc
+8 -2
View File
@@ -42,7 +42,6 @@ def _id_to_pk(shortcode):
class InstagramBaseIE(InfoExtractor): class InstagramBaseIE(InfoExtractor):
_API_BASE_URL = 'https://i.instagram.com/api/v1'
_BASE_URL = 'https://www.instagram.com/' _BASE_URL = 'https://www.instagram.com/'
_APP_IDS = { _APP_IDS = {
'ios': '124024574287414', 'ios': '124024574287414',
@@ -75,6 +74,12 @@ class InstagramBaseIE(InfoExtractor):
def _is_web_app(self): def _is_web_app(self):
return self._app_id == self._APP_IDS['web'] 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 @property
def _api_headers(self): def _api_headers(self):
return { return {
@@ -87,7 +92,8 @@ class InstagramBaseIE(InfoExtractor):
@staticmethod @staticmethod
def _is_login_redirect(url): 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): def _get_count(self, media, kind, *keys):
return traverse_obj( return traverse_obj(