youtube-dl: [twitch.tv][includes workaround + fix] KeyError('redirect',) when downloading with username/password
- I’ve verified and I assure that I’m running youtube-dl 2017.08.27.1
- At least skimmed through the README, most notably the FAQ and BUGS sections
- Searched the bugtracker for similar issues including closed ones
- Bug report (encountered problems with youtube-dl)
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--add-metadata', '--write-description', '--write-thumbnail', '--ignore-errors', '--username', 'PRIVATE', '--password', 'PRIVATE', '--cookies', 'cookies.txt', '--verbose', 'https://www.twitch.tv/PRIVATE/videos/all']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2017.08.27.1
[debug] Python version 3.4.4 - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg 3.2, ffprobe 3.2
[debug] Proxy map: {}
[twitch:vod] Downloading login page
[twitch:vod] Logging in as PRIVATE
ERROR: An extractor error has occurred. (caused by KeyError('redirect',)); 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 "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 433, in extract
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 391, in initialize
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 56, in _real_initialize
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 106, in _login
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 91, in login_step
KeyError: 'redirect'
Traceback (most recent call last):
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 433, in extract
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 391, in initialize
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 56, in _real_initialize
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 106, in _login
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\twitch.py", line 91, in login_step
KeyError: 'redirect'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\YoutubeDL.py", line 776, in extract_info
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmp_2hklmx2\build\youtube_dl\extractor\common.py", line 447, in extract
youtube_dl.utils.ExtractorError: An extractor error has occurred. (caused by KeyError('redirect',)); 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.
When you try to use login credentials using –username and –password on Twitch.tv now, youtube-dl gets redirected and aborts downloading the video(s).
A workaround is to create a cookies.txt file using –cookies together with –username and –password once (it gets created despite the redirect error) and then invoke youtube-dl a second time without the –username and –password command options but only using –cookies cookies.txt.
Being able to use login credentials or cookies with youtube-dl is important because some streamers make their VODs only available to subscribers.
Also note that this bug is reproducable with any Twitch.tv VOD not just sub-only VODs, all it takes is trying to use –username and –password for the redirect error to occur.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 15
Looks like the response includes ‘redirect_path’ now. Changing the ‘redirect_url = urljoin(…)’ line to this fixed the problem for me:
For folks that land here that don’t know exactly what to do to fix this if you have even a tiny bit of git and python knowledge you just need to modify the twitch.py extractor file after cloning the repo.
Then you can download the vid you want by running a command like this from the top level of the repo.
$ python -m youtube_dl -u NAME -p PASS https://www.twitch.tv/videos/217708370I have the same problem. The described workaround also works for me. Thanks @Gorrrg!
Not a big surprise it gets redirected to a login page: