Skip to content

plugins.youtube: fix video ID retrieval #5673

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

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Nov 18, 2023

Fixes #5672

@cgomesu please check
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#pull-request-feedback

$ streamlink https://www.youtube.com/@ABCNews
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/@ABCNews
Available streams: audio_mp4a, audio_opus, 144p (worst), 240p, 360p, 480p, 720p (best)

$ streamlink https://www.youtube.com/@ABCNews/live
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/@ABCNews/live
Available streams: 144p (worst), 240p, 360p, 480p, 720p (best)

$ streamlink https://www.youtube.com/user/ABCNews
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/user/ABCNews
Available streams: audio_mp4a, audio_opus, 144p (worst), 240p, 360p, 480p, 720p (best)

$ streamlink https://www.youtube.com/user/ABCNews/live
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/user/ABCNews/live
Available streams: 144p (worst), 240p, 360p, 480p, 720p (best)

$ streamlink https://www.youtube.com/c/ABCNews
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/c/ABCNews
Available streams: audio_mp4a, audio_opus, 144p (worst), 240p, 360p, 480p, 720p (best)

$ streamlink https://www.youtube.com/c/ABCNews/live
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/c/ABCNews/live
Available streams: 144p (worst), 240p, 360p, 480p, 720p (best)
$ streamlink https://www.youtube.com/@recordnews
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/@recordnews
Available streams: 144p (worst), 240p, 360p, 480p, 720p, 1080p (best)

$ streamlink https://www.youtube.com/@recordnews/live
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/@recordnews/live
Available streams: 144p (worst), 240p, 360p, 480p, 720p, 1080p (best)

$ streamlink https://www.youtube.com/c/recordnews
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/c/recordnews
Available streams: 144p (worst), 240p, 360p, 480p, 720p, 1080p (best)

$ streamlink https://www.youtube.com/c/recordnews/live
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/c/recordnews/live
Available streams: 144p (worst), 240p, 360p, 480p, 720p, 1080p (best)
$ ./script/test-plugin-urls.py youtube --ignore CHANNEL
:: Finding streams for URL: https://www.youtube.com/embed/aqz-KE-bpKQ
:: Found streams: audio_mp4a, audio_opus, 144p, 240p, 360p, 480p, 720p, 720p60, 1080p60, 1440p60, 2160p60, worst, best
:: Finding streams for URL: https://www.youtube.com/live/aqz-KE-bpKQ
:: Found streams: audio_mp4a, audio_opus, 144p, 240p, 360p, 480p, 720p, 720p60, 1080p60, 1440p60, 2160p60, worst, best
:: Finding streams for URL: https://www.youtube.com/v/aqz-KE-bpKQ
:: Found streams: audio_mp4a, audio_opus, 144p, 240p, 360p, 480p, 720p, 720p60, 1080p60, 1440p60, 2160p60, worst, best
:: Finding streams for URL: https://www.youtube.com/watch?foo=bar&baz=qux&v=aqz-KE-bpKQ&asdf=1234
:: Found streams: audio_mp4a, audio_opus, 144p, 240p, 360p, 480p, 720p, 720p60, 1080p60, 1440p60, 2160p60, worst, best
:: Finding streams for URL: https://youtu.be/aqz-KE-bpKQ
:: Found streams: audio_mp4a, audio_opus, 144p, 240p, 360p, 480p, 720p, 720p60, 1080p60, 1440p60, 2160p60, worst, best

@bastimeyer bastimeyer added the plugin issue A Plugin does not work correctly label Nov 18, 2023
@bastimeyer
Copy link
Member Author

Some non-/live URLs don't seem to return a live stream and instead a VOD, which is then bandwidth-limited due to the plugin's lack of signed content URLs.

@bastimeyer
Copy link
Member Author

Some non-/live URLs don't seem to return a live stream and instead a VOD, which is then bandwidth-limited due to the plugin's lack of signed content URLs.

It's probably because the channel has not highlighted their live stream in this case, so this should be fine...

@cgomesu
Copy link

cgomesu commented Nov 18, 2023

@cgomesu please check https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#pull-request-feedback

I can confirm that the change fixes the issue on my end:

streamlink --loglevel debug https://www.youtube.com/@LofiGirl best
[session][debug] Plugin youtube is being overridden by /home/gomes/.local/share/streamlink/plugins/youtube.py
[cli][debug] OS:         Linux-6.1.0-13-amd64-x86_64-with-glibc2.36
[cli][debug] Python:     3.11.2
[cli][debug] OpenSSL:    OpenSSL 3.0.11 19 Sep 2023
[cli][debug] Streamlink: 6.3.1
[cli][debug] Dependencies:
[cli][debug]  certifi: 2023.11.17
[cli][debug]  isodate: 0.6.1
[cli][debug]  lxml: 4.9.3
[cli][debug]  pycountry: 22.3.5
[cli][debug]  pycryptodome: 3.19.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.31.0
[cli][debug]  trio: 0.23.1
[cli][debug]  trio-websocket: 0.11.1
[cli][debug]  typing-extensions: 4.8.0
[cli][debug]  urllib3: 2.1.0
[cli][debug]  websocket-client: 1.6.4
[cli][debug] Arguments:
[cli][debug]  url=https://www.youtube.com/@LofiGirl
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][info] Found matching plugin youtube for URL https://www.youtube.com/@LofiGirl
[plugins.youtube][debug] Using video ID: jfKfPfyJRdk
[plugins.youtube][debug] This video is live.
[utils.l10n][debug] Language code: pt_BR
[cli][info] Available streams: 144p (worst), 240p, 360p, 480p, 720p, 1080p (best)
[cli][info] Opening stream: 1080p (hls)
[cli][info] Starting player: /usr/bin/vlc
[stream.hls][debug] Reloading playlist
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] First Sequence: 7307198; Last Sequence: 7307203
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 7307201; End Sequence: None
[stream.hls][debug] Adding segment 7307201 to queue
[stream.hls][debug] Adding segment 7307202 to queue
[stream.hls][debug] Adding segment 7307203 to queue
[stream.hls][debug] Writing segment 7307201 to output
[stream.hls][debug] Segment 7307201 complete
[cli.output][debug] Opening subprocess: ['/usr/bin/vlc', '--input-title-format', 'https://www.youtube.com/@LofiGirl', '-']
[stream.hls][debug] Writing segment 7307202 to output
[stream.hls][debug] Segment 7307202 complete
[cli][debug] Writing stream to output
[stream.hls][debug] Writing segment 7307203 to output
[stream.hls][debug] Segment 7307203 complete
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 7307204 to queue
[stream.hls][debug] Writing segment 7307204 to output
[stream.hls][debug] Segment 7307204 complete
[stream.hls][debug] Reloading playlist
[stream.hls][debug] Adding segment 7307205 to queue
[stream.hls][debug] Writing segment 7307205 to output
[stream.hls][debug] Segment 7307205 complete
^C[stream.segmented][debug] Closing worker thread
[stream.segmented][debug] Closing writer thread
[cli][info] Stream ended
Interrupted! Exiting...
[cli][info] Closing currently open stream...

@bastimeyer bastimeyer merged commit 7874c7e into streamlink:master Nov 18, 2023
@bastimeyer bastimeyer deleted the plugins/youtube/fix-ytInitialData branch November 18, 2023 19:56
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugins.youtube: Could not find videoId on channel page but there's a live-stream available
2 participants