<commit_before>package actors

import akka.actor.Actor
import akka.event.Logging
import helper._
import models.dto.{VideoUploadFailure, VideoDownloadSuccess, VideoUploadSuccess, ShowMetaData}

/**
 * Upload video to storage backend
 *
 * @author <NAME>
 */
class VideoUploadActor(backend: StorageBackend) extends Actor {
  val log = Logging(context.system, this)

  def receive = {
    case meta: ShowMetaData => try {

      log.info("uploading file: " + meta.showTitle)

      val url = backend.store(meta)

      // delete local video file
      meta.localVideoFile.map(_.delete)
      meta.localVideoFile = None

      meta.showSourceTitle = meta.showTitle
      meta.publicVideoUrl = Some(url)

      if (meta.vimeo.isDefined && meta.vimeo.get && !meta.vimeoDone.isDefined) {
        meta.vimeoDone = Some(true)
        sender() ! VideoDownloadSuccess(meta)
      }

      sender() ! VideoUploadSuccess(meta)

    } catch {
      case e: Exception =>
        log.error("upload of '%s' failed: %s".format(meta.localVideoFile.getOrElse("???"), e.getMessage))<commit_msg>call .isEmpty for improved code readability<commit_after>package actors

import akka.actor.Actor
import akka.event.Logging
import helper._
import models.dto.{VideoUploadFailure, VideoDownloadSuccess, VideoUploadSuccess, ShowMetaData}

/**
 * Upload video to storage backend
 *
 * @author <NAME>
 */
class VideoUploadActor(backend: StorageBackend) extends Actor {
  val log = Logging(context.system, this)

  def receive = {
    case meta: ShowMetaData => try {

      log.info("uploading file: " + meta.showTitle)

      val url = backend.store(meta)

      // delete local video file
      meta.localVideoFile.map(_.delete)
      meta.localVideoFile = None

      meta.showSourceTitle = meta.showTitle
      meta.publicVideoUrl = Some(url)

      if (meta.vimeo.isDefined && meta.vimeo.get && meta.vimeoDone.isEmpty) {
        meta.vimeoDone = Some(true)
        sender() ! VideoDownloadSuccess(meta)
      }

      sender() ! VideoUploadSuccess(meta)

    } catch {
      case e: Exception =>
        log.error("upload of '%s' failed: %s".format(meta.localVideoFile.getOrElse("???"), e.getMessage))
{'fraction_non_alphanumeric': 0.11688909341923608, 'fraction_numerical': 0.0, 'mean_word_length': 3.3049504950495048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2115515', 'n_tokens_mistral': 669, 'n_tokens_neox': 656, 'n_words': 148}