本文整理汇总了PHP中Api::queueAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::queueAdd方法的具体用法?PHP Api::queueAdd怎么用?PHP Api::queueAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api::queueAdd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
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 {
// if we failed, we just mark it as failed, this will retry 5 min from now ...
$api->setTaskFailedUnlock($task["id"]);
示例2: 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)
示例3: list
}
list($source, $destination) = $adapterObject->filePathTranscode($media, $all_settings[$params["setting"]]);
if (!$source || !$destination) {
$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($source) || filesize($source) == 0) {
$api->log(LOG_CRIT, "Got task '" . $task["id"] . "' but file '" . $filename . "' not found or has zero size!!");
$api->setTaskFailedUnlock($task["id"]);
continue;
}
// We overwrite the destination file (or folder)
// 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 ...
$result = $ffmpeg->transcode($media, $source, $destination, $params["setting"], $adapterObject);
if ($result) {
$api->transcodeUpdate($transcode["id"], array("status" => TRANSCODE_PROCESSED, "metadata" => serialize($result)));
// Queue the task to tell the client that we have the metadata
$api->queueAdd(TASK_SEND_TRANSCODE, $task["mediaid"], API_RETRY, array("transcode" => $params["transcode"]), $media["adapter"]);
// ok, transfer finished, let's mark it done
$api->setTaskProcessedUnlock($task["id"]);
// Queue the task to tell the client that we have the metadata
$api->log(LOG_DEBUG, "Successully processed task '" . $task["id"] . "', transcode for media '" . $task["mediaid"] . "' for setting '" . $params["setting"] . "'");
} else {
// if we failed, we just mark it as failed, this will retry 5 min from now ...
$api->setTaskFailedUnlock($task["id"]);
$api->log(LOG_DEBUG, "Ffmpeg call failed when processing task '" . $task["id"] . "', transcode for media '" . $task["mediaid"] . "' for setting '" . $params["setting"] . "'");
}
}
// infinite loop...