RssItemItunes.parse constructor

RssItemItunes.parse(
  1. XmlElement element
)

Implementation

factory RssItemItunes.parse(XmlElement element) {
  final episodeStr = findElementOrNull(element, 'itunes:episode')?.text?.trim();
  final seasonStr = findElementOrNull(element, 'itunes:season')?.text?.trim();
  final durationStr = findElementOrNull(element, 'itunes:duration')?.text?.trim();

  return RssItemItunes(
    title: findElementOrNull(element, 'itunes:title')?.text?.trim(),
    episode: episodeStr == null ? null : int.tryParse(episodeStr),
    season: seasonStr == null ? null : int.tryParse(seasonStr),
    duration: durationStr == null ? null : parseDuration(durationStr),
    episodeType: newRssItunesEpisodeType(
        findElementOrNull(element, 'itunes:episodeType')),
    author: findElementOrNull(element, 'itunes:author')?.text?.trim(),
    summary: findElementOrNull(element, 'itunes:summary')?.text?.trim(),
    explicit: parseBoolLiteral(element, 'itunes:explicit'),
    subtitle: findElementOrNull(element, 'itunes:subtitle')?.text?.trim(),
    keywords: findElementOrNull(element, 'itunes:keywords')
            ?.text
            ?.split(',')
            ?.map((keyword) => keyword.trim())
            ?.toList() ??
        const <String>[],
    image: RssItunesImage.parse(findElementOrNull(element, 'itunes:image')),
    category: RssItunesCategory.parse(
        findElementOrNull(element, 'itunes:category')),
    block: parseBoolLiteral(element, 'itunes:block'),
  );
}