当前位置: 首页>>代码示例>>PHP>>正文


PHP Api::mediaUpdate方法代码示例

本文整理汇总了PHP中Api::mediaUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::mediaUpdate方法的具体用法?PHP Api::mediaUpdate怎么用?PHP Api::mediaUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Api的用法示例。


在下文中一共展示了Api::mediaUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fopen

    } else {
        $sizebefore = 0;
        $f = fopen($filename, "wb");
    }
    if (!$f) {
        $api->log(LOG_CRIT, "cannot write to " . $filename . " for task '" . $task["id"] . "'");
        $api->setTaskFailedUnlock($task["id"]);
        continue;
    }
    curl_setopt($curl, CURLOPT_FILE, $f);
    $res = curl_exec($curl);
    $info = curl_getinfo($curl);
    fclose($f);
    if ($res) {
        // and mark the media as "locally downloaded"
        $api->mediaUpdate($task["mediaid"], array("status" => MEDIA_LOCAL_AVAILABLE));
        // and ask for its metadata if requested to:
        if ($task["params"]["dometadata"]) {
            $api->queueAdd(TASK_DO_METADATA, $task["mediaid"], METADATA_RETRY);
        }
        // ok, transfer finished, let's mark it done
        $api->setTaskProcessedUnlock($task["id"]);
        $api->log(LOG_INFO, "Download task " . $task["id"] . " finished for media " . $task["mediaid"] . "");
    } else {
        // if we failed, we just mark it as failed, this will retry 5 min from now ...
        $api->setTaskFailedUnlock($task["id"]);
        print_r($info);
        $api->log(LOG_WARNING, "Download task " . $task["id"] . " failed or unfinished for media " . $task["mediaid"] . "");
    }
}
// while (true)
开发者ID:ninetian,项目名称:omk-server,代码行数:31,代码来源:downloader.daemon.php

示例2: array

     $api->log(LOG_CRIT, "Got task '" . $task["id"] . "' but media '" . $task["mediaid"] . "' didn't allow to find the file using adapter '" . $task["adapter"] . "' !!");
     $api->setTaskFailedUnlock($task["id"]);
     continue;
 }
 if (!file_exists($filename) || filesize($filename) == 0) {
     $api->log(LOG_CRIT, "Got task '" . $task["id"] . "' but file '" . $filename . "' not found or has zero size!!");
     $api->setTaskFailedUnlock($task["id"]);
     continue;
 }
 // ok, now we use ffmpeg to get the metadata of the downloaded media
 // depending on FFMPEG / AVCONV version, we use one parser or the other ...
 $metadata = $ffmpeg->getFfmpegMetadata($filename);
 if ($metadata) {
     if (count($metadata["tracks"]) == 0) {
         // Store the metadata in the media object:
         $api->mediaUpdate($task["mediaid"], array("status" => MEDIA_METADATA_FAILED, "metadata" => serialize($metadata)));
         // Queue the task to tell the client that we had an error getting the metadata
         $api->queueAdd(TASK_SEND_METADATAERROR, $task["mediaid"], API_RETRY);
         // ok, transfer finished, let's mark it done
         $api->setTaskProcessedUnlock($task["id"]);
         $api->log(LOG_DEBUG, "Failed (properly) while processing task '" . $task["id"] . "', metadata for media '" . $task["mediaid"] . "'");
     } else {
         // Store the metadata in the media object:
         $api->mediaUpdate($task["mediaid"], array("status" => MEDIA_METADATA_OK, "metadata" => serialize($metadata)));
         // Queue the task to tell the client that we have the metadata
         $api->queueAdd(TASK_SEND_METADATA, $task["mediaid"], API_RETRY);
         // ok, transfer finished, let's mark it done
         $api->setTaskProcessedUnlock($task["id"]);
         $api->log(LOG_DEBUG, "Successully processed task '" . $task["id"] . "', metadata for media '" . $task["mediaid"] . "'");
     }
 } else {
开发者ID:ninetian,项目名称:omk-server,代码行数:31,代码来源:metadata.daemon.php


注:本文中的Api::mediaUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。