YouTube API V3:我在哪里可以找到每个'videoCategoryId'的列表?

问题描述 投票:16回答:3

我正在使用Youtube API V3,但无法找到有关如何按类别过滤的文档:

这是我的代码:

$results = $youtube->search->listSearch('id,snippet', array(
    'q' =>                  $_GET['q'],
    'maxResults' =>         20,
    'type' =>               'video'
    'videoCategoryId' =>    'what-do-i-put-here?',
));

我一直在阅读他们的文档一个小时,似乎找不到任何关于如何找出各类别ID的参考。在我的情况下,我正在寻找音乐的videoCategoryId ....

php youtube youtube-api google-api
3个回答
29
投票

视频类别是特定于区域的 - 这就是类别列表服务需要类别ID或区域,但不需要两者的原因。这个终点:

https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&regionCode= {双字符区域}&关键= {} YOUR_API_KEY

将返回给定区域的所有类别及其ID。正如Ikai Lan在评论中指出的那样,美国的音乐ID是“10”,事实上,在允许这一类别的所有地区;但可能有些地区不允许,或者某些地区根本不受支持。


29
投票

https://gist.github.com/dgp/1b24bf2961521bd75d6c使用Dinesh Gowtham Prathap的YouTube API v3视频类别ID列表

1 - Film & Animation 
2 - Autos & Vehicles
10 - Music
15 - Pets & Animals
17 - Sports
18 - Short Movies
19 - Travel & Events
20 - Gaming
21 - Videoblogging
22 - People & Blogs
23 - Comedy
24 - Entertainment
25 - News & Politics
26 - Howto & Style
27 - Education
28 - Science & Technology
29 - Nonprofits & Activism
30 - Movies
31 - Anime/Animation
32 - Action/Adventure
33 - Classics
34 - Comedy
35 - Documentary
36 - Drama
37 - Family
38 - Foreign
39 - Horror
40 - Sci-Fi/Fantasy
41 - Thriller
42 - Shorts
43 - Shows
44 - Trailers

12
投票

在底部:https://developers.google.com/youtube/v3/docs/videoCategories/list是'现在尝试'部分。

将“代码段”放在标有“部分”的字段中,然后添加区域代码,例如标有“regionCode”的字段中的GB或US。

这将带回您所选地区的完整类别列表。

© www.soinside.com 2019 - 2024. All rights reserved.