This repository has been archived on 2026-08-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
melo-app/lib/models/song.dart
T
Hermes (Server) 9a880b0f21 Security: Cloud-Auth auf Bearer-JWT umgestellt (IDOR-Luecke geschlossen)
- cloud_service: echter Login gegen baka-auth, Token statt X-API-Key/X-User
- app_config: hartcodierten API-Key-Default entfernt
- download_service + melo_logger: Bearer-Token statt X-API-Key
- navidrome: Passwort in flutter_secure_storage (Keychain/Keystore)
- song: token-haltige stream_url wird nicht mehr in SQLite persistiert
- cloud_screen: Pfad-Traversal beim Download-Dateinamen gefixt (p.basename)
- home_screen: Login-Dialog mit Passwort-Feld, Auto-Sync nutzt restoreLogin
2026-07-31 14:31:12 +02:00

76 lines
2.5 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class Song {
final int? id;
final String titel;
final String kuenstler;
final String album;
final int dauerSekunden;
final String dateiPfad;
final String? coverPfad;
final int groesseBytes;
final bool istHeruntergeladen;
final String hinzugefuegtAm;
final String downloadQuelle; // "local", "youtube", "server"
final String? streamUrl; // Für Server-Streaming (Navidrome) wird bewusst NICHT in der DB persistiert (Auth-Token-Schutz)
int? zuletztPosition; // Sekunden, für Wiederaufnahme
Set<int>? tagIds; // Cache für Tag-Filterung (nicht in DB gespeichert)
Song({
this.id,
required this.titel,
required this.kuenstler,
this.album = '',
required this.dauerSekunden,
required this.dateiPfad,
this.coverPfad,
this.groesseBytes = 0,
this.istHeruntergeladen = false,
String? hinzugefuegtAm,
this.downloadQuelle = 'local',
this.streamUrl,
this.zuletztPosition,
}) : hinzugefuegtAm = hinzugefuegtAm ?? DateTime.now().toIso8601String();
Map<String, dynamic> toMap() => {
'id': id,
'titel': titel,
'kuenstler': kuenstler,
'album': album,
'dauer_sekunden': dauerSekunden,
'datei_pfad': dateiPfad,
'cover_pfad': coverPfad,
'groesse_bytes': groesseBytes,
'ist_heruntergeladen': istHeruntergeladen ? 1 : 0,
'hinzugefuegt_am': hinzugefuegtAm,
'download_quelle': downloadQuelle,
'stream_url': null, // Token-haltige Stream-URLs nie persistieren (Sicherheit)
'zuletzt_position': zuletztPosition,
};
factory Song.fromMap(Map<String, dynamic> m) => Song(
id: m['id'] as int?,
titel: m['titel'] as String,
kuenstler: m['kuenstler'] as String,
album: m['album'] as String? ?? '',
dauerSekunden: m['dauer_sekunden'] as int,
dateiPfad: m['datei_pfad'] as String,
coverPfad: m['cover_pfad'] as String?,
groesseBytes: m['groesse_bytes'] as int? ?? 0,
istHeruntergeladen: (m['ist_heruntergeladen'] as int?) == 1,
hinzugefuegtAm: m['hinzugefuegt_am'] as String?,
downloadQuelle: m['download_quelle'] as String? ?? 'local',
streamUrl: m['stream_url'] as String?,
zuletztPosition: m['zuletzt_position'] as int?,
);
String get dauerFormatiert {
final min = dauerSekunden ~/ 60;
final sek = dauerSekunden % 60;
return '$min:${sek.toString().padLeft(2, '0')}';
}
String get groesseFormatiert {
if (groesseBytes < 1048576) return '${(groesseBytes / 1024).toStringAsFixed(0)} KB';
return '${(groesseBytes / 1048576).toStringAsFixed(1)} MB';
}
}