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

can not download instagram video #26377

Closed
qiufeihai opened this issue Aug 19, 2020 · 20 comments
Closed

can not download instagram video #26377

qiufeihai opened this issue Aug 19, 2020 · 20 comments

Comments

@qiufeihai
Copy link

qiufeihai commented Aug 19, 2020

youtube-dl version

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.07.28
[debug] Python version 3.8.0 (CPython) - Linux-3.10.0-862.14.4.el7.x86_64-x86_64-with-glibc2.17
[debug] exe versions: none
[debug] Proxy map: {}
Usage: youtube-dl [OPTIONS] URL [URL...]

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-f', 'mp4', '-o', 'test.mp4', 'https://www.instagram.com/p/CECsuu2BgXj/?utm_source=ig_web_copy_link', '-v']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.07.28
[debug] Python version 3.8.0 (CPython) - Linux-3.10.0-862.14.4.el7.x86_64-x86_64-with-glibc2.17
[debug] exe versions: none
[debug] Proxy map: {}
[Instagram] CECsuu2BgXj: Downloading webpage
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/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 797, in extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 530, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/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/local/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/local/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/local/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

can not download instagram video

WRITE DESCRIPTION HERE

@smowtenshi
Copy link

I can't reproduce this issue. I'm not really sure, but it looks like you don't have a ffmpeg binary on your system, so please make sure it's installed and try again.

yt-dl -v -f mp4 -o "test.mp4" https://www.instagram.com/p/CECsuu2BgXj/?utm_source=ig_web_copy_link
[debug] System config: []
[debug] User config: ['-o', '%(title)s.%(ext)s']
[debug] Custom config: []
[debug] Command-line args: ['-v', '-f', 'mp4', '-o', 'test.mp4', 'https://www.instagram.com/p/CECsuu2BgXj/?utm_source=ig_web_copy_link']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.07.28
[debug] Python version 3.8.5 (CPython) - Linux-5.8.0-2-MANJARO-x86_64-with-glibc2.2.5
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.3.1, rtmpdump 2.4
[debug] Proxy map: {}
[Instagram] CECsuu2BgXj: Downloading webpage
[debug] Invoking downloader on 'URL'
[download] Destination: test.mp4
[download] 100% of 4.60MiB in 00:00

@qiufeihai
Copy link
Author

after install ffmpeg

youtube-dl -f mp4 -o test.mp4 https://www.instagram.com/p/CECsuu2BgXj/?utm_source=ig_web_copy_link -v
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-f', 'mp4', '-o', 'test.mp4', 'https://www.instagram.com/p/CECsuu2BgXj/?utm_source=ig_web_copy_link', '-v']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.07.28
[debug] Python version 3.8.0 (CPython) - Linux-3.10.0-862.14.4.el7.x86_64-x86_64-with-glibc2.17
[debug] exe versions: ffmpeg 3.4.8, ffprobe 3.4.8
[debug] Proxy map: {}
[Instagram] CECsuu2BgXj: Downloading webpage
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/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 797, in extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 530, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/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/local/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/local/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/local/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.

@jjhesk
Copy link

jjhesk commented Aug 21, 2020

try other library

@ilyailya
Copy link

I have the same issue.
Oddly it works on my personal macbook, but don't work on a server:

# youtube-dl --verbose https://www.instagram.com/p/CFC897ECPrJ/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.instagram.com/p/CFC897ECPrJ/']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.07.28
[debug] Git HEAD: 9886d18
[debug] Python version 3.6.9 (CPython) - Linux-4.15.0-66-generic-x86_64-with-Ubuntu-18.04-bionic
[debug] exe versions: ffmpeg 3.4.8, ffprobe 3.4.8
[debug] Proxy map: {}
[Instagram] CFC897ECPrJ: Downloading webpage
ERROR: Unable to extract video url; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  File "/root/redditbot/venv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 797, in extract_info
    ie_result = ie.extract(url)
  File "/root/redditbot/venv/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 530, in extract
    ie_result = self._real_extract(url)
  File "/root/redditbot/venv/lib/python3.6/site-packages/youtube_dl/extractor/instagram.py", line 195, in _real_extract
    video_url = self._og_search_video_url(webpage, secure=False)
  File "/root/redditbot/venv/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 1123, in _og_search_video_url
    return self._html_search_regex(regexes, html, name, **kargs)
  File "/root/redditbot/venv/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 1014, in _html_search_regex
    res = self._search_regex(pattern, string, name, default, fatal, flags, group)
  File "/root/redditbot/venv/lib/python3.6/site-packages/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; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

