ocarina2/lib/api/subsonic/album.dart

40 lines
986 B
Dart
Raw Normal View History

2024-05-23 19:14:08 +02:00
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,
2024-05-24 00:10:11 +02:00
required this.coverArtId,
2024-05-23 19:14:08 +02:00
required this.playCount,
required this.artistName,
required this.artistId,
required this.year,
required this.songCount,
required this.genres,
required this.duration,
2024-05-24 00:10:11 +02:00
});
2024-05-23 19:14:08 +02:00
final String id;
final String name;
@JsonKey(name: "coverArt")
2024-05-24 00:10:11 +02:00
final String coverArtId;
@JsonKey(defaultValue: 0)
2024-05-23 19:14:08 +02:00
final int playCount;
@JsonKey(name: "artist")
final String artistName;
final String artistId;
2024-06-21 12:20:01 +02:00
final int? year;
2024-05-23 19:14:08 +02:00
final int songCount;
final List<String> genres;
final int duration;
2024-05-24 00:10:11 +02:00
String get coverArtUrl => SubsonicApiService().getCoverArtUrl(coverArtId);
2024-05-23 19:14:08 +02:00
factory Album.fromJson(Map<String, dynamic> json) => _$AlbumFromJson(json);
Map<String, dynamic> toJson() => _$AlbumToJson(this);
}