Compare commits

...

3 Commits

Author SHA1 Message Date
Dan
0d84709d1e
Merge 2ab7c62bcd into da252d9d32 2024-11-18 09:35:59 +05:30
Dan
2ab7c62bcd
Update instagram.py 2023-02-19 12:49:22 -07:00
Dan
d59a219b65
[extractor/instagram] Fix Login Script Parsing
Fix login script for instagram
2023-02-19 10:30:02 -07:00

View File

@ -58,14 +58,18 @@ class InstagramBaseIE(InfoExtractor):
self._LOGIN_URL, None, note='Downloading login webpage', errnote='Failed to download login webpage') self._LOGIN_URL, None, note='Downloading login webpage', errnote='Failed to download login webpage')
shared_data = self._parse_json(self._search_regex( shared_data = self._parse_json(self._search_regex(
r'window\._sharedData\s*=\s*({.+?});', login_webpage, 'shared data', default='{}'), None) r'\["XIGSharedData",\s*\[\],\s*({.+?}),\d+\]', login_webpage, 'shared data', default='{}'), None)
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( login = self._download_json(
f'{self._LOGIN_URL}/ajax/', None, note='Logging in', headers={ f'{self._LOGIN_URL}/ajax/', None, note='Logging in', headers={
**self._API_HEADERS, **self._API_HEADERS,
'X-Requested-With': 'XMLHttpRequest', 'X-Requested-With': 'XMLHttpRequest',
'X-CSRFToken': shared_data['config']['csrf_token'], 'X-CSRFToken': shared_data.get('config', {}).get('csrf_token'),
'X-Instagram-AJAX': shared_data['rollout_hash'], 'X-Instagram-AJAX': shared_data.get('rollout_hash'),
'Referer': 'https://www.instagram.com/', 'Referer': 'https://www.instagram.com/',
}, data=urlencode_postdata({ }, data=urlencode_postdata({
'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{int(time.time())}:{password}', 'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{int(time.time())}:{password}',