AlternateEnclosure.parse constructor

AlternateEnclosure.parse(
  1. XmlElement element
)

Factory method to parse an XmlElement and create an AlternateEnclosure object from it.

The element is an XML element containing the alternate enclosure information.

Returns the parsed AlternateEnclosure object.

Implementation

factory AlternateEnclosure.parse(XmlElement element) {
  final lengthStr = element.getAttribute('length');
  final bitrateStr = element.getAttribute('bitrate');
  final heightStr = element.getAttribute('height');
  return AlternateEnclosure(
    type: element.getAttribute('type'),
    length: lengthStr == null ? null : int.tryParse(lengthStr),
    bitrate: bitrateStr == null ? null : double.tryParse(bitrateStr),
    height: heightStr == null ? null : int.tryParse(heightStr),
    lang: element.getAttribute('lang'),
    title: element.getAttribute('title'),
    rel: element.getAttribute('rel'),
    codecs: element.getAttribute('codecs'),
    default_: element.getAttribute('default'),
    sources: element
        .findElements('podcast:source')
        .map((e) => Source.parse(e))
        .toList(),
    integrities: element
        .findElements('podcast:integrity')
        .map((e) => Integrity.parse(e))
        .toList(),
  );
}