使用 YouTube API 仅搜索 YouTube 上的音乐曲目 [英] Searching only for music tracks on YouTube with the YouTube API

查看:25
本文介绍了使用 YouTube API 仅搜索 YouTube 上的音乐曲目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 YouTube API (v3) 来启用仅搜索音乐曲目(不包括猫或藤蔓或任何其他非音乐视频).我在 API Explorer 和文档中查看了有关此问题的任何指示,但找不到任何有用的信息.

I'd like to use the YouTube API (v3) to enable searches of only music tracks (no cats or vines or any other non-musical video). I looked in the API Explorer and the docs for any pointers on that matter, but could not find any helpful information.

如何只搜索音乐?是否也可以按发行年份或音乐类型过滤搜索结果?

How can I search for music only? Is it also possible to filter the search results by year of release or music genre?

推荐答案

您能做的最好的事情是在您的查询中添加一个 videoCategoryId 参数到 YouTube 数据 API.这样可以确保只返回属于该类别的视频.

The best you can do is to add a videoCategoryId parameter in your query to the YouTube Data API. This ensures that only videos belonging to this category are returned.

正如另一个 Stackoverflow 问题中提到的,在美国和其他允许音乐的地方,音乐的 videoCategoryId 是 10.

As referenced in this other Stackoverflow question, the videoCategoryId for music in the US and elsewhere where music is allowed is 10.

来源:YouTube API V3: 在哪里可以找到每个videoCategoryId"的列表?

这篇关于使用 YouTube API 仅搜索 YouTube 上的音乐曲目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