I need a way of getting a completely random YouTube video. No restriction.
How can I do with with the YouTube API?
** edit * OK as requested here is what i tried so far:
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 - 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 - even checked the youtube app gallery http://youtube-gallery.appspot.com/ to see if anyone is doing it. and HOW.
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 for ideas.
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.
To quote the youtube API guy in first link:
As others have mentioned, we make any data dumps or the like available. All your interaction with YouTube needs to be done via the standard API.
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.
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.
Cheers, -Jeff Posnick, YouTube API Team as With regards to randomyoutubevideo.net, this is what the "About" page of that site has to say:
So how can we provide truly random links to YouTube videos? It turns out that the YouTube programming interface (API) provides additional functions that allow the discovery of videos that are much more random. Using a number of tricks, combined with a little manipulation of the space-time frabric, we have managed to create a process that yiields truly random links to YouTube videos.
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.
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.