[instagram] data not none even when missing cookies

This commit is contained in:
Mort Yao 2021-02-08 17:35:23 +01:00
parent 92ac149d54
commit 980ba1bc2e
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -22,14 +22,15 @@ def instagram_download(url, output_dir='.', merge=True, info_only=False, **kwarg
download_urls([stream], title, ext, size, output_dir, merge=merge)
else:
data = re.search(r'window\._sharedData\s*=\s*(.*);</script>', html)
if data is not None:
try:
info = json.loads(data.group(1))
post = info['entry_data']['PostPage'][0]
else:
assert post
except:
# with logged-in cookies
data = re.search(r'window\.__additionalDataLoaded\(\'[^\']+\',(.*)\);</script>', html)
if data is not None:
log.e('[Error] Cookies needed.')
log.e('[Warning] Cookies needed.')
post = json.loads(data.group(1))
if 'edge_sidecar_to_children' in post['graphql']['shortcode_media']: