gpt4 book ai didi

php - YouTube API v3 – 检查上传的视频是否已完成处理

转载 作者:行者123 更新时间:2023-12-03 05:18:16 25 4
gpt4 key购买 nike

我正在使用 YouTube API v3Google PHP client我成功地上传了视频并检索了详细信息。但是,我想知道 YouTube 何时处理完上传的视频并准备好使用

// The code is largely stripped down
$client = new Google_Client();
$youtube = new Google_Service_YouTube($client);
$listResponse = $youtube->videos->listVideos("snippet", array('id' => 'xyz'));

$listResponse是一个数组,只包含一个 Google_Service_YouTube_Video 类型的视频对象(因为只请求了一个视频 ID) ,但似乎没有任何属性包含有关视频处理状态的有用信息。

这些是我认为 $listResponse[0] 中最有趣的属性

[processingDetailsType:protected] => Google_Service_YouTube_VideoProcessingDetails (string)
[processingDetailsDataType:protected] => (empty)
[processed:protected] => Array ([snippet] => 1)

特别有趣的是 processingDetailsType这只是一个代表类名的字符串,processed在视频被 YouTube 成功处理后不会改变。

$listResponse[0]['snippet']保留视频详细信息,但仍然无法确定它是否已被处理。我监控了publishedAt属性(property),希望它会在处理视频时发生变化,但它保持不变。同样,processed看起来很有趣的属性总是空的。

[snippet] => Google_Service_YouTube_VideoSnippet Object
(
[collection_key:protected] => tags
[internal_gapi_mappings:protected] => Array
(
)

[categoryId] => 22
[channelId] => XXXYYYZZZ
[channelTitle] => Some Channel Title
[defaultLanguage] =>
[description] =>
[liveBroadcastContent] => none
[localizedType:protected] => Google_Service_YouTube_VideoLocalization
[localizedDataType:protected] =>
[publishedAt] => 2015-04-15T14:54:47.000Z
[tags] =>
[thumbnailsType:protected] => Google_Service_YouTube_ThumbnailDetails
[thumbnailsDataType:protected] =>
[title] => Some Video Title
[modelData:protected] => Array
(
[thumbnails] => Array
(
[default] => Array
(
[url] => https://i.ytimg.com/vi/xyz/default.jpg
[width] => 120
[height] => 90
)

[medium] => Array
(
[url] => https://i.ytimg.com/vi/xyz/mqdefault.jpg
[width] => 320
[height] => 180
)

[high] => Array
(
[url] => https://i.ytimg.com/vi/xyz/hqdefault.jpg
[width] => 480
[height] => 360
)

[standard] => Array
(
[url] => https://i.ytimg.com/vi/xyz/sddefault.jpg
[width] => 640
[height] => 480
)
)

[localized] => Array
(
[title] => Some Video Title
[description] =>
)
)

[processed:protected] => Array
(
)
)

最佳答案

根据 Google API:

[T] snippet 属性包含 channelId、title、description、tags 和 categoryId 属性,没有任何关于处理数据的内容。

相反,如果您使用“processingDetails”,您将获得:“processingStatus”、“processingProgress”、processingProgress.partsTotal 等,因此最好使用

$listResponse = $youtube->videos->listVideos("processingDetails", array('id' => 'xyz'));

您将获得该数据。在此链接中,您可以看到说明:https://developers.google.com/YouTube/v3/docs/videos/list

关于php - YouTube API v3 – 检查上传的视频是否已完成处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29671027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com