@ilyailya
Copy link

Here is output from mac:

» youtube-dl --verbose https://www.instagram.com/p/CFC897ECPrJ/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.instagram.com/p/CFC897ECPrJ/']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.07.28
[debug] Git HEAD: 24acfa3
[debug] Python version 3.7.6 (CPython) - Darwin-18.7.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 3.3.1, ffprobe 3.3.1
[debug] Proxy map: {}
[Instagram] CFC897ECPrJ: Downloading webpage
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on 'https://scontent-dub4-1.cdninstagram.com/v/t50.2886-16/119474664_314554919773092_2942774456573139959_n.mp4?_nc_ht=scontent-dub4-1.cdninstagram.com&_nc_cat=100&_nc_ohc=JtSyshgqdgMAX9XeMTz&oe=5F5F899C&oh=01e1bb8c361ba139886f90a9bb155619'
[download] Destination: Video by world_of_snakes-CFC897ECPrJ.mp4
[download] 100% of 1009.31KiB in 00:00

@ilyailya
Copy link

I already tried to upgrade to the newer version of youtube-dl, it didn't help

@liamengland1
Copy link

liamengland1 commented Sep 13, 2020

Oddly it works on my personal macbook, but don't work on a server

Maybe instagram is rate limiting your server, or serving different content to its IP. What's the output of curl https://www.instagram.com/p/CFC897ECPrJ/ if you run it from your server? You can put it in a pastebin/gist

@ilyailya
Copy link

@llacb47 That's actually a super smart guess!
https://gist.github.com/ilyailya/2b15d259f3f6268353380da4d7e4e7a6
Turns out instagram redirecting me to the login page

@smowtenshi
Copy link

Could it be something related to TLS verification?

While in my case every handshake is made properly, in case of @ilyailya there are some outputs like * TLSv1.3 (IN), TLS handshake, Unknown (8): in line 14 and * TLSv1.3 (IN), TLS Unknown, Certificate Status (22): in line 45, and that's where 302 redirection occurs.

@liamengland1
Copy link

liamengland1 commented Sep 13, 2020

Could it be something related to TLS verification?

No. It's rate-limiting, plain and simple. If you log in to instagram from your server's ip (even if you then log out), it should not happen anymore

@ilyailya
Copy link

If you log in to instagram from your server's ip (even if you then log out), it should not happen anymore

@llacb47 I'm having a hard time imagining how to do it, do you have any ideas?

@dtunctuncer
Copy link

@ilyailya Have you found a solution? I am also having the same issue

@ilyailya
Copy link

@dtunctuncer, unfortunately, not. I've tried authorising through this lib https://github.com/ping/instagram_private_api, but it didn't help. If you will find solution, pls post it here

@blacklion
Copy link

I could not download video s IGTV too (I could see it in browser):

> ./youtube-dl --verbose 'https://www.instagram.com/tv/CGIPlKQqaU6/'
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.instagram.com/tv/CGIPlKQqaU6/']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.09.20
[debug] Python version 3.7.7 (CPython) - FreeBSD-12.1-STABLE-amd64-64bit-ELF
[debug] exe versions: ffmpeg 4.2.3, ffprobe 4.2.3
[debug] Proxy map: {}
[Instagram] CGIPlKQqaU6: Downloading webpage
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 "./youtube-dl/youtube_dl/YoutubeDL.py", line 797, in extract_info
    ie_result = ie.extract(url)
  File "./youtube-dl/youtube_dl/extractor/common.py", line 532, in extract
    ie_result = self._real_extract(url)
  File "./youtube-dl/youtube_dl/extractor/instagram.py", line 195, in _real_extract
    video_url = self._og_search_video_url(webpage, secure=False)
  File "./youtube-dl/youtube_dl/extractor/common.py", line 1128, in _og_search_video_url
    return self._html_search_regex(regexes, html, name, **kargs)
  File "./youtube-dl/youtube_dl/extractor/common.py", line 1019, in _html_search_regex
    res = self._search_regex(pattern, string, name, default, fatal, flags, group)
  File "./youtube-dl/youtube_dl/extractor/common.py", line 1010, 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.

@ajm339
Copy link

ajm339 commented Dec 2, 2020

I've had this issue for a while as well and it keeps getting closed by the admins. Literally the same problem. #25624 (comment)

@jSadoski
Copy link

jSadoski commented Dec 20, 2020

I made a small breakthrough on this issue.

TL,DR: You'll need to put

?utm_source=ig_embed

