[instagram] fix extraction

This commit is contained in:
Mort Yao 2024-07-30 00:28:13 +02:00
parent 4ab02216cd
commit 7acebdab9d
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251
2 changed files with 9 additions and 2 deletions

View File

@ -145,7 +145,7 @@ fake_headers = {
'Accept-Charset': 'UTF-8,*;q=0.5',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.2592.68' # Latest Edge
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/126.0.2592.113' # Latest Edge
}
if sys.stdout.isatty():

View File

@ -5,8 +5,13 @@ __all__ = ['instagram_download']
from ..common import *
def instagram_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.2592.87',
'sec-fetch-mode': 'navigate' # important
}
url = r1(r'([^?]*)', url)
cont = get_content(url, headers=fake_headers)
cont = get_content(url, headers=headers)
vid = r1(r'instagram.com/\w+/([^/]+)', url)
description = r1(r'<meta property="og:title" content="([^"]*)"', cont) or \
@ -15,6 +20,8 @@ def instagram_download(url, output_dir='.', merge=True, info_only=False, **kwarg
appId = r1(r'"appId":"(\d+)"', cont)
media_id = r1(r'"media_id":"(\d+)"', cont)
logging.debug('appId: %s' % appId)
logging.debug('media_id: %s' % media_id)
api_url = 'https://i.instagram.com/api/v1/media/%s/info/' % media_id
try: