Itunes.parse constructor
Itunes.parse(
- XmlElement element
Parse constructor for the Itunes class, used when 'parsing' a feed
Implementation
factory Itunes.parse(XmlElement element) {
final episodeStr =
element.findElements('itunes:episode').firstOrNull?.text ?? '';
final seasonStr =
element.findElements('itunes:season').firstOrNull?.text ?? '';
final durationStr =
element.findElements('itunes:duration').firstOrNull?.text ?? '';
return Itunes(
author: element.findElements('itunes:author').firstOrNull?.text,
summary: element.findElements('itunes:summary').firstOrNull?.text,
explicit: parseBoolLiteral(element, 'itunes:explicit'),
title: element.findElements('itunes:title').firstOrNull?.text,
subtitle: element.findElements('itunes:subtitle').firstOrNull?.text,
owner: element
.findElements('itunes:owner')
.map(ItunesOwner.parse)
.firstOrNull,
keywords: element
.findElements('itunes:keywords')
.firstOrNull
?.text
.split(',')
.map((keyword) => keyword.trim())
.toList() ??
[],
image: element
.findElements('itunes:image')
.map(ItunesImage.parse)
.firstOrNull,
categories: element
.findElements('itunes:category')
.map(ItunesCategory.parse)
.toList(),
type: element.findElements('itunes:type').map(newItunesType).firstOrNull,
newFeedUrl: element.findElements('itunes:new-feed-url').firstOrNull?.text,
block: parseBoolLiteral(element, 'itunes:block'),
complete: parseBoolLiteral(element, 'itunes:complete'),
episode: episodeStr.isNotEmpty ? int.tryParse(episodeStr) : null,
season: seasonStr.isNotEmpty ? int.tryParse(seasonStr) : null,
duration: durationStr.isNotEmpty ? _parseDuration(durationStr) : null,
episodeType: element
.findElements('itunes:episodeType')
.map(newItunesEpisodeType)
.firstOrNull,
);
}