#!/usr/bin/perl -T # launcher script for mplayer from e.g. # /etc/mailcap "video/*; mplaylist %s" # Andrew Daviel, TRIUMF, February 2008 # for quicktime files, .MOV might be an actual movie. # or it might be a "reference movie" ( playlist) # if it's bigger than 2000 bytes, assume it's a movie # and give it to mplayer # otherwise, look inside and try to find a stream URL $ENV{PATH} = '/usr/local/bin' ; # where to find mplayer open (LOG,">/tmp/mplaylist.log") ; my $file = shift ; my $tfile ; if ($file =~ /^([\w\s\.\/\-_]+)$/) { $tfile = $1 ; } # untaint unless ($tfile) { print LOG "Invalid file in \"$file\"\n" ; } my @stat = stat($tfile) ; my $size = $stat[7]; print LOG "file $tfile size $size\n" ; close(LOG) ; if ($size>2000) { exec ("mplayer -quiet $tfile >> /tmp/mplaylist.log 2>\&1") ; } else { open (IN,"$tfile") or die ; while () { if (/^RTSPtext(.*)/i or /^File1=[\s]*(rtsp:.*)/i or /^File1=[\s]*(http:.*)/i or /^[\s]*([\w]+:\/.*)/ or /href="([\w]+p:.*)"/i or /href=([\w]+p:.*)/i) { exec ("mplayer -quiet -cache 32 $1 >> /tmp/mplaylist.log 2>\&1") ; } } } #exec mplayer -user videos -passwd -playlist $* #exec mplayer -cache 32 -playlist $F >> /tmp/mplaylist.log 2>&1