Files
plezy/lib/models/trakt/trakt_catalog_media.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

117 lines
3.2 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:json_annotation/json_annotation.dart';
import 'trakt_ids.dart';
import 'trakt_images.dart';
part 'trakt_catalog_media.g.dart';
/// A show's recurring broadcast slot from Trakt's `airs` object.
class TraktAirs {
final String? day;
final String? time;
final String? timezone;
const TraktAirs({this.day, this.time, this.timezone});
factory TraktAirs.fromJson(Map<String, dynamic> json) =>
TraktAirs(day: json['day'] as String?, time: json['time'] as String?, timezone: json['timezone'] as String?);
}
/// Recommendation provenance attached to a personalised recommendation row.
class TraktRecommendationUser {
final String? username;
final String? name;
final String? notes;
const TraktRecommendationUser({this.username, this.name, this.notes});
factory TraktRecommendationUser.fromJson(Map<String, dynamic> json) => TraktRecommendationUser(
username: json['username'] as String?,
name: json['name'] as String?,
notes: json['notes'] as String?,
);
}
/// A movie or show summary from Trakt's catalog endpoints (`extended=full`).
///
/// Trakt uses the same field names for movie and show objects. Whether an
/// instance is a movie or a show is known from the endpoint or wrapper key it
/// was parsed from (see [TraktCatalogEntry]).
@JsonSerializable(createToJson: false)
class TraktCatalogMedia {
final String? title;
final int? year;
final TraktIds ids;
final String? overview;
final String? tagline;
@JsonKey(name: 'original_title')
final String? originalTitle;
final String? released;
@JsonKey(name: 'first_aired')
final String? firstAired;
/// Runtime in minutes.
final int? runtime;
/// Trakt community rating, 010.
final double? rating;
final int? votes;
final List<String>? genres;
final String? certification;
final String? trailer;
@JsonKey(name: 'comment_count')
final int? commentCount;
final String? language;
final List<String>? languages;
@JsonKey(name: 'available_translations')
final List<String>? availableTranslations;
final String? country;
@JsonKey(name: 'favorited_by')
final List<TraktRecommendationUser>? favoritedBy;
@JsonKey(name: 'recommended_by')
final List<TraktRecommendationUser>? recommendedBy;
/// Shows: `returning series` / `continuing` / `in production` / `planned` /
/// `upcoming` / `pilot` / `canceled` / `ended`. Movies: `released` /
/// `in production` / `post production` / `planned` / `rumored` / `canceled`.
final String? status;
/// Shows only.
final String? network;
@JsonKey(name: 'aired_episodes')
final int? airedEpisodes;
final TraktAirs? airs;
final TraktImages? images;
const TraktCatalogMedia({
this.title,
this.year,
required this.ids,
this.overview,
this.tagline,
this.originalTitle,
this.released,
this.firstAired,
this.runtime,
this.rating,
this.votes,
this.genres,
this.certification,
this.trailer,
this.commentCount,
this.language,
this.languages,
this.availableTranslations,
this.country,
this.favoritedBy,
this.recommendedBy,
this.status,
this.network,
this.airedEpisodes,
this.airs,
this.images,
});
factory TraktCatalogMedia.fromJson(Map<String, dynamic> json) => _$TraktCatalogMediaFromJson(json);
}