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):
|
def instagram_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
||||||
url = r1(r'([^?]*)', url)
|
url = r1(r'([^?]*)', url)
|
||||||
html = get_html(url, faker=True)
|
cont = get_content(url, headers=fake_headers)
|
||||||
|
|
||||||
vid = r1(r'instagram.com/\w+/([^/]+)', url)
|
vid = r1(r'instagram.com/\w+/([^/]+)', url)
|
||||||
description = r1(r'<meta property="og:title" content="([^"]*)"', html) or \
|
description = r1(r'<meta property="og:title" content="([^"]*)"', cont) or \
|
||||||
r1(r'<title>\s([^<]*)</title>', html) # with logged-in cookies
|
r1(r'<title>\s([^<]*)</title>', cont) # with logged-in cookies
|
||||||
title = "{} [{}]".format(description.replace("\n", " "), vid)
|
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:
|
if stream:
|
||||||
_, ext, size = url_info(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:
|
if not info_only:
|
||||||
download_urls([stream], title, ext, size, output_dir, merge=merge)
|
download_urls([stream], title, ext, size, output_dir, merge=merge)
|
||||||
else:
|
else:
|
||||||
data = re.search(r'window\._sharedData\s*=\s*(.*);</script>', html)
|
data = re.search(r'window\._sharedData\s*=\s*(.*);</script>', cont)
|
||||||
try:
|
try:
|
||||||
info = json.loads(data.group(1))
|
info = json.loads(data.group(1))
|
||||||
post = info['entry_data']['PostPage'][0]
|
post = info['entry_data']['PostPage'][0]
|
||||||
assert post
|
assert post
|
||||||
except:
|
except:
|
||||||
# with logged-in cookies
|
# 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:
|
if data is not None:
|
||||||
log.e('[Warning] Cookies needed.')
|
log.e('[Warning] Cookies needed.')
|
||||||
post = json.loads(data.group(1))
|
post = json.loads(data.group(1))
|
||||||
|
Loading…
Reference in New Issue
Block a user