Querying Youtube for Embeddable Videos via the youtube_it Gem
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 que开发者_JS百科ry 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. :)
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."
The format param wasn't working for me, but I found an "only_embeddable" option which does the trick:
yt_client.videos_by(query: "techno viking", only_embeddable: true)
精彩评论