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

[zdf] ytdl fails with KeyError: 'basename' #31149

Closed
6 tasks done
Tafkas opened this issue Aug 8, 2022 · 2 comments · Fixed by #31152
Closed
6 tasks done

[zdf] ytdl fails with KeyError: 'basename' #31149

Tafkas opened this issue Aug 8, 2022 · 2 comments · Fixed by #31152
Labels
broken-IE problem with existing site extraction

Comments

@Tafkas
Copy link

Tafkas commented Aug 8, 2022

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2021.12.17
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar bug reports including closed ones
  • I've read bugs section in FAQ

Verbose log

➜  ~ youtube-dl --version
2021.12.17
➜  ~ youtube-dl --verbose https://www.zdf.de/gesellschaft/aktenzeichen-xy-ungeloest
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.zdf.de/gesellschaft/aktenzeichen-xy-ungeloest']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.10.5 (CPython) - macOS-12.5-x86_64-i386-64bit
[debug] exe versions: ffmpeg 5.1, ffprobe 5.1, rtmpdump 2.4
[debug] Proxy map: {}
[debug] Using fake IP 53.60.232.50 (DE) as X-Forwarded-For.
[ZDFChannel] aktenzeichen-xy-ungeloest: Downloading webpage
[download] Downloading playlist: Aktenzeichen XY... ungelöst
[ZDFChannel] playlist Aktenzeichen XY... ungelöst: Collected 44 video ids (downloading 44 of them)
[download] Downloading video 1 of 44
[debug] Using fake IP 53.88.203.47 (DE) as X-Forwarded-For.
[ZDF] aktenzeichen-xy-ungeloest-vom-3-august-2022-100: Downloading webpage
[ZDF] aktenzeichen-xy-ungeloest-vom-3-august-2022-100: Downloading JSON content
[ZDF] aktenzeichen-xy-ungeloest-vom-3-august-2022-100: Downloading JSON metadata
[ZDF] 220803_sendung_axy: Downloading m3u8 information
[ZDF] 220803_sendung_axy: Downloading m3u8 information
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on 'https://zdfvod-rwrtr.akamaized.net/i/,/mp4/none/zdf/22/08/220803_sendung_axy/6/220803_sendung_axy,_508k_p9,_808k_p11,_1628k_p13,_3328k_p15,v15.mp4.csmil/index-f4-v1-a1.m3u8'
[download] Aktenzeichen XY... ungelöst vom 3. August 2022-220803_sendung_axy.mp4 has already been downloaded
[download] 100% of 1.66GiB
[debug] ffmpeg command line: ffprobe -show_streams 'file:Aktenzeichen XY... ungelöst vom 3. August 2022-220803_sendung_axy.mp4'
[ffmpeg] Fixing malformed AAC bitstream in "Aktenzeichen XY... ungelöst vom 3. August 2022-220803_sendung_axy.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Aktenzeichen XY... ungelöst vom 3. August 2022-220803_sendung_axy.mp4' -c copy -f mp4 -bsf:a aac_adtstoasc 'file:Aktenzeichen XY... ungelöst vom 3. August 2022-220803_sendung_axy.temp.mp4'
[download] Downloading video 2 of 44
[ZDF] xy580-fall1-kindermoerder-gesucht-100: Downloading webpage
[ZDF] xy580-fall1-kindermoerder-gesucht-100: Downloading JSON metadata
ERROR: An extractor error has occurred. (caused by KeyError('basename')); 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 "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/extractor/zdf.py", line 294, in _real_extract
    return self._extract_mobile(video_id)
  File "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/extractor/zdf.py", line 251, in _extract_mobile
    content_id = document['basename']
KeyError: 'basename'
Traceback (most recent call last):
  File "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/extractor/zdf.py", line 294, in _real_extract
    return self._extract_mobile(video_id)
  File "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/extractor/zdf.py", line 251, in _extract_mobile
    content_id = document['basename']
KeyError: 'basename'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 836, in __extract_info
    ie_result = ie.extract(url)
  File "/usr/local/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 547, in extract
    raise ExtractorError('An extractor error has occurred.', cause=e)
youtube_dl.utils.ExtractorError: An extractor error has occurred. (caused by KeyError('basename')); 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.

Description

I was trying to download the current episode of Aktenzeichen XY from https://www.zdf.de/gesellschaft/aktenzeichen-xy-ungeloest.

@dirkf
Copy link
Contributor

dirkf commented Aug 9, 2022

What did you expect this page to be, a single video or a playlist?

yt-dl thinks it's a playlist (ZDFChannelIE) with 44 items, corresponding to the data-plusbar-url values in the page source. The first item is downloaded (3 August). Then, as item 2 has no video, it fails to get player data for it and crashes when falling back to the corresponding mobile page. If you use --ignore-errors this happens for items 3-7 too, until 8-10 which do have videos, and so on.

