mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
[instagram] use get_content
This commit is contained in:
parent
3044f5c16a
commit
47bd107686
@ -6,14 +6,14 @@ from ..common import *
|
||||
|
||||
def instagram_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
||||
url = r1(r'([^?]*)', url)
|
||||
html = get_html(url, faker=True)
|
||||
cont = get_content(url, headers=fake_headers)
|
||||
|
||||
vid = r1(r'instagram.com/\w+/([^/]+)', url)
|
||||
description = r1(r'<meta property="og:title" content="([^"]*)"', html) or \
|
||||
r1(r'<title>\s([^<]*)</title>', html) # with logged-in cookies
|
||||
description = r1(r'<meta property="og:title" content="([^"]*)"', cont) or \
|
||||
r1(r'<title>\s([^<]*)</title>', cont) # with logged-in cookies
|
||||
title = "{} [{}]".format(description.replace("\n", " "), vid)
|
||||
|
||||
stream = r1(r'<meta property="og:video" content="([^"]*)"', html)
|
||||
stream = r1(r'<meta property="og:video" content="([^"]*)"', cont)
|
||||
if stream:
|
||||
_, ext, size = url_info(stream)
|
||||
|
||||
@ -21,14 +21,14 @@ def instagram_download(url, output_dir='.', merge=True, info_only=False, **kwarg
|
||||
if not info_only:
|
||||
download_urls([stream], title, ext, size, output_dir, merge=merge)
|
||||
else:
|
||||
data = re.search(r'window\._sharedData\s*=\s*(.*);</script>', html)
|
||||
data = re.search(r'window\._sharedData\s*=\s*(.*);</script>', cont)
|
||||
try:
|
||||
info = json.loads(data.group(1))
|
||||
post = info['entry_data']['PostPage'][0]
|
||||
assert post
|
||||
except:
|
||||
# with logged-in cookies
|
||||
data = re.search(r'window\.__additionalDataLoaded\(\'[^\']+\',(.*)\);</script>', html)
|
||||
data = re.search(r'window\.__additionalDataLoaded\(\'[^\']+\',(.*)\);</script>', cont)
|
||||
if data is not None:
|
||||
log.e('[Warning] Cookies needed.')
|
||||
post = json.loads(data.group(1))
|
||||
|
Loading…
Reference in New Issue
Block a user