v2.32 — Defekte Musik erkennen (Magic Bytes, ffprobe, DB-Flag, UI)

This commit is contained in:
Dustin
2026-08-01 16:40:42 +02:00
parent 4a05c76199
commit 2d4c7c8b98
9 changed files with 352 additions and 4 deletions
+33 -2
View File
@@ -20,7 +20,7 @@ class DbHelper {
final pfad = await getDatabasesPath();
return openDatabase(
p.join(pfad, 'melo.db'),
version: 2,
version: 3,
onCreate: (db, version) async {
await db.execute('''
CREATE TABLE songs (
@@ -33,6 +33,7 @@ class DbHelper {
cover_pfad TEXT,
groesse_bytes INTEGER DEFAULT 0,
ist_heruntergeladen INTEGER DEFAULT 0,
ist_korrupt INTEGER DEFAULT 0,
hinzugefuegt_am TEXT NOT NULL,
download_quelle TEXT DEFAULT 'local',
stream_url TEXT,
@@ -91,7 +92,14 @@ class DbHelper {
// Spalte existiert bereits ignorieren
}
}
// Weitere Migrationen: if (oldVersion < 3) { ... }
if (oldVersion < 3) {
try {
await db.execute('ALTER TABLE songs ADD COLUMN ist_korrupt INTEGER DEFAULT 0');
} catch (_) {
// Spalte existiert bereits ignorieren
}
}
// Weitere Migrationen: if (oldVersion < 4) { ... }
},
);
}
@@ -174,6 +182,29 @@ class DbHelper {
return rows.map((r) => Song.fromMap(r)).toList();
}
/// Markiert einen Song als korrupt
Future<void> alsKorruptMarkieren(int songId) async {
final d = await db;
await d.update('songs', {'ist_korrupt': 1},
where: 'id = ?', whereArgs: [songId]);
}
/// Markiert einen Song als nicht-korrupt (Reparatur)
Future<void> korruptZuruecksetzen(int songId) async {
final d = await db;
await d.update('songs', {'ist_korrupt': 0},
where: 'id = ?', whereArgs: [songId]);
}
/// Alle als korrupt markierten Songs abrufen
Future<List<Song>> korrupteSongs() async {
final d = await db;
final rows = await d.query('songs',
where: 'ist_korrupt = 1',
orderBy: 'hinzugefuegt_am DESC');
return rows.map((r) => Song.fromMap(r)).toList();
}
// ─── Tags ────────────────────────────────────────
Future<int> tagErstellen(String name, {String? icon, String? farbe}) async {