Skip to content

feat(downloads): Smart downloads from your Home mixes - #749

Draft
Sahank29 wants to merge 1 commit into
Clash-Projects:mainfrom
Sahank29:feat/smart-downloads-from-mixes
Draft

Sahank29 wants to merge 1 commit into
Clash-Projects:mainfrom
Sahank29:feat/smart-downloads-from-mixes

Conversation

@Sahank29

Copy link
Copy Markdown
Contributor

Saves songs for offline listening from your YouTube Music Home mixes and rotates them as the mixes change. Off by default, in Settings > Downloads.

How it works

  • YouTube's own Smart downloads endpoint returns no songs to a web sign-in (timing only), so songs come from Home instead: Liked Music and the Supermix / Replay / Discover mixes.
  • A background job (WorkManager) runs at most about once a day. It needs a network, free storage and battery above 20%, and Wi-Fi if "Wi-Fi only" is on.
  • It takes the first ~38 songs of each mix, interleaves them so one mix can't fill the limit, and keeps the first N (default 250).
  • Songs download one at a time into the app's private smart-downloads folder, up to 7 minutes per run, continuing a minute later if songs remain.
  • It stops at the song limit, the storage limit (default 2 GB), or when free space would drop under 512 MB.

What it deletes

  • Only songs it downloaded itself, never manual downloads.
  • After a refresh, saved songs that are no longer in any current mix.
  • Database rows whose file is gone, and files in its folder with no row.
  • Turning it off cancels the job and keeps the files.

Other

  • Database 15 -> 16 (adds a smart-download video id to downloads).
  • Adds androidx.work:work-runtime-ktx.

Tested: unit tests for mix interleaving and rotation. On a device it found 13 mixes, built a 250-song plan and downloaded songs in the background.
Not tested: the settings dialog on small screens, and a full rotation across two days.

Saves songs from Liked Music and the Supermix/Replay/Discover mixes for
offline listening, rotating them as the mixes change. Runs in the
background on Wi-Fi with a battery, storage and song limit.
@Sahank29
Sahank29 marked this pull request as draft November 26, 2026 17:12
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.

1 participant