feat: download songs in Low quality

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
joshuafhigginsandClaude Opus 5.5 committed 2026-11-20 15:00:19 -05:00 Verified
1 parent d7d476e5ec
commit 06d501921d
3 files changed
+18 -9

No files matched your search

@@ -450,9 +450,10 @@ function QualitySection({ user }: { user: CurrentUser }) {
/** Shades of the text color, faintest for the smallest files. */
const QUALITY_OPACITY: Record<DownloadQuality, number> = {
medium: 0.25,
high: 0.45,
lossless: 0.7,
low: 0.2,
medium: 0.35,
high: 0.5,
lossless: 0.75,
atmos: 1,
}
+4 -3
View File
@@ -39,9 +39,10 @@ const ASK_EVERY_TIME = "ask"
/** Shades of the text color, darkest for the smallest files. */
const QUALITY_OPACITY: Record<DownloadQuality, number> = {
medium: 0.25,
high: 0.45,
lossless: 0.7,
low: 0.2,
medium: 0.35,
high: 0.5,
lossless: 0.75,
atmos: 1,
}
+10 -3
View File
@@ -2,6 +2,7 @@ import type { PlaybackSource, PlaybackStreamPlan } from "./playback-stream"
/** Qualities a listener can pick when downloading, lowest first. */
export const DOWNLOAD_QUALITIES = [
"low",
"medium",
"high",
"lossless",
@@ -11,6 +12,7 @@ export const DOWNLOAD_QUALITIES = [
export type DownloadQuality = (typeof DOWNLOAD_QUALITIES)[number]
export const DOWNLOAD_QUALITY_LABELS: Record<DownloadQuality, string> = {
low: "Low",
medium: "Medium",
high: "High",
lossless: "Lossless",
@@ -18,12 +20,14 @@ export const DOWNLOAD_QUALITY_LABELS: Record<DownloadQuality, string> = {
}
export const DOWNLOAD_QUALITY_DETAILS: Record<DownloadQuality, string> = {
low: "AAC 64 kbps",
medium: "AAC 128 kbps",
high: "AAC 256 kbps",
lossless: "ALAC or FLAC",
atmos: "Spatial audio",
}
const LOW_KBPS = 64
const MEDIUM_KBPS = 128
const HIGH_KBPS = 256
@@ -54,13 +58,14 @@ function highPlan(files: Record<string, unknown>): DownloadPlan {
/**
* Picks the file for one song. Lossless and Dolby Atmos fall back to High when
* the song lacks them, and Medium is always transcoded.
* the song lacks them, and Low and Medium are always transcoded.
*/
export function downloadPlan(
files: Record<string, unknown>,
quality: DownloadQuality
): DownloadPlan {
switch (quality) {
case "low":
case "medium":
return {
quality,
@@ -70,7 +75,7 @@ export function downloadPlan(
: "normal" in files
? "normal"
: "atmos",
kbps: MEDIUM_KBPS,
kbps: quality === "low" ? LOW_KBPS : MEDIUM_KBPS,
}
case "high":
return highPlan(files)
@@ -84,7 +89,7 @@ export function downloadPlan(
/**
* The download quality holding the same audio a stream plan plays, so a
* download can stand in for streaming. Low has no download equivalent.
* download can stand in for streaming.
*/
export function streamDownloadQuality(
plan: PlaybackStreamPlan
@@ -95,6 +100,7 @@ export function streamDownloadQuality(
}
if (plan.kbps === HIGH_KBPS) return "high"
if (plan.kbps === MEDIUM_KBPS) return "medium"
if (plan.kbps === LOW_KBPS) return "low"
return undefined
}
@@ -129,6 +135,7 @@ export function downloadOptions(
).length
if (
fallbackCount === songs.length &&
quality !== "low" &&
quality !== "medium" &&
quality !== "high"
) {