问题描述
我需要得到一个完全随机的YouTube视频的一种方式。没有限制。
I need a way of getting a completely random YouTube video. No restriction.
如何才能做到与YouTube的API?
How can I do with with the YouTube API?
**编辑*确定的要求这里是我试过到目前为止:
** edit * OK as requested here is what i tried so far:
1 - 通过API和实例,在YouTube的开发站点去。 http://www.youtube.com/dev/ 没有运气找到正确的API或做它存在的方式。
1 - went through the api and examples at youtube dev site. http://www.youtube.com/dev/ no luck finding the correct api or a way of doing it there.
2 - 谷歌搜索,当然;)有 http://randomyoutubevideo.net/ 但他们只提供了一个API,从他们使用的我和YouTube之间。 <这给了我希望,它实际上是可以做到这一点。
2 - google search of course ;) got http://randomyoutubevideo.net/ but they only offer an api from THEM to use in between me and youtube. < this gives me hope that it IS actually possible to do this.
3 - 即使检查了YouTube应用程序库 http://youtube-gallery.appspot.com/ 如果有人看是做什么的。以及如何。
3 - even checked the youtube app gallery http://youtube-gallery.appspot.com/ to see if anyone is doing it. and HOW.
我也会做的就是要求YouTube的讨论页面上。也许有人可以有帮助。
what i will also do is ask on the youtube discussion pages. perhaps someone there can help.
推荐答案
目前看来是没有办法做到这一点,但是有办法接近你要找的内容。请参见这里和此处的想法。
There appears to be no way to do this, however there are ways to approximate what you're looking for. See here and here for ideas.
从这些页面的基本思路是:使用最新的上传饲料(如果你不关心的东西时,被上传),或简单地得到所有YouTube视频转储,并随机选择从这些网址。
The basic ideas from those pages are to use the most recent uploads feed (if you don't care about when something was uploaded) or simply get a dump of ALL youtube videos and randomly select a URL from those.
要引用的第一个环节在YouTube API的家伙:
To quote the youtube API guy in first link:
正如其他人所提到的,我们做任何的数据转储或类似 可用。与YouTube你所有的交互必须通过完成 标准API。
我不能说我有足够的统计后台 建议你怎么能检索录像的真正随机抽样。我愿意 认为将它用在试图产生11个字符 YouTube的视频IDS可能是错误的做法,不过,也有 太多不存在的视频的标识,你会颠簸起来反对, 我不认为API的最佳方式是让请求将 返回的时间的HTTP 404响应X%。
I can't say that I have enough of a background in statistics to suggest how you could retrieve a truly random sample of videos. I do think that going about it by attempting to generate 11 character YouTube video ids is probably the wrong approach, though—there are just too many non-existent video ids that you'll bump up against, and I don't think the best use of the API is to make requests that will return HTTP 404 responses X% of the time.
您可能有更好的运气只是使用API来搜索词或 被拾取在无规和采取的一个采样的短语 结果。如果你这样做,你应该想想用什么价值 在排序依据= URL参数。默认的排序是相关性,这 会导致结果的最前面是那些我们的算法认为 最相关的搜索词。这可能会扭曲你的 结果,如果你总是抢在第一项等。你也可以 为了通过发布,这将给你一个反向时间进 视频。
You might have better luck just using the API to search for words or phrases that are picked at "random" and taking a sampling of the results. If you do that, you should think about what value to use for the orderby= URL parameter. The default ordering is "relevance", which will lead to the top results being the ones that our algorithms think are the most relevant to your search terms. This might skew your results if you always grab the first entry or the like. You could also order by "published" which will give you a reverse-chronological feed of videos.
干杯, -Jeff Posnick,YouTube的API小组
Cheers, -Jeff Posnick, YouTube API Team
至于randomyoutubevideo.net,这是该网站的关于页面有说:
With regards to randomyoutubevideo.net, this is what the "About" page of that site has to say:
那么,如何才能提供真正的随机链接到YouTube的视频?事实证明 指出,在YouTube编程接口(API)提供了附加的 功能,允许视频的发现,即是更 随机。利用多种技巧,再加上一点点操作 时空frabric,我们已经成功地创造出一个过程, yiields真正的随机链接到YouTube的视频。
此页面上的随机的YouTube功能,目前使用的一个子集 数据库。随着时间的推移,我们将扩大该数据库,并根据 需求,可能会使它提供免费的通过API。
The random YouTube function on this page currently uses a subset of the database. Over time we will expand this database and, depending on demand, may make it available free of charge via an API.
我明白这意味着他们已经被拔视频大名单的API,使他们的数据库从他们随机选择。
I understand this to mean that they have been pulling large lists of videos from the API and making a DB of them from which they randomly select.
这篇关于我如何获得一个随机的YouTube视频与YouTube的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!