mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
11.86k stars 975 forks source link

downloading from instagram http 400 {"message":"useragent mismatch","status":"fail"} #2748

Open doublep21 opened 2 years ago

doublep21 commented 2 years ago

downloading with gallery-dl [gallery-dl][debug] Version 1.22.4-dev [gallery-dl][debug] Python 3.7.3 - Linux-5.10.103-v7l+-armv7l-with-debian-10.12 [gallery-dl][debug] requests 2.25.1 - urllib3 1.26.5 [gallery-dl][debug] Starting DownloadJob for 'https://www.instagram.com/reel/Cf4IYfWjCiVB8tAD8RS6nQ8bwZepwTYKtZjnOM0/?igshid=MDJmNzVkMjY=' [instagram][debug] Using InstagramPostExtractor for 'https://www.instagram.com/reel/Cf4IYfWjCiVB8tAD8RS6nQ8bwZepwTYKtZjnOM0/?igshid=MDJmNzVkMjY=' [urllib3.connectionpool][debug] Starting new HTTPS connection (1): i.instagram.com:443 [urllib3.connectionpool][debug] https://i.instagram.com:443 "GET /api/v1/media/1077569162048647457588682994704618982176032148149460379160902408921908/info/ HTTP/1.1" 400 117 [instagram][error] HttpError: '400 Bad Request' for 'https://i.instagram.com/api/v1/media/1077569162048647457588682994704618982176032148149460379160902408921908/info/'

{"message":"useragent mismatch","status":"fail"}

afterdelight commented 2 years ago

-->{"message":"useragent mismatch","status":"fail"}

use insta loader with added delay instead

doublep21 commented 2 years ago

-->{"message":"useragent mismatch","status":"fail"}

use insta loader with added delay instead

how?

afterdelight commented 2 years ago

https://github.com/instaloader/instaloader

afterdelight commented 2 years ago

gallery-dl dont grab hq pictures

mikf commented 2 years ago

_ Is https://www.instagram.com/reel/Cf4IYfWjCiVB8tAD8RS6nQ8bwZepwTYKtZjnOM0/?igshid=MDJmNzVkMjY= a mobile-only link or something to that effect?

gallery-dl dont grab hq pictures

It does for single posts.

afterdelight commented 2 years ago

does it download hq by default? do i need to login?

mikf commented 2 years ago

It does download them by default for /p/<shortcode> URLs, but I always get an HTTP redirect to login page warning for these when not logged in, even if I haven't accessed IG at all this day, so yes, you need an account for that.

The relevant issue for hq/original images would be https://github.com/mikf/gallery-dl/issues/2666

cunlem commented 2 years ago

I think /p/<shorcode> URLs now require Referrer header to be set because they stopped working in browser too when not accessed from profile page. Is there a way to pass extra HTTP headers to gallery-dl?

afterdelight commented 2 years ago

what about stories? can it fetch the highest resolution available?

mikf commented 2 years ago

@cunlem You can pass custom headers with the headers option, for example -o headers.Referer=https://www.instagram.com/p/<shortcode>, but that doesn't seem to make a difference for the post from this issue

@afterdelight I think so, since stories use a non-GraphQL API endpoint, but you should check with instaloader and compare to be sure.