通过 youtube_it Gem 查询 Youtube 的可嵌入视频
在查看 Google 的 YouTube api 文档( http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Retriving_and_searching_for_videos )我不确定这是否可能。
基本上我想以返回的视频只是可嵌入视频的方式查询 youtube。
目前我有这样的事情:
yt_client.videos_by(:query => "techno viking")
该搜索效果很好,但会返回所有匹配的视频,甚至是那些不允许嵌入的视频。
有什么想法吗?我希望让 YouTube 进行排序,而不是我用 ruby 过滤搜索结果。 :)
I cannot find this documented anywhere and after looking over Google's api docs for YouTube ( http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Retrieving_and_searching_for_videos ) I'm not sure if it's even possible.
Basically i would like to query youtube in a way that the videos returned are only embeddable vids.
Currently i have something like this:
yt_client.videos_by(:query => "techno viking")
That search works great but will return all matching videos, even the ones that do not allow embedding.
Any ideas? I'd love to have YouTube do the sorting instead of me filtering the search results with ruby. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这里用我上次评论的内容回答我自己的问题:
yt_client.videos_by(:query => "techno viking", :format => 5)
来自文档页面http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Retriving_and_searching_for_videos:
“开发者通常会在查询中添加 &format=5,以将结果限制为以下视频:可以嵌入到他们的网站上。”
Answering my own question here with content from my last comment:
yt_client.videos_by(:query => "techno viking", :format => 5)
From the doc page http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Retrieving_and_searching_for_videos:
"Developers commonly add &format=5 to their queries to restrict results to videos that can be embedded on their sites."
格式参数对我不起作用,但我发现一个“only_embeddable”选项可以解决问题:
The format param wasn't working for me, but I found an "only_embeddable" option which does the trick: