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
+32
View File
@@ -231,6 +231,38 @@ void main() {
});
});
group('ytUrlSetzen (F2: YT-Link → Server)', () {
test('POST /yt-url mit song_id + yt_url, status ok → true', () async {
http.Request? anfrage;
final cloud = CloudService(
client: MockClient((req) async {
anfrage = req;
return jsonOk({'status': 'ok'});
}),
);
final ok = await cloud.ytUrlSetzen('s1', 'https://youtu.be/abc');
expect(ok, isTrue);
expect(anfrage!.url.path, '/api/v1/cloud/yt-url');
final body = jsonDecode(anfrage!.body) as Map<String, dynamic>;
expect(body['song_id'], 's1');
expect(body['yt_url'], 'https://youtu.be/abc');
});
test('ytUrlSetzen ohne status ok → false', () async {
final cloud = CloudService(
client: MockClient((req) async => jsonOk({'status': 'error'})),
);
expect(await cloud.ytUrlSetzen('s1', 'https://youtu.be/abc'), isFalse);
});
test('ytUrlSetzen 401 → false (Auth-Fehler)', () async {
final cloud = CloudService(
client: MockClient((req) async => http.Response('{}', 401)),
);
expect(await cloud.ytUrlSetzen('s1', 'https://youtu.be/abc'), isFalse);
});
});
group('History & Songs', () {
test('getHistory parst history-Liste', () async {
final cloud = CloudService(