How to specify movie trailers using Youtube API

8.9k Views Asked by At

I'm trying to get just official movie trailers from the Youtube API, but it's difficult to get consistent results.

The closest I seem to get is using the following url:

http://gdata.youtube.com/feeds/api/videos/-/MOVIE-TITLE?max-results=1

It sometimes works well:

http://gdata.youtube.com/feeds/api/videos/-/The-A-Team?max-results=1

Other times, not as well, for example:

gdata.youtube.com/feeds/api/videos/-/The-Twilight-Saga:-Eclipse-[DVD]-The-Twilight-Saga:-Eclipse?max-results=1

I'm wondering if anyone knows of a good way to specify official movie trailers? I'd rather have no match than an irrelevant one ;)

2

There are 2 best solutions below

1
On BEST ANSWER

If you append "-trailer" to the MOVIE-TITLE you should get better results.

0
On

I have also found improvements using the Version 2 API and restricting result to only include High def ones.

eg http://gdata.youtube.com/feeds/api/videos?q=kung+fu+panda-trailer&start-index=1&max-results=1&v=2&alt=json&hd

full parameters available for V2 are here https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters#hdsp