Beispiel #1
0
 protected function getVideoDuplicate($provider, $videoId)
 {
     $duplicates = WikiaFileHelper::getDuplicateVideos($provider, $videoId);
     if (count($duplicates) > 0) {
         return wfFindFile($duplicates[0]['video_title']);
     }
     return null;
 }
/**
 * Compare new metadata with the one from file
 * @param array $video
 * @param string $msg
 * @param array $newMeta
 * @return boolean
 */
function compareMetadataFile($video, $msg, $newMeta)
{
    // find duplicate videos from wiki
    $duplicates = WikiaFileHelper::getDuplicateVideos('ooyala', $video['embed_code'], 2);
    if (empty($duplicates)) {
        echo "\n\tNOTE: {$msg} ... File not found in DB\n";
        return false;
    } else {
        if (count($duplicates) > 1) {
            $dupes = array();
            foreach ($duplicates as $dup) {
                $dupes[] = $dup['video_title'];
            }
            echo "\n\tNOTE: {$msg} ... (Found " . count($duplicates) . " duplicates: " . implode(',', $dupes) . ")\n";
            return false;
        }
    }
    // get file object
    $title = $duplicates[0]['video_title'];
    $file = WikiaFileHelper::getVideoFileFromTitle($title);
    if (empty($file)) {
        echo "\n\tNOTE: {$msg} ... File not found\n";
        return false;
    }
    $fileMeta = unserialize($file->getMetadata());
    foreach ($fileMeta as $key => &$value) {
        if ($key == 'ageRequired') {
            $fileMeta['age_required'] = $value;
            unset($fileMeta['ageRequired']);
        } else {
            if ($key == 'language') {
                $fileMeta['lang'] = $value;
                unset($fileMeta['language']);
            } else {
                if ($key == 'published') {
                    $value = date('Y-m-d', $value);
                } else {
                    $keyLc = strtolower($key);
                    if ($key != $keyLc) {
                        $fileMeta[$keyLc] = $value;
                        unset($fileMeta[$key]);
                    }
                }
            }
        }
    }
    echo "\n\tCompare to File:\n";
    compareMetadata($fileMeta, $newMeta);
    return true;
}