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

Extract stream segments for YouTube #479

Merged
merged 3 commits into from
Dec 19, 2020
Merged

Conversation

vkay94
Copy link
Contributor

@vkay94 vkay94 commented Dec 11, 2020

  • I carefully read the contribution guidelines and agree to them.
  • I have tested the API against NewPipe.
  • I agree to create a pull request for NewPipe as soon as possible to make it compatible with the changed API.

This PR extracts the stream segments data provided by YouTube and makes them accessible inside StreamInfo. Other services which don't support this data return an empty list when trying getting them. This also applies to streams in YouTube which aren't divided by the uploader.

Video chapters of a longer stream (desktop version)

The added data class StreamSegment contains the following data:

  • String title: Title of the chapter set by the uploader
  • int startTimeSeconds: Starting point of the chapter in seconds
  • String url: Direct link to the segment (...?t=)
  • String previewUrl: Url to the image at the start position

Test against NewPipe

Demo video in NewPipe's player: https://streamable.com/e/3e27wa
Debug app: app-debug-segments-20201212.zip

Copy link
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@opusforlife2
Copy link
Collaborator

Nice! Maybe there is a way to integrate this into the background player as well.

@vkay94
Copy link
Contributor Author

vkay94 commented Dec 12, 2020

I've updated the commits by using has() and explicit ParsingException throwing if the text and start time aren't valid. I did some testing with a sample video on my Account by trying various scenarios (unordered timestamps, empty titles, unavailable thumbnails at the beginning) and how the ytInitialData is formatted in those cases.

I'll update the test apk shortly.

Copy link
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That looks better now!

@TobiGr TobiGr merged commit 22a4151 into TeamNewPipe:dev Dec 19, 2020
@TobiGr TobiGr added enhancement New feature or request youtube service, https://www.youtube.com/ labels Dec 19, 2020
@vkay94 vkay94 deleted the stream-segments branch December 19, 2020 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request youtube service, https://www.youtube.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants