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

KeyError when using 'ytsearch:' pseudo-URL #15017

Open
BenWiederhake opened this issue Dec 17, 2017 · 1 comment
Open

KeyError when using 'ytsearch:' pseudo-URL #15017

BenWiederhake opened this issue Dec 17, 2017 · 1 comment

Comments

@BenWiederhake
Copy link

@BenWiederhake BenWiederhake commented Dec 17, 2017

I followed the guide below

  • I made sure I am using the latest version: running youtube-dl --version says 2017.12.14, which is just three days ago, and I just installed it from pip3 install. I ensured my version is 2017.12.14.
  • I've verified and I assure that I'm running youtube-dl 2017.12.14

Before submitting an issue make sure you have:

  • I at least skimmed through the README (holy shit is it long), and most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones. Only one match, and it's outdated and closed anyway.

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)

As this issue is a bug report, I provide the full verbose output as follows:

$ youtube-dl --verbose -i -x 'ytsearch:Zombie Nation — Kernkraft 400'
[debug] System config: []
[debug] User config: ['-u', 'PRIVATE', '-p', 'PRIVATE']
[debug] Custom config: []
[debug] Command-line args: ['--verbose', '-i', '-x', 'ytsearch:Zombie Nation — Kernkraft 400']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.12.14
[debug] Python version 3.6.4rc1 - Linux-4.13.0-1-amd64-x86_64-with-debian-buster-sid
[debug] exe versions: ffmpeg 3.4-4, ffprobe 3.4-4
[debug] Proxy map: {}
[youtube:search] Downloading login page
[youtube:search] Looking up account info
[youtube:search] Logging in
[youtube:search] Checking cookie
[youtube:search] query "Zombie Nation — Kernkraft 400": Downloading page 1
ERROR: An extractor error has occurred. (caused by KeyError(1,)); 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 "/home/eispin/.local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 437, in extract
    ie_result = self._real_extract(url)
  File "/home/eispin/.local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 2604, in _real_extract
    return self._get_n_results(query, 1)
  File "/home/eispin/.local/lib/python3.6/site-packages/youtube_dl/extractor/youtube.py", line 2579, in _get_n_results
    html_content = data[1]['body']['content']
KeyError: 1
Traceback (most recent call last):
  File "/home/eispin/.local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 437, in extract
    ie_result = self._real_extract(url)
  File "/home/eispin/.local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 2604, in _real_extract
    return self._get_n_results(query, 1)
  File "/home/eispin/.local/lib/python3.6/site-packages/youtube_dl/extractor/youtube.py", line 2579, in _get_n_results
    html_content = data[1]['body']['content']
KeyError: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/eispin/.local/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 784, in extract_info
    ie_result = ie.extract(url)
  File "/home/eispin/.local/lib/python3.6/site-packages/youtube_dl/extractor/common.py", line 450, in extract
    raise ExtractorError('An extractor error has occurred.', cause=e)
youtube_dl.utils.ExtractorError: An extractor error has occurred. (caused by KeyError(1,)); 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.

I added the -v flag to my command line to you run youtube-dl.

Description of my issue, suggested solution and other information

I got the syntax from here:

$ youtube-dl -i -x 'Zombie Nation — Kernkraft 400'
ERROR: 'Zombie Nation — Kernkraft 400' is not a valid URL. Set --default-search "ytsearch" (or run  youtube-dl "ytsearch:Zombie Nation — Kernkraft 400" ) to search YouTube

This seems to be related to the login mechanism. After deleting my config file, it behaves like this:

$ youtube-dl 'ytsearch:Zombie Nation'  # No login whatsoever
[youtube:search] query "Zombie Nation": Downloading page 1
[download] Downloading playlist: Zombie Nation
[youtube:search] playlist Zombie Nation: Collected 1 video ids (downloading 1 of them)
[download] Downloading video 1 of 1
[youtube] z5LW07FTJbI: Downloading webpage
[youtube] z5LW07FTJbI: Downloading video info webpage
[youtube] z5LW07FTJbI: Extracting video information
[youtube] z5LW07FTJbI: Downloading MPD manifest
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[download] Destination: Zombie Nation - Kernkraft 400-z5LW07FTJbI.f133.mp4
[download] 100% of 4.21MiB in 00:08
[download] Destination: Zombie Nation - Kernkraft 400-z5LW07FTJbI.f251.webm
[download] 100% of 3.46MiB in 00:01
[ffmpeg] Merging formats into "Zombie Nation - Kernkraft 400-z5LW07FTJbI.mkv"
Deleting original file Zombie Nation - Kernkraft 400-z5LW07FTJbI.f133.mp4 (pass -k to keep)
Deleting original file Zombie Nation - Kernkraft 400-z5LW07FTJbI.f251.webm (pass -k to keep)
[download] Finished downloading playlist: Zombie Nation


$  youtube-dl -u MYUSERNAME -p CORRECTPASSWORD 'ytsearch:Zombie Nation'
[youtube:search] Downloading login page
[youtube:search] Looking up account info
[youtube:search] Logging in
[youtube:search] Checking cookie
[youtube:search] query "Zombie Nation": Downloading page 1
ERROR: An extractor error has occurred. (caused by KeyError(1,)); 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.
[$? = 1]


$  youtube-dl -u MYUSERNAME -p WRONGPASSWORD 'ytsearch:Zombie Nation'
[youtube:search] Downloading login page
[youtube:search] Looking up account info
[youtube:search] Logging in
WARNING: Unable to login: Invalid password
[youtube:search] query "Zombie Nation": Downloading page 1
[download] Downloading playlist: Zombie Nation
[youtube:search] playlist Zombie Nation: Collected 1 video ids (downloading 1 of them)
[download] Downloading video 1 of 1
[youtube] Downloading login page
[youtube] Looking up account info
[youtube] Logging in
WARNING: Unable to login: Invalid password
[youtube] z5LW07FTJbI: Downloading webpage
[youtube] z5LW07FTJbI: Downloading video info webpage
[youtube] z5LW07FTJbI: Extracting video information
[youtube] z5LW07FTJbI: Downloading MPD manifest
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[download] Zombie Nation - Kernkraft 400-z5LW07FTJbI.mkv has already been downloaded and merged
[download] Finished downloading playlist: Zombie Nation

Manual workaround: Any of:

  • Manually search for youtube URLs, feed them to yourube-dl in a batch.
  • Don't log in (huh)
@tjesp
Copy link

@tjesp tjesp commented Jun 11, 2019

I still have this problem. If I removed my cookies.txt everything went fine (I assume that was logging me in).

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
2 participants
You can’t perform that action at this time.