2017-08-08 85 views
1

我正在使用google-api-php-client搜索YouTube視頻,我想過濾結果以僅返回帶有字幕(cc)的視頻。Youtube列表搜索與cc篩選器?

可能嗎?如果是,我應該如何修改查詢?

$searchResponse = $youtube->search->listSearch('id,snippet', array(
    'q' => $_GET['q'], 
    'maxResults' => $_GET['maxResults'], 
)); 

謝謝。

+1

https://developers.google.com/youtube/v3/docs/search/list看到'videoCaption'? – Scuzzy

+0

謝謝謝謝。這正是我需要的。我添加了'videoCaption'=>'closedCaption',它的工作原理! – Henry

+0

然後,我會將我的評論移至答案中 – Scuzzy

回答

2

https://developers.google.com/youtube/v3/docs/search/list

的API文檔提到一個videoCaption字符串參數

的videoCaption參數指示API是否應該過濾基於他們是否有字幕的視頻搜索結果。如果您爲此參數指定值,則還必須將類型參數的值設置爲視頻。

$searchResponse = $youtube->search->listSearch('id,snippet', array(
    'q' => $_GET['q'], 
    'maxResults' => $_GET['maxResults'], 
    'videoCaption' => 'closedCaption', 
    'type' => 'video' 
));