Skip to content

Commit

Permalink
[instagram] fix extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Jul 29, 2024
1 parent 4ab0221 commit 7acebda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/you_get/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
'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():
Expand Down
9 changes: 8 additions & 1 deletion src/you_get/extractors/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
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 \
Expand All @@ -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:
Expand Down

0 comments on commit 7acebda

Please sign in to comment.