O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  



Viewing launch.com musicvideos under *nix with mplayer
launch.com uses an integrated musicvideo playback system designed for Internet Explorer and Windows Media Player. This hack describes a method for playing this content under any *nix using mplayer.

Contributed by:
Michael Clement
[11/29/03 | Discuss (16) | Link to this hack]

I've been working on a way to watch music videos from launch.com under Linux or *BSD. Their way of showing videos relies on Internet Explorer and Windows Media Player, and gives an error message whenever one tries to access videos using anything else.

I spent some time with Ethereal, capturing the packet transfers under Windows, and got a handle on the sequence of HTTP requests involved in retrieving a URL to the media stream, a mms:// address. I have posted a more complete writeup of the analysis in my sourceforge diary.

This Perl script is a basic hack that performs these lookups, given a video ID. This ID is obtained by mousing over the desired video link at launch.com, and entering the number given in the javascript call as the sole commandline parameter of the Perl script. The script will parse, build, and execute the requests as needed, and attempt to open the resulting stream with mplayer.

The script was built under FreeBSD 4.8-RELEASE and Perl 5.005_03, for mplayer 0.90rc4-2.95.4. I've had pretty good success, though it has caused a lockup once when running in fullscreen mode - consider yourself warned! Also, mplayer tends to hang at the end of the stream, so you might have to kill it.

Example usage:

./scriptname.pl 1079533

This plays Relax by Keoki.

Here is a somewhat stripped-down version:

#!/usr/bin/perl
# Written by badfugu - October 2003
# I do claim some ownership, but please distribute freely.

require LWP::UserAgent;
require HTTP::Request;
require HTTP::Response;

# Get video ID from input
my $vid_id = $ARGV[0];
print "Video ID: $vid_id\n";
($vid_id <= 0) and die "Invalid video ID!\n";

# Build the first URL
my $pri_url_head =
"http://launchtoday.launch.yahoo.com/player/showasx.asp?cid=1&pid=4&csid=396500550&sx=g/1.xml&sgm=1&vid=";
my $pri_url_tail =
"&bw=300&pv=6&bp=Windows%209x&uid=1326200615&uguid=014cc991dbaa442e9e14f1df48a434ba&im=0&pls=&asp=&fcv=&z=y.asx";
my $pri_url = $pri_url_head . $vid_id . $pri_url_tail;

# Attempt to fetch the playlist (asx) from that URL
print "Attempting to fetch from showasx.asp...\n";
my $ua = new LWP::UserAgent;
my $request = new HTTP::Request 'GET', $pri_url;
my $response = $ua->request($request);
if (!($response->is_success)) {
die "Could not fetch!\n";
}

# Extract second url from response
my $sec_url = "";
if ($response->content =~ /(http:.+medialog.+$vid_id.+asx)/) {
$sec_url = "$1";
} else {
die "Could not extract medialog.asp url!\n";
}

# Attempt to fetch the next playlist from the secondary URL
print "Attempting to fetch from medialog.asp...\n";
my $mkpl_url = "";
$request->url($sec_url);
$response = $ua->request($request);
if (!($response->is_success)) {
die "Could not fetch!\n";
} else {
$mkpl_url = $response->content;
}

# Attempt to fetch the media stream URL
print "Attempting to fetch from makeplaylist.dll...\n";
$request->url($mkpl_url);
$response = $ua->request($request);
if (!($response->is_success)) {
die "Could not fetch!\n";
} else {
$mms_url = $response->content;
}

# Play that stream!!!
system("mplayer -bandwidth 99999999 $mms_url");

# eof 

See also: http://launch.yahoo.com
http://sourceforge.net/developer/diary.php?diary_id=14623&diary_user=895596
http://www.mplayerhq.hu/


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.