Skip to content

Add endscreen data parsing from YouTube API#22

Open
Eutalix wants to merge 7 commits into
yuliskov:masterfrom
Eutalix:feature/endscreen-parsing
Open

Add endscreen data parsing from YouTube API#22
Eutalix wants to merge 7 commits into
yuliskov:masterfrom
Eutalix:feature/endscreen-parsing

Conversation

@Eutalix

@Eutalix Eutalix commented Apr 3, 2026

Copy link
Copy Markdown

Summary

This PR adds parsing support for YouTube end screens - the interactive elements that appear near the end of videos (recommended videos, channels, subscribe buttons, playlists).

The YouTube API already returns this data in the response, but it was being completely ignored by the parsers.

Changes

New Interfaces

  • EndScreenItem - Public API contract for endscreen elements

New Models (JSON parsing)

  • EndScreen - Root endscreen object
  • EndScreenRenderer - Container for endscreen elements
  • EndScreenElement - Individual endscreen element with positioning, timing, and content

Implementation

  • YouTubeEndScreenItem - Converts parsed JSON models to EndScreenItem interface

Integration

  • Modified WatchNextResult to parse $.endscreen from API response
  • Modified MediaItemMetadata interface to expose getEndScreenItems()
  • Modified YouTubeMediaItemMetadata to populate endscreen items from parsed data

API Data Structure

Each endscreen element contains:

  • Type: VIDEO, CHANNEL, PLAYLIST
  • Content: title, description, thumbnail
  • Timing: startMs, endMs (when to show/hide)
  • Positioning: left, top, width, aspectRatio (layout coordinates)
  • Target: videoId, channelId, or playlistId (where it links to)

Testing

The API already returns this data - verified in existing test fixtures:

  • youtubeapi/src/test/resources/video_info/get_video_info.json

Next Steps

This PR only adds the parsing/data layer. Future work needed:

  1. Expose in SmartTube's Video model
  2. Create UI overlay component
  3. Handle user interaction (clicking elements)
  4. Add settings toggle

@yuliskov

yuliskov commented Apr 3, 2026

Copy link
Copy Markdown
Owner

Thanks, I'll review this pr later.

@Eutalix Eutalix force-pushed the feature/endscreen-parsing branch 2 times, most recently from a732336 to bf4bec3 Compare April 3, 2026 18:05
- Add EndScreenItem interface for public API contract
- Add EndScreen, EndScreenRenderer, EndScreenElement models to parse JSON
- Add YouTubeEndScreenItem implementation
- Parse endscreen data in WatchNextResult
- Expose endscreen items via MediaItemMetadata.getEndScreenItems()

The YouTube API already returns endscreen data (interactive elements
shown at the end of videos), but it was being ignored. This change
adds the parsing layer to make the data available to clients.

No UI implementation yet - this is just the data/parsing layer.
@Eutalix Eutalix force-pushed the feature/endscreen-parsing branch from bf4bec3 to 7ebe011 Compare April 3, 2026 18:13
@Eutalix

Eutalix commented Apr 3, 2026

Copy link
Copy Markdown
Author

Thanks, I'll review this pr later.

@yuliskov Ok! 🙂

Eutalix added 6 commits April 9, 2026 18:53
V2 API implementation returns null as end screens are not supported in V2.
End screen support is only available in V1 API.
- Replace CommonItems.Thumbnail with ThumbnailItem
- Fix thumbnail URL extraction using getThumbnails()
- Ensure compatibility with existing codebase structure
- Use youtubeapi.common.helpers.YouTubeHelper instead of googlecommon version
- Pass ThumbnailItem directly instead of getThumbnails() list
- Fix type compatibility issue with findOptimalResThumbnailUrl
- Add EndScreenElement.getThumbnails() Kotlin extension
- Use ThumbnailItem for image field in EndScreenElement
- Import Kotlin extension in YouTubeEndScreenItem using static import
- Add getEndScreenItems() stub to V2 implementation (returns null)
- Fix thumbnail URL extraction using CommonHelperKt.getThumbnails
- Import EndScreenElement at the top of CommonHelper.kt
- Ensure Kotlin extension function compiles correctly
- Add getThumbnails() extension at top level (not inside function)
- Import EndScreenElement at file header
- Ensure proper Kotlin syntax and scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants