Skip to content

plugins.nrk: remove metadata, add region check #5408

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

Merged
merged 1 commit into from
Jul 1, 2023

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Jul 1, 2023

Fixes #5407

100% unsure whether this fixes #5407, because they detect my VPN, so I can't see the API responses.

This PR refactors the plugin and simply removes the stream metadata and adds a region check.

@werid please validate these changes.
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#pull-request-feedback


Test URLs are unmodified and the failing ones are probably outdated...

$ ./script/test-plugin-urls.py nrk
:: Finding streams for URL: https://radio.nrk.no/direkte/p1
:: Found streams: 32k, 130k, worst, best
:: Finding streams for URL: https://radio.nrk.no/direkte/p2
:: Found streams: 32k, 130k, worst, best
:: Finding streams for URL: https://radio.nrk.no/podkast/oppdatert/l_5005d62a-7f4f-4581-85d6-2a7f4f2581f2
:: Found streams: live, worst, best
:: Finding streams for URL: https://tv.nrk.no/direkte/nrk1
:::: Not playable: blocked - For å se dette i EØS må du logge inn og bekrefte at du er bosatt i Norge med BankID
!! No streams found
:: Finding streams for URL: https://tv.nrk.no/direkte/nrk2
:::: Not playable: blocked - For å se dette i EØS må du logge inn og bekrefte at du er bosatt i Norge med BankID
!! No streams found
:: Finding streams for URL: https://tv.nrk.no/direkte/nrk3
:::: Not playable: notransmission - Ingen sending
!! No streams found
:: Finding streams for URL: https://tv.nrk.no/direkte/nrksuper
:::: Not playable: blocked - For å se dette i EØS må du logge inn og bekrefte at du er bosatt i Norge med BankID
!! No streams found
:: Finding streams for URL: https://tv.nrk.no/program/NNFA51102617
:: Found streams: 270p, 360p, 540p, 720p, worst, best
:: Finding streams for URL: https://tv.nrk.no/serie/kongelige-fotografer/sesong/1/episode/2/avspiller
:: Found streams: 270p, 360p, 540p, 720p, worst, best
:: Finding streams for URL: https://tv.nrk.no/serie/nytt-paa-nytt/2020/MUHH43003020
:::: Not playable: blocked - Ikke tilgjengelig lenger
!! No streams found

@bastimeyer bastimeyer added plugin issue A Plugin does not work correctly restriction: geo blocked labels Jul 1, 2023
@bastimeyer bastimeyer force-pushed the plugins/nrk/fix-5407 branch from bebd81d to be26c21 Compare July 1, 2023 15:23
@werid
Copy link

werid commented Jul 1, 2023

Can confirm this fixes the issue.

[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.11.0
[cli][debug] Streamlink: 5.1.1+267.gbe26c216
[cli][debug] Dependencies:
[cli][debug]  certifi: 2022.9.24
[cli][debug]  isodate: 0.6.1
[cli][debug]  lxml: 4.9.2
[cli][debug]  pycountry: 22.3.5
[cli][debug]  pycryptodome: 3.18.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.29.0
[cli][debug]  urllib3: 1.26.13
[cli][debug]  websocket-client: 1.4.2
[cli][debug] Arguments:
[cli][debug]  url=https://tv.nrk.no/direkte/nrk1
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --ffmpeg-ffmpeg=C:\Program Files (x86)\Streamlink\ffmpeg\ffmpeg.exe
[cli][info] Found matching plugin nrk for URL https://tv.nrk.no/direkte/nrk1
[utils.l10n][debug] Language code: en_US
[cli][info] Available streams: 270p (worst), 360p, 540p, 720p_alt, 720p, 1080p (best)
[cli][info] Opening stream: 1080p (hls)
[cli][info] Starting player: "C:\Program Files\VideoLAN\VLC\vlc.exe"
[stream.hls][debug] Reloading playlist
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] Segments in this playlist are encrypted
[stream.hls][debug] First Sequence: 26814756; Last Sequence: 26815840
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 26815838; End Sequence: None
[stream.hls][debug] Adding segment 26815838 to queue
[stream.hls][debug] Adding segment 26815839 to queue
[stream.hls][debug] Adding segment 26815840 to queue
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Segments in this playlist are encrypted
[stream.hls][debug] Adding segment 26815841 to queue
[stream.hls][debug] Writing segment 26815838 to output
[stream.hls][debug] Segment 26815838 complete
[cli.output][debug] Opening subprocess: "C:\Program Files\VideoLAN\VLC\vlc.exe" --input-title-format https://tv.nrk.no/direkte/nrk1 -
[cli][debug] Writing stream to output

@bastimeyer
Copy link
Member Author

Thanks. Could you please also have a quick look at the API responses from

  • https://psapi.nrk.no/playback/manifest/{manifest_type}/{program_id}
  • https://psapi.nrk.no/playback/metadata/{manifest_type}/{program_id}?eea-portability=true

with {manifest_type} being channel and {program_id} being nrk1?

If I knew the exact API response contents, I could maybe add stream metadata back to the plugin.

@bastimeyer bastimeyer merged commit 72eb680 into streamlink:master Jul 1, 2023
@bastimeyer bastimeyer deleted the plugins/nrk/fix-5407 branch July 1, 2023 20:35
@bastimeyer
Copy link
Member Author

The metadata is empty on all other streams, so removing it is the right choice. Merged...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin issue A Plugin does not work correctly restriction: geo blocked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugins.nrk: error: Unable to validate JSON
2 participants