Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / youpipe / AGENTS.md
| 1 | # AGENTS.md — youpipe/ (':youpipe') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `youpipe/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install youpipe (dev by default)._ |
| 6 | <!-- last-reviewed: 2026-10-16 --> |
| 7 | - Gradle: :youpipe / dir: youpipe/ |
| 8 | - Package roots present: ui, data, platform |
| 9 | - Entry files: MainActivity.kt (no YouPipeApplication.kt — listed file does not exist; Route inline) |
| 10 | - Deps: :library:image, :youpipe:extractor, :sdk:cast, :library:room, :library:work, :library:network |
| 11 | - Metadata: metadata_data/youpipe.md (present) |
| 12 | - Rust: yes / screenshotTest: yes |
| 13 | |
| 14 | ## Overview |
| 15 | **Purpose:** An ad-free Material 3 YouTube client (NewPipe extractor lineage) with subscriptions, history, downloads, and recommendations. Requires internet. |
| 16 | **Key features:** |
| 17 | - Subscription feed with categories, auto-refresh (`SubscriptionFetchTask`), watch history + resume, playlists, and Watch Later |
| 18 | - Video playback via Media3/ExoPlayer with SABR streaming, SponsorBlock, chapters, background audio, and Picture-in-Picture |
| 19 | - Offline downloads (`DownloadManager`/`DownloadWorker`) with import/export, plus Cast-to-TV via `:sdk:cast` |
| 20 | - Local recommendations engine with tunable interests/keywords and impression tracking |
| 21 | **Architecture / data-flow:** Tabbed-pager `ui/` (`Main` tabs + `VideoPage`/`ChannelPage`/dialog routes) over `util/YouPipeViewModel` → `data/` Room (`SubscriptionDatabase`, repository + per-entity stores) fed by `SubscriptionFetchTask` and the Rust InnerTube extractor (`rustNativeLib youpipe_extractor`) bridged via `nativeext/` + `util/Extractor.kt`; playback runs through `util/PlaybackService` + the `util/sabr/` session stack. `onCreateBeforeContent` touches the VM so its hourly task arms, then resolves the launch backstack (share-target → watch link → persisted default page). |
| 22 | **Entry points + reading order:** `Route` (`Main(tab)` / `VideoPage` / `ChannelPage` / `SubscriptionVideosPage` / `PlaylistDetail` / `Downloads` + dialogs, inline) → `MainActivity.kt` (`resolveInitialBackStack`) → `ui/VideoPage.kt` → `util/YouPipeViewModel.kt` → `util/Extractor.kt` → `data/SubscriptionRepository.kt`. |
| 23 | **Gotchas:** |
| 24 | - Card drift fixed: `YouPipeApplication.kt` never existed — deleted from Entry files; card also gains `data/PlaylistStore`, `RecommendationStore`, `SubscriptionCategoryStore`, `util/YouPipePlaylistOps`, `util/YouPipeRecommendationSettings`, `ui/VideoPlayerNotificationProgressBar` |
| 25 | - `resolveInitialBackStack` runs synchronously in `onCreate` (before `setContent`) — keep it side-effect free |
| 26 | - PiP close and activity destroy deliberately do NOT stop `PlaybackService`; audio keeps playing and switches to audio-only |
| 27 | - SABR attestation goes through the `sabr/` WebView/token stack — changes there break playback long before the player UI does |
| 28 | |
| 29 | ## Key files |
| 30 | ### Root — entry + inline navigation |
| 31 | - com/vayunmathur/youpipe/MainActivity.kt — Route, share/deep-link backstack, default page |
| 32 | ### data/ — subscriptions, playlists, recommendations (Room) |
| 33 | - com/vayunmathur/youpipe/data/SubscriptionDatabase.kt |
| 34 | - com/vayunmathur/youpipe/data/SubscriptionRepository.kt |
| 35 | - com/vayunmathur/youpipe/data/Subscription.kt |
| 36 | - com/vayunmathur/youpipe/data/SubscriptionVideo.kt |
| 37 | - com/vayunmathur/youpipe/data/SubscriptionCategory.kt |
| 38 | - com/vayunmathur/youpipe/data/SubscriptionCategoryStore.kt |
| 39 | - com/vayunmathur/youpipe/data/Playlist.kt |
| 40 | - com/vayunmathur/youpipe/data/PlaylistStore.kt |
| 41 | - com/vayunmathur/youpipe/data/HistoryVideo.kt |
| 42 | - com/vayunmathur/youpipe/data/DownloadedVideo.kt |
| 43 | - com/vayunmathur/youpipe/data/CachedRelatedVideo.kt |
| 44 | - com/vayunmathur/youpipe/data/ChannelPreference.kt |
| 45 | - com/vayunmathur/youpipe/data/KeywordPreference.kt |
| 46 | - com/vayunmathur/youpipe/data/RecommendationPreferences.kt |
| 47 | - com/vayunmathur/youpipe/data/RecommendationImpression.kt |
| 48 | - com/vayunmathur/youpipe/data/RecommendationStore.kt |
| 49 | ### nativeext/ — Rust extractor bridge |
| 50 | - com/vayunmathur/youpipe/nativeext/YouPipeNative.kt |
| 51 | - com/vayunmathur/youpipe/nativeext/NativeExtractor.kt |
| 52 | ### platform/ — cast playback |
| 53 | - com/vayunmathur/youpipe/platform/CastPlayback.kt |
| 54 | ### ui/ — tabs, feed, search, library |
| 55 | - com/vayunmathur/youpipe/ui/VideoPage.kt |
| 56 | - com/vayunmathur/youpipe/ui/VideoPlayer.kt |
| 57 | - com/vayunmathur/youpipe/ui/VideoPlayerViewState.kt |
| 58 | - com/vayunmathur/youpipe/ui/VideoPlayerPlaybackState.kt |
| 59 | - com/vayunmathur/youpipe/ui/VideoPlayerPlaybackEffects.kt |
| 60 | - com/vayunmathur/youpipe/ui/VideoPlayerSeekRow.kt |
| 61 | - com/vayunmathur/youpipe/ui/VideoPlayerTopControls.kt |
| 62 | - com/vayunmathur/youpipe/ui/VideoPlayerChapterSheet.kt |
| 63 | - com/vayunmathur/youpipe/ui/VideoPlayerCasting.kt |
| 64 | - com/vayunmathur/youpipe/ui/VideoPlayerNotificationProgressBar.kt |
| 65 | - com/vayunmathur/youpipe/ui/VideoDetails.kt |
| 66 | - com/vayunmathur/youpipe/ui/VideoDetailScreen.kt |
| 67 | - com/vayunmathur/youpipe/ui/VideoFormatting.kt |
| 68 | - com/vayunmathur/youpipe/ui/VideoSections.kt |
| 69 | - com/vayunmathur/youpipe/ui/VideoRow.kt |
| 70 | - com/vayunmathur/youpipe/ui/FeedGrid.kt |
| 71 | - com/vayunmathur/youpipe/ui/SearchPage.kt |
| 72 | - com/vayunmathur/youpipe/ui/ChannelPage.kt |
| 73 | - com/vayunmathur/youpipe/ui/SubscriptionsPage.kt |
| 74 | - com/vayunmathur/youpipe/ui/SubscriptionVideosPage.kt |
| 75 | - com/vayunmathur/youpipe/ui/HistoryPage.kt |
| 76 | - com/vayunmathur/youpipe/ui/SavedPage.kt |
| 77 | - com/vayunmathur/youpipe/ui/PlaylistDetailPage.kt |
| 78 | - com/vayunmathur/youpipe/ui/DownloadedVideosPage.kt |
| 79 | - com/vayunmathur/youpipe/ui/LinkifiedText.kt |
| 80 | - com/vayunmathur/youpipe/ui/dialogs/AddToPlaylist.kt |
| 81 | - com/vayunmathur/youpipe/ui/dialogs/AddToWatchLater.kt |
| 82 | - com/vayunmathur/youpipe/ui/dialogs/CreatePlaylist.kt |
| 83 | - com/vayunmathur/youpipe/ui/dialogs/CreateSubscriptionCategory.kt |
| 84 | ### ui/ — settings |
| 85 | - com/vayunmathur/youpipe/ui/SettingsPage.kt |
| 86 | - com/vayunmathur/youpipe/ui/GeneralSettingsPage.kt |
| 87 | - com/vayunmathur/youpipe/ui/SponsorBlockSettingsPage.kt |
| 88 | - com/vayunmathur/youpipe/ui/RecommendationsSettingsPage.kt |
| 89 | - com/vayunmathur/youpipe/ui/ManageInterestsPage.kt |
| 90 | - com/vayunmathur/youpipe/ui/DataSettingsPage.kt |
| 91 | ### util/ — ViewModel, extraction, playback, sync (migration pending) |
| 92 | - com/vayunmathur/youpipe/util/YouPipeViewModel.kt |
| 93 | - com/vayunmathur/youpipe/util/YouPipeUiContract.kt |
| 94 | - com/vayunmathur/youpipe/util/YouPipeVideoLoading.kt |
| 95 | - com/vayunmathur/youpipe/util/Extractor.kt |
| 96 | - com/vayunmathur/youpipe/util/MyDownloader.kt |
| 97 | - com/vayunmathur/youpipe/util/PlaybackService.kt |
| 98 | - com/vayunmathur/youpipe/util/DownloadManager.kt |
| 99 | - com/vayunmathur/youpipe/util/DownloadWorker.kt |
| 100 | - com/vayunmathur/youpipe/util/SubscriptionFetchTask.kt |
| 101 | - com/vayunmathur/youpipe/util/Recommender.kt |
| 102 | - com/vayunmathur/youpipe/util/YouPipeRecommendations.kt |
| 103 | - com/vayunmathur/youpipe/util/YouPipeRecommendationSettings.kt |
| 104 | - com/vayunmathur/youpipe/util/YouPipePlaylistOps.kt |
| 105 | - com/vayunmathur/youpipe/util/YouPipeImportExport.kt |
| 106 | ### util/sabr/ — SABR session + attestation stack |
| 107 | - com/vayunmathur/youpipe/util/sabr/SabrNgSession.kt |
| 108 | - com/vayunmathur/youpipe/util/sabr/SabrNgSessionStore.kt |
| 109 | - com/vayunmathur/youpipe/util/sabr/SabrNgSourceSpec.kt |
| 110 | - com/vayunmathur/youpipe/util/sabr/SabrNgDashMediaSource.kt |
| 111 | - com/vayunmathur/youpipe/util/sabr/SabrNgDownloadHelper.kt |
| 112 | - com/vayunmathur/youpipe/util/sabr/SabrNgSegmentDataSource.kt |
| 113 | - com/vayunmathur/youpipe/util/sabr/SabrRequestCoordinator.kt |
| 114 | - com/vayunmathur/youpipe/util/sabr/SabrFfmpegMuxer.kt |
| 115 | - com/vayunmathur/youpipe/util/sabr/SabrAttestationRetryHandler.kt |
| 116 | - com/vayunmathur/youpipe/util/sabr/SabrDownloadException.kt |
| 117 | - com/vayunmathur/youpipe/util/sabr/LocalDomPoTokenProvider.kt |
| 118 | - com/vayunmathur/youpipe/util/sabr/LocalDomPoTokenGenerator.kt |
| 119 | - com/vayunmathur/youpipe/util/sabr/SabrLocalDomPoTokenUtil.kt |
| 120 | - com/vayunmathur/youpipe/util/sabr/SharedWebViewRuntime.kt |
| 121 | - com/vayunmathur/youpipe/util/sabr/YoutubePageAttestationBootstrap.kt |
| 122 | |
| 123 | ## Verify (this module only) |
| 124 | ``` |
| 125 | ./gradlew :youpipe:compileDevKotlin |
| 126 | ./gradlew :youpipe:lint |
| 127 | ./gradlew :youpipe:checkMetadata |
| 128 | ``` |