yt-dlp: Instagram stories: cannot download, says need to log in when already logged in on browser
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
- I understand that I will be blocked if I intentionally remove or skip any mandatory* field
Checklist
- I’m reporting that yt-dlp is broken on a supported site
- I’ve verified that I’m running yt-dlp version 2023.09.24 (update instructions) or later (specify commit)
- I’ve checked that all provided URLs are playable in a browser with the same IP and same login details
- I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
- I’ve searched known issues and the bugtracker for similar issues including closed ones. DO NOT post duplicates
- I’ve read the guidelines for opening an issue
- I’ve read about sharing account credentials and I’m willing to share it if required
Region
USA
Provide a description that is worded well enough to be understood
I am still able to download Instagram ‘reels’ just fine, but suddenly cannot download any ‘stories’ as of early morning on October 5th. It says I need to log in when I am already logged in to the same account on Chrome browser. I have been doing this exact same thing daily for the last several months with no problem (downloading ‘stories’ from multiple users).
I’ve seen the notes about how using yt-dlp with Instagram is risky, but somehow I’ve never had an Instagram account banned due to using yt-dlp.
Provide verbose output that clearly demonstrates the problem
- Run your yt-dlp command with -vU flag added (
yt-dlp -vU <your command line>
) - If using API, add
'verbose': True
toYoutubeDL
params instead - Copy the WHOLE output (starting with
[debug] Command-line config
) and insert it below
Complete Verbose Output
[debug] Command-line config: ['-vU', '-o', '%(uploader)s-%(id)s.%(ext)s', '--cookies', 'instagram.com_cookies.txt', 'https:/
/www.instagram.com/stories/kimkardashian/3206599444580335888/']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8 (No VT), error utf-8 (No VT), screen utf-8 (No VT)
[debug] yt-dlp version stable@2023.09.24 [088add956] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-7-6.1.7601-SP1 (OpenSSL 1.1.1k 25 Mar 2021)
[debug] exe versions: ffmpeg 2022-05-26-git-0dcbe1c1aa-full_build-www.gyan.dev (setts), ffprobe 2022-05-26-git-0dcbe1c1aa-fu
ll_build-www.gyan.dev, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.19.0, brotli-1.1.0, certifi-2023.07.22, mutagen-1.47.0, sqlite3-3.35.5, websockets-
11.0.3
[debug] Proxy map: {}
[debug] Loaded 1886 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.09.24, Current version: stable@2023.09.24
Current Build Hash: 125465ac4416bcd4bf1632b899630ceecc08b341e83fdf10bd34700c58ea5152
yt-dlp is up to date (stable@2023.09.24)
[instagram:story] Extracting URL: https://www.instagram.com/stories/kimkardashian/3206599444580335888/
[instagram:story] 3206599444580335888: Downloading webpage
[instagram:story] 3206599444580335888: Downloading JSON metadata
ERROR: [instagram:story] 3206599444580335888: You need to log in to access this content. Use --cookies, --cookies-from-brows
er, --username and --password, --netrc-cmd, or --netrc (instagram) to provide account credentials
File "yt_dlp\extractor\common.py", line 715, in extract
File "yt_dlp\extractor\instagram.py", line 713, in _real_extract
File "yt_dlp\extractor\common.py", line 1175, in raise_login_required
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 7
- Comments: 26 (2 by maintainers)
Commits related to this issue
- [ie/instagram] Fix stories extraction Closes #8290 Authored by: bashonly — committed to bashonly/yt-dlp by bashonly 6 months ago
- [ie/instagram] Fix stories extraction (#8843) Closes #8290 Authored by: bashonly — committed to yt-dlp/yt-dlp by bashonly 6 months ago
While debugging this issue I found that the user
id
value that is extracted from the JSON is always null while thepk
value is populated with a number After replacing theid
key withpk
in the following line I successfully downloaded a story video from Instagram https://github.com/yt-dlp/yt-dlp/blob/87264d4fdadcddd91289b968dd0e4bf58d449267/yt_dlp/extractor/instagram.py#L706just checked again and i can still download reels and posts (videos in photo albums)
currently using gallery-dl as replacement, everything works fine with that
had the exact same output
Same issue here, have been using “–cookies-from-browser firefox” for several years (so much so I’ve aliased it in my .bashrc), but since the update a few days ago, it’s acting as if I’m not logged in, and specifying username & password gives the ‘An extractor error has occurred. (caused by KeyError(‘config’))’ error.
Getting the same with --cookies and --cookies-from-browser, also giving user and pass throws this error:
[debug] Command-line config: [‘https://www.instagram.com/stories/xxxxxxxxxxx/xxxxxxxxxxxxxxxxx/’, ‘–username’, ‘PRIVATE’, ‘–password’, ‘PRIVATE’, ‘-vU’] [debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out cp1252 (No VT), error cp1252 (No VT), screen cp1252 (No VT) [debug] yt-dlp version stable@2023.10.07 [377e85a17] (pip) [debug] Python 3.11.4 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1u 30 May 2023) [debug] exe versions: ffmpeg 2022-08-03-git-d3f48e68b3-full_build-www.gyan.dev (setts), ffprobe 2022-08-03-git-d3f48e68b3-full_build-www.gyan.dev, phantomjs 2.1.1 [debug] Optional libraries: Cryptodome-3.18.0, brotli-1.0.9, certifi-2023.07.22, mutagen-1.46.0, sqlite3-3.42.0, websockets-11.0.3 [debug] Proxy map: {} [debug] Loaded 1886 extractors [debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest Available version: stable@2023.10.07, Current version: stable@2023.10.07 yt-dlp is up to date (stable@2023.10.07) [instagram:story] Downloading login webpage ERROR: 3208732104181607427: An extractor error has occurred. (caused by KeyError(‘config’)); please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U File “C:\Python311\Lib\site-packages\yt_dlp\extractor\common.py”, line 712, in extract self.initialize() File “C:\Python311\Lib\site-packages\yt_dlp\extractor\common.py”, line 618, in initialize self._perform_login(username, password) File “C:\Python311\Lib\site-packages\yt_dlp\extractor\instagram.py”, line 67, in _perform_login ‘X-CSRFToken’: shared_data[‘config’][‘csrf_token’], ~~~~~~~~~~~^^^^^^^^^^ KeyError: ‘config’
That’s a different problem, it’s not able to find your cookies file. One workaround before that gets fixed is to try to export your cookies into the ol’ netscape text format, and then refer to it with --cookies FILE.
@dennisnez login/netrc is broken for instagram, use cookies instead
Can confirm @ozelentok fix works, just tried with the current master commit 0b6f8