Thursday, March 25, 2010

Download trailers from iTunes

I just don't want to visit http://trailers.apple.com every time I want to know about new movies, instead I would like to automagically have those files downloaded to a directory. I created a small script for this purpose.

First, visit the link above (just to learn your way around Apple's trailer site) select a movie and and choose a resolution. You usually have 3 HD options on a movies' trailer page: 480p, 720p and 1080p.
Right-click on the specific Resolution button and select Copy Location.

With the movies' URL copied and pasted, here's is an example for the movie "Wild Grass":

$ wget -U "QuickTime/7.6.2 (qtver=7.6.2;os=Windows NT 5.1Service Pack 3)" --referer=http://trailers.apple.com/movies/sony/wildgrass/ http://trailers.apple.com/movies/sony/wildgrass/wildgrass-tlr1_h720p.mov


No magic here except the User-Agent string. If you don't provide the proper user agent (means: lying that we are a Quicktime player), you won't get the movie file but only an .html file. The referrer is just here for the safety's sake, omitting it won't cause any problem.