Skip to content

plugins.youtube: find videoId on channel pages #3847

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 Jul 4, 2021

Resolves #3846


Find videoId in ytInitialData when input URL is a channel page
and translate URL to canonical video URL.

@bastimeyer bastimeyer added the plugin enhancement A new feature for a working Plugin label Jul 4, 2021
@back-to
Copy link
Collaborator

back-to commented Jul 4, 2021

won't work with /user/ into /c/

https://www.youtube.com/user/deutschewelleenglish

error: Unable to open URL: https://consent.youtube.com/s (404 Client Error: Not Found for url: https://www.youtube.com/c/deutschewelleenglish/live)

Due to the removal of private API requests, this seems to be
the only way to find live streams.

ytInitialData was used to get the video id from the userpage

https://github.com/streamlink/streamlink/blob/2.1.2/src/streamlink/plugins/youtube.py#L61

a bit ugly, but it worked.

videoRenderer -> viewCountText -> runs

https://github.com/streamlink/streamlink/blob/2.1.2/src/streamlink/plugins/youtube.py#L243-L273

@bastimeyer
Copy link
Member Author

won't work with /user/ into /c/

weird, it's working perfectly for a different channel where I tested it

a bit ugly, but it worked.
videoRenderer -> viewCountText -> runs

It's even uglier if you don't use the search_dict method:

ytInitialData
  .contents
  .twoColumnBrowseResultsRenderer
  .tabs[]
  .tabRenderer
  .content
  .sectionListRenderer
  .contents[]
  .itemSectionRenderer
  .contents[]
  .channelFeaturedContentRenderer
  .items[]
  .videoRenderer
  .videoId

@bastimeyer bastimeyer added the WIP Work in process label Jul 4, 2021
Find videoId in ytInitialData when input URL is a channel page
and translate URL to canonical video URL.
@bastimeyer bastimeyer force-pushed the plugins/youtube/translate-channel-urls branch from 4cdd1c4 to 82f565c Compare July 5, 2021 05:28
@bastimeyer bastimeyer removed the WIP Work in process label Jul 5, 2021
@bastimeyer bastimeyer changed the title plugins.youtube: translate channel URLs plugins.youtube: find videoId on channel pages Jul 5, 2021
@back-to back-to merged commit 08a9f46 into streamlink:master Jul 5, 2021
@bastimeyer bastimeyer deleted the plugins/youtube/translate-channel-urls branch July 5, 2021 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin enhancement A new feature for a working Plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

YouTube live stream not detected from channel page
2 participants