in common/src/main/scala/com/gu/media/youtube/YouTubeVideos.scala [129:149]
def updateThumbnail(id: String, thumbnail: InputStreamContent): Either[VideoUpdateError, String] = {
getVideo(id, List("snippet")) match {
case Some(video) => {
findMistakesInDev(video) match {
case None => {
val set = client.thumbnails().set(id, thumbnail).setOnBehalfOfContentOwner(contentOwner)
// If we want some way of monitoring and resuming thumbnail uploads then we can change this to be `false`
set.getMediaHttpUploader.setDirectUploadEnabled(true)
YoutubeRequestLogger.logRequest(YoutubeApiType.DataApi, YoutubeRequestType.UpdateVideoThumbnail)
set.execute()
Right("Updated video")
}
case Some(error) => Left(VideoUpdateError("Could not update video thumbnail", Some(error)))
}
}
case _ => Left(VideoUpdateError("Could not update thumbnail because could not find video"))
}
}