#!/usr/bin/perl use strict; # my $VERSION = "0.3 beta"; # 2004-08-25 - Fixing some Getopts things. Trying to get multiple-dld to work # 2004-08-24 - Push URL, when they seem to be clips (Clips can also have large/medium/small links) # Added Getopts - get help with "--help" # 2004-08-23 - Started putting appletrailer and appletrailers together # 2004-08-18 - Fix for Alfie # http://www.apple.com/trailers/paramount/alfie/ # TWO Embed Tags (Full Screen Button and Trailer) # _fs.mov (not fs1.mov) # 2004-08-12 - Started Modification to get all Trailers from # http://www.apple.com/trailers # -- Version 0.1 -- # 2004-03-16 - First Version # Takes an URL as parameter ( like the .../large.html # or .../moviename/) and finds the trailer to download # This Script gets the latest Apple Trailers # Created by Leonard Tulipan (micattack@gmx.net) # Homepage: http://downlets.sourceforge.net/ # Released under the GPL - This is free software # Needs # # HTML::TreeBuilder # Bundle::LWP # Term::ProgressBar # File::Basename # To install you probably just need to execute: # perl -e "use CPAN; install HTML::TreeBuilder; install Bundle::LWP;" # perl -e "use CPAN; install Term::ProgressBar; install File::Basename;" # Answer NO if cpan asks if you want to configure manually. This doesn't # select your local mirror, but it also doesn't bother you with a lot of # questions # Todo # # Use getopts and e.g.: # -a ... All Trailers (Now Default) # -m ... Movie Name (partial regex matching) # -l ... List (a)ll (default), (e)xclusive, (S)tudio # -k ... Ask before downloading # -p ... Prefered Version (small - medium - large) - currently always the largest # -s ... Download from that Studio # Set to 1 to see debug output # Can now be set with --debug command line switch my $debug=0; # For immediate output of progress bar $|++; # HTML Treebuilder is needed for HTML File Syntax checking use HTML::TreeBuilder; # LWP UserAgent is used for downloading the HTML Files from the web # make sure we have the modules we need, else die peacefully. # perl -e "use CPAN; install Bundle::LWP;" eval("use LWP 5.6.9;"); die "[err] LWP 5.6.9 or greater required.\n" if $@; # Progress Bar eval("use Term::ProgressBar;"); # prevent word-wrapping. die "[err] Term::ProgressBar not installed.\n" if $@; # For Command Line Options use Getopt::Long; # For dirname use File::Basename; my $version; my $help; my @url; my $ask; my $nobig; GetOptions( 'version' => \$version, 'debug' => \$debug, 'help' => \$help, 'url=s' => \@url, 'ask|k' => \$ask, 'nobig' => \$nobig); @url = split(/,/,join(',',@url)); if($version || $help) { print " Appletrailers Version $VERSION\n"; print " Created by Leonard Tulipan (micattack\@gmx.net)\n"; print " Homepage: http://downlets.sourceforge.net/\n"; print " Released under the GPL - This is free software\n"; if($help) { print < ... Download Trailer found on this URL (Specify the HTML not the MOV File e.g: -f http://www.apple.com/trailers/paramount/team_america/ You can specify more than one url with a comma separator or simply specify multiple -u on the command line --ask/-k ... Ask before Downloading a Trailer --debug/-d ... Turn Debugging On EndHelp } exit; } print " Debugging is now on\n" if $debug; # Start a new instance from UserAgent my $ua = LWP::UserAgent->new; # Set User Agent to iTunes $ua->agent('User-Agent: iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)'); # We save the trailerpages ../large.html or the like in this array my @trailerpages; if(!@url) { # Get All Trailers, if no url is specified on the command line # Get the Trailer HTML Page my $request = HTTP::Request->new('GET', "http://www.apple.com/trailers/"); # The Itunes xml URL: #my $request = HTTP::Request->new('GET', "www.apple.com/moviesxml/h/index.xml"); # Save the HTML in $response my $response = $ua->request($request); # Start a new instance of TreeBuilder my $tree = HTML::TreeBuilder->new(); # Parse the content of $response (Trailerpage) $tree->parse($response->content); # Print out the content, if there seems to be something wrong (new html code, etc) #print $response->content; # Get the Trailer-Rows - Look for
and put each of those as a value of an array my @trailer_rows = $tree->look_down("_tag", "div", sub{ $_[0]->attr('class') eq "rowtext"}); # Look for the exclusive Trailers inside the first
# Look for all