import 'package:lrc/lrc.dart'; class SubtitleSimple { Uri uri; String name; List lyrics; int rating; String provider; SubtitleSimple({ required this.uri, required this.name, required this.lyrics, required this.rating, required this.provider, }); factory SubtitleSimple.fromJson(Map json) { return SubtitleSimple( uri: Uri.parse(json['uri'] as String), name: json['name'] as String, lyrics: (json['lyrics'] as List) .map((e) => LyricSlice.fromJson(e as Map)) .toList(), rating: json['rating'] as int, provider: json['provider'] as String? ?? 'unknown', ); } Map toJson() { return { 'uri': uri.toString(), 'name': name, 'lyrics': lyrics.map((e) => e.toJson()).toList(), 'rating': rating, 'provider': provider, }; } } class LyricSlice { Duration time; String text; LyricSlice({required this.time, required this.text}); factory LyricSlice.fromLrcLine(LrcLine line) { return LyricSlice( time: line.timestamp, text: line.lyrics.trim(), ); } factory LyricSlice.fromJson(Map json) { return LyricSlice( time: Duration(milliseconds: json['time']), text: json['text'] as String, ); } Map toJson() { return { 'time': time.inMilliseconds, 'text': text, }; } @override String toString() { return 'LyricsSlice({time: $time, text: $text})'; } }