#!/usr/bin/perl -w # make sure you have wget and mimms on your system before using this script use strict; # Grab url from standard input # Expect something like: # javascript:openMediaPop('/multimedia/tds/headlines/10015.html','','SRM','low'); # or # http://www.comedycentral.com/mp/play.jhtml?reposid=/multimedia/tds/headlines/10015.html my $target = <>; # Hack to make second (http) form look like first (javascript) form if ($target =~ /reposid=([^\'\"\>\n\r]*)/) { my $v = $1; $target = "\'$v\',,,\'low\'"; } # Extract reposid and resolution if ($target =~ /\'([^\']+.html)\',.*,.*,\'([a-z]+)\'/) { my $js = $1; my $quality = $2; # construct page that will provide required material my $t1 = "http://www.comedycentral.com/mp/play.jhtml?player=realplayer&type=v&quality=$quality&reposid=$js"; # grab that page - save to src1.txt to aid debugging my $txt = `wget -O - \"$t1\" | tee src1.txt`; # find plugin material if ($txt =~ /(videoswitcher[^\n\'\"\>]*)/) { my $t2 = $1; $t2 = "http://www.comedycentral.com/mp/$t2"; # grab the material the plugin references my $txt2 = `wget -O - \"$t2\" | tee src2.txt`; if ($txt2 =~ /(mms:[^\n\'\"\>]+)/) { # finally, grab the mimms stream. You should have a wmv file now my $t3 = $1; system "mimms \"$t3\""; } } }