Add Serie

This commit is contained in:
2025-10-31 09:50:17 +01:00
parent 1ce512b1c4
commit 72b4f4e30c
5 changed files with 297 additions and 17 deletions
@@ -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);
}