39 lines
988 B
Dart
39 lines
988 B
Dart
|
import 'package:json_annotation/json_annotation.dart';
|
||
|
import 'package:ocarina/api/subsonic/subsonic.dart';
|
||
|
part 'album.g.dart';
|
||
|
|
||
|
@JsonSerializable()
|
||
|
class Album {
|
||
|
Album({
|
||
|
required this.id,
|
||
|
required this.name,
|
||
|
required String coverArtId,
|
||
|
required this.playCount,
|
||
|
required this.artistName,
|
||
|
required this.artistId,
|
||
|
required this.year,
|
||
|
required this.songCount,
|
||
|
required this.genres,
|
||
|
required this.duration,
|
||
|
}) : _coverArtId = coverArtId;
|
||
|
|
||
|
final String id;
|
||
|
final String name;
|
||
|
@JsonKey(name: "coverArt")
|
||
|
final String _coverArtId;
|
||
|
final int playCount;
|
||
|
@JsonKey(name: "artist")
|
||
|
final String artistName;
|
||
|
final String artistId;
|
||
|
final int year;
|
||
|
final int songCount;
|
||
|
final List<String> genres;
|
||
|
final int duration;
|
||
|
|
||
|
String get coverArtUrl => SubsonicApiService().getCoverArtUrl(_coverArtId);
|
||
|
|
||
|
factory Album.fromJson(Map<String, dynamic> json) => _$AlbumFromJson(json);
|
||
|
|
||
|
Map<String, dynamic> toJson() => _$AlbumToJson(this);
|
||
|
}
|