Use --playlist-items 1 to avoid this and just get the first video (though I'm not sure that item 1 is guaranteed to be the newest).

Single video pages (ZDFIE) have a .html extension in the URL.

There doesn't seem to be any metadata in the data-plusbar... blocks that would indicate when what appears to be a linked single video page actually has a video. We can fix the actual crash in the log but then your original command will just break on playlist item 2 with ERROR: No video formats found instead.

Using the jq program, you can list the URLs of the playlist items and perhaps pick the one you want:

youtube-dl --flat-playlist -J 'https://www.zdf.de/gesellschaft/aktenzeichen-xy-ungeloest' | jq '.entries | .[] | .url'

@dirkf
Copy link
Contributor

dirkf commented Aug 9, 2022

Actually, the page does show which items are videos. The <div ...> element that contains the data-plusbar-url attribute is enclosed in a link that contains a data-target-video-type attribute and a data-target-id that matches the data-plusbar-id. The video type 'novideo' shows the items to skip.

dirkf added a commit to dirkf/youtube-dl that referenced this issue Aug 9, 2022
* pull some yt-dlp changes into ZDFBaseIE._extract_format()
* add test cases from yt-dlp to ZDFIE
* fix crash in ZDFIE._extract_mobile() when object had no `formitaeten`
* improve title extraction in ZDFChannelIE (remove trailing station ident)
* avoid extracting non-video playlist items (fixes ytdl-org#31149)
dirkf added a commit to dirkf/youtube-dl that referenced this issue Aug 9, 2022
* pull some yt-dlp changes into ZDFBaseIE._extract_format()
* add test cases from yt-dlp to ZDFIE
* fix crash in ZDFIE._extract_mobile() when object had no `formitaeten`
* improve title extraction in ZDFChannelIE (remove trailing station ident)
* avoid extracting non-video playlist items (fixes ytdl-org#31149)
@dirkf dirkf mentioned this issue Aug 9, 2022
11 tasks
dirkf added a commit to dirkf/youtube-dl that referenced this issue Aug 10, 2022
* pull some yt-dlp changes into ZDFBaseIE._extract_format()
* add test cases from yt-dlp to ZDFIE
* fix crash in ZDFIE._extract_mobile() when object had no `formitaeten`
* improve title extraction in ZDFChannelIE (remove trailing station ident)
* avoid extracting non-video playlist items (fixes ytdl-org#31149)
@dirkf dirkf linked a pull request Aug 10, 2022 that will close this issue
11 tasks
@dirkf dirkf added the broken-IE problem with existing site extraction label Aug 20, 2022
gaming-hacker added a commit to gaming-hacker/youtube-dl that referenced this issue Sep 13, 2022
* commit '1d15ed47c2b3539c8b3b2336f23b54f2b1766cbf':
  [ZDF] Overhaul ZDF extractors * pull some yt-dlp changes into ZDFBaseIE._extract_format() * add test cases from yt-dlp to ZDFIE * fix crash in ZDFIE._extract_mobile() when object had no `formitaeten` * improve title extraction in ZDFChannelIE (remove trailing station ident) * avoid extracting non-video playlist items (fixes ytdl-org#31149)
  [test] Implement string "lambda x: condition(x)" as an expected value
dirkf added a commit that referenced this issue Oct 10, 2022
* pull some yt-dlp changes into ZDFBaseIE._extract_format()
* add test cases from yt-dlp to ZDFIE
* fix crash in ZDFIE._extract_mobile() when object had no `formitaeten`
* improve title extraction in ZDFChannelIE (remove trailing station ident)
* avoid extracting non-video playlist items (fixes #31149)
github-actions bot added a commit to hellopony/youtube-dl that referenced this issue Oct 11, 2022
* https://github.com/ytdl-org/youtube-dl:
  [netease] Get netease music download url through player api (ytdl-org#31235)
  [Common:JWPlayer] Fix x1000 scaling error
  [utils] Sanitize look-alike Unicode glyphs in non-ID filename fields when --restrict-filenames
  [JSInterp] Improve separation logic
  [ZDF] Overhaul ZDF extractors * pull some yt-dlp changes into ZDFBaseIE._extract_format() * add test cases from yt-dlp to ZDFIE * fix crash in ZDFIE._extract_mobile() when object had no `formitaeten` * improve title extraction in ZDFChannelIE (remove trailing station ident) * avoid extracting non-video playlist items (fixes ytdl-org#31149)
  [test] Implement string "lambda x: condition(x)" as an expected value
  [motherless] Fixed the broken uploader_id in the extractor (ytdl-org#31243)
alxlive pushed a commit to alxlive/youtube-dl that referenced this issue Feb 27, 2023
* pull some yt-dlp changes into ZDFBaseIE._extract_format()
* add test cases from yt-dlp to ZDFIE
* fix crash in ZDFIE._extract_mobile() when object had no `formitaeten`
* improve title extraction in ZDFChannelIE (remove trailing station ident)
* avoid extracting non-video playlist items (fixes ytdl-org#31149)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broken-IE problem with existing site extraction
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants