45 lines
1.2 KiB
Dart
45 lines
1.2 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
import 'package:ocarina/api/subsonic/subsonic.dart';
|
|
part 'song.g.dart';
|
|
|
|
@JsonSerializable()
|
|
class Song {
|
|
Song({
|
|
required this.id,
|
|
required this.artistName,
|
|
required this.title,
|
|
required this.albumName,
|
|
required this.albumId,
|
|
required this.artistId,
|
|
required this.duration,
|
|
required this.bitRate,
|
|
required this.contentType,
|
|
required this.fileType,
|
|
required this.coverArtId,
|
|
this.trackNumber,
|
|
});
|
|
|
|
factory Song.fromJson(Map<String, dynamic> json) => _$SongFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$SongToJson(this);
|
|
final String id;
|
|
@JsonKey(name: "artist")
|
|
final String artistName;
|
|
final String? artistId;
|
|
final String albumId;
|
|
final String title;
|
|
@JsonKey(name: "album")
|
|
final String albumName;
|
|
@JsonKey(name: "track")
|
|
final int? trackNumber;
|
|
final int duration;
|
|
final int bitRate;
|
|
final String contentType;
|
|
@JsonKey(name: "suffix")
|
|
final String fileType;
|
|
@JsonKey(name: "coverArt")
|
|
final String coverArtId;
|
|
|
|
String get coverArtUrl => SubsonicApiService().getCoverArtUrl(coverArtId);
|
|
String get streamUrl => SubsonicApiService().getStreamUrl(id);
|
|
}
|