开发者

Get youtube video feed by tags with space in tags

To get the feed of a certain uploader with a certain tag I use the following api url:

http://gdata.youtube.com/feeds/api/users/UPLOADER/uploads/-/TAG

if I wanted to search i.e. for the feed with tags foo and bar, 开发者_如何转开发I would use the following:

http://gdata.youtube.com/feeds/api/users/UPLOADER/uploads/-/foo/bar

BUT since youtube lets you specify tags with space, i.e. "foo bar", I want to search exactly for this tag. So when I use the first URL in combination with urlencode in PHP it won't return anything.

In the browser, the URL will change to .../uploads/-/foo%20bar, but also no results.

When I use uploads/-/foo/bar, the problem is that it returns videos having the tags 'foo' and 'bar' (wrong), or only 'foo bar' (right).

I also tried to replace the space with /, +, and -. Using the keywords.cat scheme in the URL will also return the same results.

Is there anything I missed, or is it generally not possible?


seems there is a bug in the youtube api which is not fixed yet. see http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/dc195bd6ad6a1fa4/2d9cf0e15ce7de50


As mentioned there is a YouTube bug, but you can use %2B (+) instead of a space to work around it.

So using your example:

http://gdata.youtube.com/feeds/api/users/UPLOADER/uploads/-/foo%2Bbar

I would have added this as a comment, but I lack the rep.


http://gdata.youtube.com/feeds/api/users/UPLOADER/uploads/-/{http%3A%2F%2Fgdata.youtube.com%2Fschemas%2F2007%2Fkeywords.cat}foo+bar

Try it with the keywords.cat specified before your tags.


I ran into the same problem and was able to get it to work by using the https://gdata.youtube.com/feeds/api/videos?q= format.
i.e. https://gdata.youtube.com/feeds/api/videos?q=+Team%20Fortress%202
And you can check this by changing the + to a -:
https://gdata.youtube.com/feeds/api/videos?q=-Team%20Fortress%202

The downside to this is that the q parameter will query all metadata of the video, so adjust accordingly.

hth Greg

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