How to download HD trailers from Apple

The Apple website contains a significant amount of movie trailers. This site includes all the trailers of films which are reasonably well-known. It also provides, for most of them, trailers in HD (High-Definition) format which have a small protection to prevent the download of its content. Hence, I’ve created a script which downloads the trailers in High-Definition.

This kind of protection is basic: there’s a link-file which the user can open through QuickTime, for example, and that file has the name of the real video file. In fact, that video file has a small difference, it has a character add-on.

Thus, after a thorough analysis, I found out the small differences in each file and I’ve created this script. I’m going to publish two versions in this article: in the first one you can choose the HD quality: 480p or 720p or 1020p; while in the second one you can download in 720p quality. Most PCs have a resolution of approximately 720p (opportunity to say that if you want it with another quality you may ask).

So, the functioning of the script is simple: you run it and then it will ask you for the link of the film (you can put the direct link of the film, or the link to the page in HD of the film). After that, it will ask you the quality (the 720p version doesn’t have this option for the script), and it will immediately begin the download. In the end, if the file already existed it will indicate error. If you have successfully managed to copy the trailer, a message indicating success will be displayed. Note that all trailers which are available for that particular film are copied, in the chosen quality.

Aspects to be developed
Since the version is still in development, some small basic options are missing. Note:

1. It only tells you that the trailer already exists at the end of the download;
2. It doesn’t have a native progress bar, therefore, to see the progress, the script has to be opened in the terminal;
3. It only downloads HD trailers, so it doesn’t have the option of downloading trailers with lower quality;
4. It doesn’t include the option of choosing a specific trailer, it downloads all the trailers which are available for that particular film and resolution;
5. It could also be more compact, but since there isn't much processing, I didn’t care about the programming quality, but the practical results.

How to install it?

Its installation is simple: download the script file, open the terminal and go to the folder where you saved the file. Then, in order to make the script executable, type the following:
For the full version:

chmod +x appletrailers.sh


Or to 720p version:

chmod +x appletrailers720.sh


After that, the script is ready to be used, just do the following on the terminal to run it:
For the full version:

./appletrailers


Or to 720p version:

./appletrailers720


File download

Now that I’ve explained its functionalities and problems, I’m going to indicate the links for the download of the two versions and then I will show you the content of each script.

Full version.
720p version.

Code
Full version.

#!/bin/bash
####################################################
#Visit my blog: http://ubuntued.info/ #
####################################################


name=$( zenity --entry --text="URL:" --title="Apple Trailers")

temp=$(echo $name grep "/hd/")

if [[ $temp = "" ]]
then name=$(echo $name"hd/")
fi

quality=$(zenity --text="Which quality do you wish?" --list --radiolist --column sel --column sel2 1 480 2 720 3 1080)

if [[ $name != "" ]]
then
wget $name -File.html

case $quality
in
480)
action=$(cat file.html grep 480 awk -F"','" '{ print $10 }' awk -F"480" '{ print "wget " $1 "h480" $2 }')
;;
720)
action=$(cat file.html grep 720 awk -F"','" '{ print $10 }' awk -F"720" '{ print "wget " $1 "h720" $2 }')
;;
1080)
action=$(cat file.html grep 1080 awk -F"','" '{ print $10 }' awk -F"1080" '{ print "wget " $1 "h1080" $2 }')
;;
esac
rm file.html

action=$(echo $action awk -F"/" '{ print $NF }')
existent=$(ls grep "$action")

if [[ $existent = $action ]]
then zenity --question --text="You already have this trailer: \n \t (File's name: $existent ).\n Do you wish to continue?" exit

fi

$action sh

existent=$(ls grep "$action")

if [[ $existent = $action ]]
then zenity --info --text="Well-succeeded, the file was saved as $existent"
else zenity --error --text="Fail ocurred. Possible problems: The file already existed or the download couldn't be done."

fi

fi

Versão 720p.


#!/bin/bash
####################################################
#Visit my blog: http://ubuntued.info/ #
####################################################

name=$( zenity --entry --text="URL:" --title="Apple Trailers")

temp=$(echo $name grep "/hd/")

if [[ $temp = "" ]]
then name=$(echo $name"hd/")
fi

if [[ $name != "" ]]
then
wget $name -File.html

action=$(cat file.html grep 720 awk -F"','" '{ print $10 }' awk -F"720" '{ print "wget " $1 "h720" $2 }')

rm file.html

action=$(echo $action awk -F"/" '{ print $NF }')
existent=$(ls grep "$action")

if [[ $existent = $action ]]
then zenity --question --text="You already have this trailer: \n \t (File's name: $existent ).\n Do you wish to continue?" exit

fi

$action sh

existent=$(ls grep "$action")

if [[ $existent = $action ]]
then zenity --info --text="Well-succeeded, the file was saved as $existe"
else zenity --error --text="Fail ocurred. Possible problems: The file already existed or the download couldn't be done."

fi

fi

Finally, I would like to inform that whenever I update this script, only this web page will be updated, so if you want to be constantly updated leave a comment and activate the option "Notify me of follow up comments via e-mail." So when I update, I will write an informative comment about the new update and you’ll be notified (:

UPDATES
[2008 Jul 08]

As I have mentioned, I will update this script so that it becomes more effective, more embracing and with fewer errors. Thus, this new update informs you if the trailer you want to copy exists before downloading it.

Read more...