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/
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Uso: launch.sh <videoid> (<bandwidth>) "
exit 0
fi
videoid=$1
shift
if [ $1 -eq $1 ] && [ $1 != 0 ]; then
bandwidth=$1
shift
else
bandwidth=300
fi
file1=$(echo "http://launchtoday.launch.yahoo.com/player/medialog.asp?vid=$videoid&cid=1&pid=4&csid=396500550&p1=&p2=&p3=2&bw=$bandwidth&mf=1&origin=35&pguid=AA388C059C7849D99CCFBC72B6F51E37&uid=42&sk=bad551cd352143eb2da02&z=ms.asx")
file2=$(echo "medialog.asp?vid=$videoid&cid=1&pid=4&csid=396500550&p1=&p2=&p3=2&bw=$bandwidth&mf=1&origin=35&pguid=AA388C059C7849D99CCFBC72B6F51E37&uid=42&sk=bad551cd352143eb2da02&z=ms.asx")
wget -c $file1 $@
wget -i $file2
file3=$(cat makeplaylist.dll*)
mplayer -dumpstream -dumpfile $videoid.wmv "$file3"
rm -f *.asx
mplayer "$videoid".wmv
-Renkho-
www.swp-scene.org