Music discovery and remote catalog
Metrolist turns YouTube Music data into a catalog that people can search, browse, and use for discovery. It receives remote page data, maps it to shared music items, applies user content rules, and presents songs, albums, artists, playlists, podcasts, and episodes as playable or navigable results.
Discovery surface
The discovery surface combines remote catalog content with local listening context. The home view loads YouTube Music sections beside local quick picks and listening history, then uses remote related data to build daily, similar, and community recommendations. Explore content adds new releases and mood or genre entry points. app/…/HomeViewModel.kt• L104-125 app/…/HomeViewModel.kt• L441-575
The remote catalog exposes a common set of item types. Each item keeps the identity and navigation or play data needed by the app, so a result can lead to playback, an album or artist page, or an online playlist or podcast page. innertube/…/HomePage.kt• L44-99 innertube/…/SearchPage.kt• L117-360
The main discovery paths are:
- Home and Explore sections for broad recommendations.
- Search suggestions and grouped search results for a direct query.
- Browse pages for catalog sections reached from chips or item links.
- Album, artist, playlist, and podcast pages for focused catalog views.
- Related results for radio-like recommendations and seed-based discovery.
- Charts and new releases for public catalog entry points.
References: app/…/HomeViewModel.kt• L441-575 innertube/…/HomePage.kt• L23-99 innertube/…/ExplorePage.kt• L5-8
Remote data flow
The remote data flow has three roles. The InnerTube client sends requests to YouTube Music and manages the session. The YouTube facade selects a catalog operation and converts the response into page models. App view models apply product rules and expose state to Compose screens. See InnerTube client for the request layer and Catalog search and browse for the page flows.
This diagram shows how a remote response becomes a catalog result or recommendation in the app.
flowchart LR
A[Search or browse intent] --> B[YouTube facade]
B --> C[InnerTube client]
C --> D[YouTube Music response]
D --> E[Page parser]
E --> F[Shared remote item]
F --> G[User content filters]
G --> H[View model state]
H --> I[Catalog screen or playback]
J[Local history and library] --> H
I --> K[Related and radio requests]
K --> C
The app keeps remote page data separate from local library data until it builds a user-facing section. This lets a home section use remote recommendations while local history and saved songs still shape the result. app/…/HomeViewModel.kt• L131-184 app/…/HomeViewModel.kt• L322-360
References: innertube/…/InnerTube.kt• L39-50 innertube/…/YouTube.kt• L86-90 app/…/HomeViewModel.kt• L489-575
Search experience
Search has a suggestion stage and a result stage. While the query changes, the app shows local search history and remote query suggestions. It also recognizes YouTube links and resolves a linked video, playlist, album, or artist into a catalog item. app/…/OnlineSearchSuggestionViewModel.kt• L45-107 app/…/OnlineSearchSuggestionViewModel.kt• L111-163
The default result view groups the remote response into useful sections such as top result, songs, videos, albums, artists, playlists, podcasts, and episodes. Filtered views use a continuation token to load more items. The view model also fills missing artist or duration data before it exposes results. app/…/OnlineSearchViewModel.kt• L52-87 app/…/OnlineSearchViewModel.kt• L89-115 app/…/OnlineSearchViewModel.kt• L140-189
Search results keep the same item meaning as other catalog paths. A song or episode can enter playback, while an album, artist, playlist, or podcast opens its matching remote page. app/…/OnlineSearchResult.kt• L233-361
References: app/…/OnlineSearchSuggestionViewModel.kt• L45-107 app/…/OnlineSearchViewModel.kt• L89-189 app/…/OnlineSearchResult.kt• L491-551
Catalog browsing
Browsing presents remote sections as focused catalog pages. A browse request may represent a home chip, a genre or mood, a chart, or a “more” link from an artist or home section. The result keeps section titles and item groups so the UI can show a page without needing to understand the original response shape. app/…/YouTubeBrowseViewModel.kt• L27-54 innertube/…/BrowseResult.kt• L8-15
Focused pages preserve the relationships that make the catalog useful. Albums contain tracks and related versions. Artists contain sections for songs and other catalog items. Playlists contain songs and continuation state. These pages provide the next navigation step after discovery. innertube/…/AlbumPage.kt• L12-16 innertube/…/ArtistPage.kt• L24-37 innertube/…/PlaylistPage.kt• L13-18
References: app/…/YouTubeBrowseViewModel.kt• L34-52 app/…/YouTubeBrowseScreen.kt• L68-141 innertube/…/BrowseResult.kt• L8-67
Recommendation paths
Recommendations begin with either a local listening seed or a remote item. For a liked or recently played song, the app asks YouTube Music for related content. It can then show songs, albums, artists, playlists, or community playlists, while removing duplicate results and filtering items that the user does not want. app/…/HomeViewModel.kt• L274-320 app/…/HomeViewModel.kt• L497-575
The related page is a cross-type recommendation result. Its groups let the home view choose the right presentation while keeping the same catalog identity used by search and browse. innertube/…/RelatedPage.kt• L16-21
The recommendation path is:
- Select a local song, artist, album, or recent listening signal.
- Resolve the remote endpoint for that seed.
- Request related catalog content.
- Remove duplicates and apply content filters.
- Present the result as a home section or a playable radio queue.
References: app/…/HomeViewModel.kt• L274-320 app/…/HomeViewModel.kt• L508-575 innertube/…/RelatedPage.kt• L16-65
Content policy
Remote results pass through user content rules before they reach most discovery screens. The rules can remove explicit items, video songs, and YouTube Shorts. Empty sections are removed so the UI does not show a heading with no usable content. innertube/…/HomePage.kt• L365-378 innertube/…/SearchSummaryPage.kt• L25-74 innertube/…/BrowseResult.kt• L17-67
These rules shape both initial data and later pages. Continuation loads and selected home chips read the same preferences before they append or replace remote content. This keeps a single discovery view from mixing allowed and hidden item types. app/…/HomeViewModel.kt• L578-630 app/…/OnlineSearchViewModel.kt• L167-189
References: app/…/HomeViewModel.kt• L443-480 app/…/YouTubeBrowseViewModel.kt• L39-51 app/…/OnlineSearchViewModel.kt• L104-111
External content services
YouTube Music is the main remote catalog for discovery. Other services support adjacent content needs rather than replacing the catalog: lyrics and audio-related services enrich playback or metadata, while external dislike data can add video information. See External content services for those boundaries.
References: innertube/…/InnerTube.kt• L371-451 app/…/LyricsMenuViewModel.kt• L68-92
Change checklist
When these files or sections are changed, remember to consider these:
- Keep new remote item types mapped in the page parsers and handled by the search and catalog screens.
- Keep continuation tokens aligned between the facade result models and view-model append logic.
- Apply content rules to initial responses, chip changes, and continuation responses.
- Preserve stable item IDs when changing parsing so deduplication does not remove distinct catalog entries.
- Keep linked YouTube URL types aligned with the page operation that resolves each type.
- Keep local recommendation seeds separate from remote catalog items when changing home sections.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| YouTube changes a response renderer or endpoint shape | An item is dropped or loses its play or browse target | Page parsers return nullable items and screens show only parsed items; parser tests cover key response shapes |
| A continuation is reused or not advanced | Search or catalog loading stops, repeats, or grows duplicate rows | Results carry a continuation separately and appends use distinct item IDs |
| Metadata is missing from search results | A song row lacks an artist or duration | Search resolves artist IDs and requests queue metadata for missing durations |
| A content filter is applied only to the first page | Hidden content appears after scrolling or chip changes | View models apply the same filters to initial, selected, and continuation data |
| An unauthenticated request reaches account-only catalog data | Account playlists or saved podcast content cannot load | Account-specific requests run only when the InnerTube cookie is present |
Key files
| File | Why to read it |
|---|---|
| innertube/…/YouTube.kt | Main catalog facade and shared remote page models |
| innertube/…/InnerTube.kt | Remote request and session boundary; see InnerTube client |
| app/…/HomeViewModel.kt | Home assembly, local seeds, and recommendation paths |
| app/…/OnlineSearchViewModel.kt | Search result shaping, metadata completion, filters, and pagination |
| app/…/OnlineSearchSuggestionViewModel.kt | Query suggestions, history, and linked YouTube URL resolution |
| innertube/…/SearchPage.kt | Search item mapping across songs, albums, artists, playlists, podcasts, and episodes |
| innertube/…/HomePage.kt | Home section mapping and remote item identity |
| innertube/…/RelatedPage.kt | Cross-type recommendation result model |
| app/…/OnlineSearchResult.kt | User-facing search grouping, filters, pagination, and navigation |
| app/…/YouTubeBrowseViewModel.kt | Focused browse request and catalog filtering |