Media.parse constructor

Media.parse(
  1. XmlElement element,
  2. bool parseHtml
)

Parse constructor for the Media class, used when 'parsing' a feed

Implementation

factory Media.parse(XmlElement element, bool parseHtml) => Media(
      group: element.findElements('media:group').map(Group.parse).firstOrNull,
      contents:
          element.findElements('media:content').map(Content.parse).toList(),
      credits:
          element.findElements('media:credit').map(Credit.parse).toList(),
      category: element
          .findElements('media:category')
          .map(Category.parse)
          .firstOrNull,
      rating:
          element.findElements('media:rating').map(Rating.parse).firstOrNull,
      title: findElements(element, 'media:title')
          ?.map((title) => Title.parse(title, parseHtml))
          .firstOrNull,
      description: element
          .findElements('media:description')
          .map(Description.parse)
          .firstOrNull,
      keywords: element.findElements('media:keywords').firstOrNull?.innerText,
      thumbnails: element
          .findElements('media:thumbnail')
          .map(Thumbnail.parse)
          .toList(),
      hash: element.findElements('media:hash').map(Hash.parse).firstOrNull,
      player:
          element.findElements('media:player').map(Player.parse).firstOrNull,
      copyright: element
          .findElements('media:copyright')
          .map(Copyright.parse)
          .firstOrNull,
      text: element
          .findElements('media:text')
          .map((text) => Text.parse(text, parseHtml))
          .firstOrNull,
      restriction: element
          .findElements('media:restriction')
          .map(Restriction.parse)
          .firstOrNull,
      community: element
          .findElements('media:community')
          .map(Community.parse)
          .firstOrNull,
      comments: element
              .findElements('media:comments')
              .firstOrNull
              ?.findElements('media:comment')
              .map((e) => e.parseText(parseHtml))
              .toList() ??
          [],
      embed: element.findElements('media:embed').map(Embed.parse).firstOrNull,
      responses: element
              .findElements('media:responses')
              .firstOrNull
              ?.findElements('media:response')
              .map((e) => e.parseText(parseHtml))
              .toList() ??
          [],
      backLinks: element
              .findElements('media:backLinks')
              .firstOrNull
              ?.findElements('media:backLink')
              .map((e) => e.innerText)
              .toList() ??
          [],
      status:
          element.findElements('media:status').map(Status.parse).firstOrNull,
      prices: element.findElements('media:price').map(Price.parse).toList(),
      license: element
          .findElements('media:license')
          .map(License.parse)
          .firstOrNull,
      peerLink: element
          .findElements('media:peerLink')
          .map(PeerLink.parse)
          .firstOrNull,
      rights:
          element.findElements('media:rights').map(Rights.parse).firstOrNull,
      scenes: element
              .findElements('media:scenes')
              .firstOrNull
              ?.findElements('media:scene')
              .map((item) => Scene.parse(item, parseHtml))
              .toList() ??
          [],
    );