Files
plezy/lib/models/simkl/simkl_all_items_entry.dart
edde746 27acbaf435 feat(explore): surface the catalog data providers already return
Explore shelf cards drew a poster, a title and a year. An audit of all six
catalog sources found the rest was lost at two boundaries — the wire-to-DTO
mapping and the DTO-to-CatalogItem mapping — and then simply not drawn: the
grid card fell through every branch of buildMetadataSubtitle to the year-only
case, while the list card used by search already composed certification,
runtime and rating from fields the synthesized MediaItem already held.

Extend CatalogItem with the neutral facts every provider had been dropping:
attributed rating sources, leaderboard ranks that keep their season window,
audience counters that keep their timeframe, broadcast slots, next-episode air
times, server availability and request state, exact release dates, alternate
titles, format, source material, studios, countries, languages, credits, tags,
links, artwork variants, play state, gallery art and background prose. Replace
fetchCast and fetchRelated with one fetchDetail returning the enriched item,
its cast, its recommendations and labelled franchise relations without adding
a request: sources needing two calls keep two and run them concurrently with
isolated failures.

Map those fields in all six sources, widening only field selections that cost
no extra round trip — MAL's fields list, AniList's selection set and a bounded
row cast that lets detail skip its character call, Trakt's guest stars, Seerr's
language parameter and TMDB size ladder, and Plex's includeUserState. Plex hub
artwork widens only on TV, where the spotlight is its only consumer, because it
doubles the payload.

Render them: a rating-first caption and bounded badges on the shelf card,
labelled sections on the detail screen, provider hub styles and result counts
on shelves, and logo, banner and accent art in the TV spotlight.

Verified against live Plex, AniList, Simkl and MAL responses, and on a Pixel 7.
2026-07-29 06:47:54 +02:00

92 lines
2.5 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
import '../../utils/json_utils.dart';
import 'simkl_ids.dart';
part 'simkl_all_items_entry.g.dart';
@JsonSerializable(createToJson: false)
class SimklAllItemsMedia {
final String? title;
@JsonKey(fromJson: flexibleInt)
final int? year;
final String? poster;
final String? fanart;
@JsonKey(fromJson: flexibleInt)
final int? runtime;
final String? overview;
final List<String>? genres;
final String? network;
final String? status;
final SimklIds ids;
const SimklAllItemsMedia({
this.title,
this.year,
this.poster,
this.fanart,
this.runtime,
this.overview,
this.genres,
this.network,
this.status,
required this.ids,
});
factory SimklAllItemsMedia.fromJson(Map<String, dynamic> json) => _$SimklAllItemsMediaFromJson(json);
}
@JsonSerializable(createToJson: false)
class SimklAllItemsEntry {
/// User-list status (`plantowatch`, `watching`, ...), not production state.
final String? status;
@JsonKey(name: 'added_to_watchlist_at')
final String? addedAt;
@JsonKey(name: 'user_rating', fromJson: flexibleDouble)
final double? userRating;
final SimklAllItemsMedia? show;
final SimklAllItemsMedia? movie;
@JsonKey(name: 'anime_type')
final String? animeType;
@JsonKey(name: 'total_episodes_count', fromJson: flexibleInt)
final int? totalEpisodes;
@JsonKey(name: 'not_aired_episodes_count', fromJson: flexibleInt)
final int? notAiredEpisodes;
const SimklAllItemsEntry({
this.status,
this.addedAt,
this.userRating,
this.show,
this.movie,
this.animeType,
this.totalEpisodes,
this.notAiredEpisodes,
});
SimklAllItemsMedia? get media => movie ?? show;
bool get isShow => show != null;
factory SimklAllItemsEntry.fromJson(Map<String, dynamic> json) => _$SimklAllItemsEntryFromJson(json);
}
class SimklAllItems {
final List<SimklAllItemsEntry> shows;
final List<SimklAllItemsEntry> movies;
final List<SimklAllItemsEntry> anime;
const SimklAllItems({this.shows = const [], this.movies = const [], this.anime = const []});
factory SimklAllItems.fromJson(Map<String, dynamic> json) =>
SimklAllItems(shows: _entries(json['shows']), movies: _entries(json['movies']), anime: _entries(json['anime']));
static List<SimklAllItemsEntry> _entries(Object? value) {
if (value is! List) return const [];
return [
for (final entry in value)
if (entry is Map<String, dynamic>) SimklAllItemsEntry.fromJson(entry),
];
}
}