youtube-dl: can not download instagram video

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 20

Most upvoted comments

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!

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.

@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

Since this issue is the first hit in the search, I’ll add some info. The current issue regarding Instagram is here https://github.com/ytdl-org/youtube-dl/issues/31098 And here’s a workaround that worked for me https://github.com/ytdl-org/youtube-dl/issues/31098#issuecomment-1193064022

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.