v2.52.1 — F2: YT-Links nur als Server-Fallback

## YT-Quell-URL (Server ist die Quelle)
- cloud_service.ytUrlSetzen(): POST /api/v1/cloud/yt-url (per-User UPDATE user_songs.yt_url)
- musik_scanner._sucheYtUrls(): durchsucht NUR Songs mit cloud_id, die auf dem Server noch keine yt_url haben; Treffer werden auf den Server hochgeladen statt lokal gespeichert
- db_helper: ytUrlAktualisieren/songsOhneYtUrl entfernt, songsMitCloudId() ergänzt
- download_service: yt_url wird beim Download nicht mehr lokal persistiert

## Fallback-Kette reDownload (korrupte/fehlende Datei)
- 1) Server-Download via cloud_id + Magic-Byte-Check (primäre Quelle)
- 2) Server-ytUrl (aus listSongs) → yt-proxy als letzte Chance
- 3) Legacy: lokal gespeicherte ytUrl (Bestandsdaten vor v2.52)
- song_tile: „Neu laden“ erscheint bei istKorrupt && (cloudId != null || ytUrl != null)
- 3 neue Tests (ytUrlSetzen: ok/error/401) → 111 Tests grün, analyze 0 Issues
This commit is contained in:
Dustin
2026-08-05 10:40:37 +02:00
parent 3b898e238e
commit bf0f544e4b
6 changed files with 158 additions and 35 deletions
+5 -10
View File
@@ -313,18 +313,13 @@ class DbHelper {
return rows.map((r) => Song.fromMap(r)).toList();
}
/// YouTube-Quell-URL für einen Song speichern
Future<void> ytUrlAktualisieren(int songId, String ytUrl) async {
final d = await db;
await d.update('songs', {'yt_url': ytUrl},
where: 'id = ?', whereArgs: [songId]);
}
/// Alle Songs ohne YouTube-Quell-URL abrufen (für Scanner-Suche)
Future<List<Song>> songsOhneYtUrl({int limit = 50}) async {
/// Alle Songs MIT cloud_id (Server-Verknüpfung) — Grundlage für die
/// YT-Quell-URL-Suche (F2): Treffer werden auf den SERVER hochgeladen
/// (POST /api/v1/cloud/yt-url) statt lokal gespeichert.
Future<List<Song>> songsMitCloudId({int limit = 50}) async {
final d = await db;
final rows = await d.query('songs',
where: 'yt_url IS NULL OR yt_url = ""',
where: 'cloud_id IS NOT NULL AND cloud_id != ""',
orderBy: 'hinzugefuegt_am DESC',
limit: limit);
return rows.map((r) => Song.fromMap(r)).toList();