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('@id',) youtube-dl [nrk] #25594

Closed
elvisandrei16 opened this issue Jun 9, 2020 · 6 comments
Closed

KeyError('@id',) youtube-dl [nrk] #25594

elvisandrei16 opened this issue Jun 9, 2020 · 6 comments

Comments

@elvisandrei16
Copy link

@elvisandrei16 elvisandrei16 commented Jun 9, 2020

C:\Users\Admin\Desktop\yt-dl>youtube-dl --write-sub --sub-format ttml https://tv.nrk.no/serie/fra-boelle-til-bestevenn/sesong/1/episode/1/avspiller [NRKTVEpisode] fra-boelle-til-bestevenn/sesong/1/episode/1: Downloading webpage ERROR: An extractor error has occurred. (caused by KeyError('@id',)); 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.
Windows 7 64 bit. Youtube-dl is up-to-date 2020.06.06. I can download some videos from the same website.
Please help me!

@barsnick
Copy link

@barsnick barsnick commented Jun 9, 2020

Your subject line should mention that the extractor is "[nrk]" (and you didn't follow the rules from the issue template).

I have encountered this problem since yesterday on some of NRK's video's, most notably [NRKTVEpisodeIE], including its provided tests.

It seems to be that "@id" is no longer provided in the embedded JSON.

I was able to extract the first provided _TEST video ("Hellum's Kro") as well as another such video by modifying the video_id extraction:

--- a/youtube_dl/extractor/nrk.py
+++ b/youtube_dl/extractor/nrk.py
@@ -425,9 +425,9 @@ class NRKTVEpisodeIE(InfoExtractor):

         webpage = self._download_webpage(url, display_id)

-        nrk_id = self._parse_json(
-            self._search_regex(JSON_LD_RE, webpage, 'JSON-LD', group='json_ld'),
-            display_id)['@id']
+        nrk_id = self._search_regex(
+            r'<meta[^>]+property=(["\'])nrk:program-id(["\'])[^>]+content=(["\']?)(?P<id>[^"\']+)(["\'])',
+            webpage, 'display_id', group='id')

         assert re.match(NRKTVIE._EPISODE_RE, nrk_id)
         return self.url_result(

Disclaimer: I cannot tell whether this breaks other videos, or whether both methods need to be provided, with one as fallback. It's just a proof of concept and "works for me"(TM) right now.

@elvisandrei16 elvisandrei16 changed the title KeyError('@id',) youtube-dl KeyError('@id',) youtube-dl [nrk] Jun 10, 2020
@elvisandrei16
Copy link
Author

@elvisandrei16 elvisandrei16 commented Jun 10, 2020

Thank you for the answer!

The error KeyError('@id',) appeared when I writed: "C:\Users\Admin\Desktop\yt-dl>youtube-dl --write-sub --sub-format ttml https://tv.nrk.no/serie/fra-boelle-til-bestevenn/sesong/1/episode/1/avspiller" in the Command prompt. Must I use another way?

Can you paste the accurate text you used for Hellum's Kro? And what software to use? Where to put the command?

Thank you in advance!

@elvisandrei16
Copy link
Author

@elvisandrei16 elvisandrei16 commented Jun 10, 2020

I put the text you wrote in hellumskro.py, in Command prompt, and it says:

C:\Users\Admin\Desktop>python hellumskro.py
File "hellumskro.py", line 3
@@ -425,9 +425,9 @@ class NRKTVEpisodeIE(InfoExtractor):
^
SyntaxError: invalid syntax

@barsnick
Copy link

@barsnick barsnick commented Jun 12, 2020

Must I use another way?

Actually, no. You must fix youtube-dl or wait for it to be fixed.

Can you paste the accurate text you used for Hellum's Kro? And what software to use? Where to put the command?

The fix I posted is a so-called diff. It's a textual instruction (which can be applied by developers, as they know how to) of what to change in youtube-dl's source code in order for this issue to go away.

Since I'm running on Unix (Linux more precisely), it's easy to fix and run. I extracted the source code (or clone it from git), went into the source folder, applied the above fix, and then ran
python -m youtube_dl [...]
instead of
youtube-dl [...]
(or one can build their own binary, which I eventually did). I don't know if it can be done so easily for Windows, I assume you have a høyre terskel ;) for installing and running the required stuff. If you're not really avid, you need to wait for an official fix.

@kometkamerat
Copy link

@kometkamerat kometkamerat commented Jun 17, 2020

Implemented the quickfix for the '@id' error, now I'm getting 404 not found in stead:

PS E:\git\youtube-dl> python.exe -m youtube_dl --write-sub https://tv.nrk.no/serie/foer-vi-doer/sesong/2/episode/1/avspiller
[NRKTVEpisode] foer-vi-doer/sesong/2/episode/1: Downloading webpage
[NRK] KOIF22003118: Downloading mediaelement JSON
[NRK] KOIF22003118: Downloading f4m manifest
WARNING: Unable to download f4m manifest: HTTP Error 404: Not Found
[NRK] KOIF22003118: Downloading m3u8 information
WARNING: Failed to download m3u8 information: HTTP Error 404: Not Found
[NRK] KOIF22003118: Downloading f4m manifest
WARNING: Unable to download f4m manifest: HTTP Error 404: Not Found
[NRK] KOIF22003118: Downloading m3u8 information
WARNING: Failed to download m3u8 information: HTTP Error 404: Not Found
ERROR: No video formats found; 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.

@barsnick
Copy link

@barsnick barsnick commented Jun 17, 2020

now I'm getting 404 not found in stead:

PS E:\git\youtube-dl> python.exe -m youtube_dl --write-sub https://tv.nrk.no/serie/foer-vi-doer/sesong/2/episode/1/avspiller
[NRKTVEpisode] foer-vi-doer/sesong/2/episode/1: Downloading webpage
[NRK] KOIF22003118: Downloading mediaelement JSON
[NRK] KOIF22003118: Downloading f4m manifest
WARNING: Unable to download f4m manifest: HTTP Error 404: Not Found
[NRK] KOIF22003118: Downloading m3u8 information
WARNING: Failed to download m3u8 information: HTTP Error 404: Not Found
[NRK] KOIF22003118: Downloading f4m manifest
WARNING: Unable to download f4m manifest: HTTP Error 404: Not Found
[NRK] KOIF22003118: Downloading m3u8 information
WARNING: Failed to download m3u8 information: HTTP Error 404: Not Found
ERROR: No video formats found; 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 can reproduce this. This seems to be a different, additional issue. It happens on some series, not all. And of those failing have the /serie/$SERIES/sesong/$SEASON/episode/$EPISODE URL scheme. I can't figure out why the manifests return a 404, I will check in a browser later. Actually, I consider this a separate issue. (But thanks for pointing it out.)

@ytdl-org ytdl-org deleted a comment from elvisandrei16 Jun 18, 2020
@ytdl-org ytdl-org locked and limited conversation to collaborators Jun 18, 2020
@ytdl-org ytdl-org deleted a comment from kometkamerat Jun 18, 2020
@ytdl-org ytdl-org deleted a comment from elvisandrei16 Jun 18, 2020
@dstftw dstftw closed this in 50e9fcc Sep 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.