Add Serie
This commit is contained in:
@@ -19,14 +19,16 @@ final seriesGroupedProvider =
|
||||
|
||||
class SeriesGroupedData {
|
||||
final Map<String, Map<int, List<EpisodeItem>>>
|
||||
data; // showName -> season -> episodes
|
||||
data; // groupKey -> season -> episodes (groupKey is unique per show)
|
||||
SeriesGroupedData(this.data);
|
||||
|
||||
factory SeriesGroupedData.fromEpisodes(List<EpisodeItem> items) {
|
||||
final map = <String, Map<int, List<EpisodeItem>>>{};
|
||||
for (final e in items) {
|
||||
final bySeason =
|
||||
map.putIfAbsent(e.showName, () => <int, List<EpisodeItem>>{});
|
||||
final key = e.showId != null
|
||||
? '${e.showName}##${e.showId}'
|
||||
: (e.firstAirYear != null ? '${e.showName} (${e.firstAirYear})' : e.showName);
|
||||
final bySeason = map.putIfAbsent(key, () => <int, List<EpisodeItem>>{});
|
||||
final list = bySeason.putIfAbsent(e.seasonNumber, () => <EpisodeItem>[]);
|
||||
list.add(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user