at the end of the link to get the permalink for IG videos


I noticed that whenever I tried to load https://www.instagram.com/p/CItyT4OgA-K from any logged-out session (whether or not I had my VPN on), I would just get the login page. I don't think it's a rate limit as some have described.

I then tried to point youtube-dl at the place where I saw the video publicly, https://www.huffingtonpost.ca/entry/schitts-creek-all-i-want-for-christmas-is-you_ca_5fd8cb2ac5b62f31c2008d52, and it succeeded. Which made me realize that the public embed link is available here,

Screen Shot 2020-12-20 at 4 18 15 AM

and found this in the embed code:

data-instgrm-permalink="https://www.instagram.com/p/CItyT4OgA-K/?utm_source=ig_embed&utm_campaign=loading"

I tried that link, and it worked like a charm!

$ youtube-dl -v -f mp4 -o "callums2.mp4" https://www.instagram.com/p/CItyT4OgA-K/?utm_source=ig_embed
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-f', 'mp4', '-o', 'callums2.mp4', 'https://www.instagram.com/p/CItyT4OgA-K/?utm_source=ig_embed']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.12.14
[debug] Python version 3.9.1 (CPython) - macOS-11.1-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.3.1, rtmpdump 2.4
[debug] Proxy map: {}
[Instagram] CItyT4OgA-K: Downloading webpage
[debug] Invoking downloader on 'https://scontent-lga3-2.cdninstagram.com/v/t50.2886-16/131185275_118131150043383_3233177926723472067_n.mp4?_nc_ht=scontent-lga3-2.cdninstagram.com&_nc_cat=103&_nc_ohc=AZlZVK_S7xsAX-5ituf&oe=5FE191E4&oh=59622f9c34e4c41ccb710f7113d30fbf'
[download] Destination: callums2.mp4
[download] 100% of 3.26MiB in 00:01

Perhaps this can be written into the code as a catch? The behavior seems pretty consistent as far as I can tell.

@Pocket-Deer
Copy link

Hello! I tried to make this like the last answer, and get error. It may be blocked to download again?

pocket_deer@localhost:~/websites/deer.li/ytdl$ youtube-dl --verbose -k -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' -o '%(title)s_%(display_id)s.%(ext)s' https://www.instagram.com/p/CM4j-k5Fidx/?utm_source=ig_embed
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--verbose', u'-k', u'-f', u'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', u'-o', u'%(title)s_%(display_id)s.%(ext)s', u'https://www.instagram.com/p/CM4j-k5Fidx/?utm_source=ig_embed']
WARNING: Assuming --restrict-filenames since file system encoding cannot encode all characters. Set the LC_ALL environment variable to fix this.
[debug] Encodings: locale ANSI_X3.4-1968, fs ANSI_X3.4-1968, out ANSI_X3.4-1968, pref ANSI_X3.4-1968
[debug] youtube-dl version 2021.03.14
[debug] Python version 2.7.16 (CPython) - Linux-4.19.0-11-amd64-x86_64-with-debian-10.6
[debug] exe versions: ffmpeg 4.1.6-1, ffprobe 4.1.6-1
[debug] Proxy map: {}
[Instagram] CM4j-k5Fidx: Downloading webpage
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/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 806, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 827, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/instagram.py", line 216, in _real_extract
    video_url = self._og_search_video_url(webpage, secure=False)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 1130, in _og_search_video_url
    return self._html_search_regex(regexes, html, name, **kargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 1021, in _html_search_regex
    res = self._search_regex(pattern, string, name, default, fatal, flags, group)
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 1012, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
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.

@Batmani
Copy link

Batmani commented May 8, 2021

Hi, I've also had issues downloading instagram videos with youtube-dl resulting in a 'unable to extract video url' error, however I've managed to find the fix for my specific issue and hope it helps others:

It's because Instagram requires you to login first, so you need to create an instagram cookies text file (I use the chrome extension cookies.txt) and save it to the same location as your youtube-dl.exe, then add the parameters --cookies "name-of-instagram-cookies.txt".

Hope this helped!

@MahdeenSky
Copy link

Interestingly enough, my cookies text file that i exported using an extension was the thing that was causing problems, and it couldn't parse the video url or username, removing that part of the command. After i removed it, it started downloading the video properly.

@LevYas
Copy link

LevYas commented Jul 23, 2022

Since this issue is the first hit in the search, I'll add some info.
The current issue regarding Instagram is here #31098
And here's a workaround that worked for me #31098 (comment)

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

No branches or pull requests