/** * Insert or update video info record from given file * @param LocalFile $file * @param bool $reupload * @return bool * @throws Exception */ public static function upsertVideoInfo(\LocalFile $file, $reupload) { if (!$file->isDataLoaded()) { $errMessage = 'Video file not loaded'; WikiaLogger::instance()->error($errMessage); throw new \Exception($errMessage); } $videoInfoHelper = new VideoInfoHelper(); $videoData = $videoInfoHelper->getVideoDataFromFile($file); if (empty($videoData)) { return true; } $videoInfo = new VideoInfo($videoData); // Force a reupload if the foreign video with the same title exists $reupload = $reupload || $videoInfoHelper->videoExists($file->getTitle(), true); if ($reupload) { $videoInfo->reuploadVideo(); } else { $videoInfo->addVideo(); } return true; }