Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instagram downloads are not working #25354

Open
RealDeviil opened this issue May 22, 2020 · 8 comments
Open

Instagram downloads are not working #25354

RealDeviil opened this issue May 22, 2020 · 8 comments

Comments

@RealDeviil
Copy link

@RealDeviil RealDeviil commented May 22, 2020

Checklist

  • [ x] I'm reporting a broken site support
  • [x ] I've verified that I'm running youtube-dl version 2020.05.08
  • [x ] I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • [x ] I've searched the bugtracker for similar issues including closed ones

Verbose log

root@vmi298562:/tmp/youtube-dl/instagram# python3 /usr/bin/youtube-dl -v --write-pages https://www.instagram.com/p/8fAKWTSWa6/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--write-pages', 'https://www.instagram.com/p/8fAKWTSWa6/']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.05.08
[debug] Python version 3.5.3 (CPython) - Linux-4.9.0-11-amd64-x86_64-with-debian-9.12
[debug] exe versions: ffmpeg 3.3.4-static
[debug] Proxy map: {}
[Instagram] 8fAKWTSWa6: Downloading webpage
[Instagram] Saving request to 8fAKWTSWa6_https_-_www.instagram.com_accounts_login_next=_p_8fAKWTSWa6_.dump
ERROR: Unable to extract video url; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 797, in extract_info
    ie_result = ie.extract(url)
  File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 530, in extract
    ie_result = self._real_extract(url)
  File "/usr/bin/youtube-dl/youtube_dl/extractor/instagram.py", line 195, in _real_extract
    video_url = self._og_search_video_url(webpage, secure=False)
  File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 1123, in _og_search_video_url
    return self._html_search_regex(regexes, html, name, **kargs)
  File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 1014, in _html_search_regex
    res = self._search_regex(pattern, string, name, default, fatal, flags, group)
  File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 1005, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract video url; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

Description

It appears that the download URLs are no longer directly embedded in inline JS on video page. My guess is that they are now found in one of the many external JS scripts included in the page. If I find out which one and/or where, I will update this thread.

Thank you.

@filixm
Copy link

@filixm filixm commented May 23, 2020

I get the same error with Instagram when running through a proxy. Works locally without proxy. Proxies I use are private and work for all other sites.

@ehsan653
Copy link

@ehsan653 ehsan653 commented May 23, 2020

we get the same error .
the main source of trouble is the instagram new policy's.

@RealDeviil
Copy link
Author

@RealDeviil RealDeviil commented May 24, 2020

It looks like Instagram is forcing a login, since a request to a video URL returns an HTTP response like this:

HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: https://www.instagram.com/accounts/login/?next=/p/8fAKWTSWa6/
Vary: Accept-Language, Cookie
Content-Language: en
Date: Sun, 24 May 2020 06:19:02 GMT
Strict-Transport-Security: max-age=31536000
Cache-Control: private, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Sat, 01 Jan 2000 00:00:00 GMT
X-Frame-Options: SAMEORIGIN
content-security-policy: report-uri https://www.instagram.com/security/csp_report/; default-src 'self' https://www.instagram.com; img-src https: data: blob:; font-src https: data:; media-src 'self' blob: https://www.instagram.com https://*.cdninstagram.com https://*.fbcdn.net; manifest-src 'self' https://www.instagram.com; script-src 'self' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://*.cdninstagram.com wss://www.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net 'unsafe-inline' 'unsafe-eval' blob:; style-src 'self' https://*.www.instagram.com https://www.instagram.com 'unsafe-inline'; connect-src 'self' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://graph.instagram.com https://*.graph.instagram.com https://*.cdninstagram.com https://api.instagram.com https://i.instagram.com wss://www.instagram.com wss://edge-chat.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net chrome-extension://boadgeojelhgndaghljhdicfkmllpafd blob:; worker-src 'self' blob: https://www.instagram.com; frame-src 'self' https://instagram.com https://www.instagram.com https://staticxx.facebook.com https://www.facebook.com https://web.facebook.com https://connect.facebook.net https://m.facebook.com; object-src 'none'; upgrade-insecure-requests
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
x-aed: 15
Access-Control-Expose-Headers: X-IG-Set-WWW-Claim
Date: Sun, 24 May 2020 06:19:02 GMT
X-FB-TRIP-ID: 1679558926
Connection: keep-alive
Content-Length: 0

Bu you can still anonymously view a video in the browser, without logging in. So there must be a way to do this without a login. I've just not been able to reproduce this yet programmatically.

There is some kind of encryption "public_key" in the login page source code (e.g., "ecf32677d2da3a328654f55f721d5ee7ef133c11ceb86685077eacc31716f93b"), and it looks like it is manipulated by https://www.instagram.com/static/bundles/es6/EncryptionUtils.js/8c78adc6dadb.js in some way.

Maybe that public key could be used to bypass the login screen? Or maybe that just adds a layer of encryption to the login process.

If anyone could contribute more to this issue, I think all of us would appreciate it.

@RealDeviil
Copy link
Author

@RealDeviil RealDeviil commented May 27, 2020

For anyone that's interested, I (programmatically) found a video's mp4 file in the source code of "embed" pages like https://www.instagram.com/p/8fAKWTSWa6/embed/ .

The download link is in the JavaScript code that starts with "window.__additionalDataLoaded".

I don't know python well enough to update this repo, but for someone who knows python, it should not be difficult to do.

Hope it helps.

@tinybug
Copy link
Contributor

@tinybug tinybug commented Jun 9, 2020

@iuriguilherme
Copy link

@iuriguilherme iuriguilherme commented Jul 2, 2020

Edit: Completely unrelated to OP. Comment left for future searches.

I don't have an instagram account and therefore I can't tell for sure if it's because the video is private that I get a 404 error with this URI: https://www.instagram.com/tv/CCB-aFzhunX

If I use a opengraph aware tool such as the telegram preview, that link becomes this one: https://www.instagram.com/tv/CCB-aFzhunX/?igshid=ji25r415j6hm

This IGTV link seems to work: https://www.instagram.com/tv/CB0m77Dgpmh/?igshid=80c8le3zds0l

I'm not sure what is the difference from them as I know nothing on how Instagram TV (is that how it's called)? works.

Edit: I figured it was a private account, I have to create an instagram account, attempt to "subscribe" on the IGTV channel of that person, and they have to allow me to watch it. Then and only then I seem to get access to the video via cookie.

@kfur
Copy link

@kfur kfur commented Jul 29, 2020

For me error occurs only if i use vpn or vps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.