/// Utility class for parsing Plex API cache responses /// /// Provides consistent extraction of MediaContainer data across the codebase. class PlexCacheParser { PlexCacheParser._(); /// Extract the Metadata list from a cached response /// /// Returns null if MediaContainer or Metadata is not present static List? extractMetadataList(Map? cached) { if (cached == null) return null; return cached['MediaContainer']?['Metadata'] as List?; } /// Extract the first metadata item from a cached response /// /// Returns null if no metadata exists static Map? extractFirstMetadata(Map? cached) { final list = extractMetadataList(cached); if (list == null || list.isEmpty) return null; return list.first as Map; } /// Extract Chapter list from the first metadata item static List? extractChapters(Map? cached) { final metadata = extractFirstMetadata(cached); if (metadata == null) return null; return metadata['Chapter'] as List?; } }