def videoFromAssets()

in common/src/main/scala/com/gu/media/model/ClientAsset.scala [40:55]


  def videoFromAssets(assets: List[Asset]): (Long, VideoAsset) = {
    assets.headOption match {
      case Some(Asset(_, version, _, Platform.Url, _)) =>
        val sources = assets.collect {
          case Asset(_, _, id, _, Some(mimeType)) => VideoSource(id, mimeType)
        }

        (version, SelfHostedAsset(sources))

      case Some(Asset(_, version, id, Platform.Youtube, _)) =>
        (version, YouTubeAsset(id))

      case other =>
        throw new IllegalArgumentException(s"Unsupported platform ${other.map(_.platform.name)}")
    }
  }