public
Last active — forked from bingos/yapc-vlc.pl

Watch YAPC::NA with VLC

  • Download Gist
yapc-vlc.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#! /usr/bin/perl
# USAGE: yapc-vlc [-d|--dump] ROOM
# where ROOM is L, V, 313, or 325
# add a -d or -dump there to dump the stream to a file
 
use 5.10.0;
use strict;
use warnings;
 
use IPC::Cmd qw[can_run];
use List::Util qw(first);
use HTML::TreeBuilder 5 -weak;
use Getopt::Long;
 
 
my $player = first { can_run($_) } qw(vlc vlc.exe mplayer mplayer.exe wmplayer.exe);
 
# use -d or -dump to save the stream locally
GetOptions( "dump|d" => \(my $dump));
 
my($dump_opts);
 
if($dump) {
(my $dump_file = localtime ) =~ s/\W/_/g;
 
for($player) {
when(/vlc/) {
$dump_opts = "--sout '#duplicate{dst=display,dst=std{access=file,mux=raw,dst=$dump_file.asf}'"
}
when(/mplayer/){
$dump_opts = "-dumpstream -dumpfile $dump_file.asf"
}
default {
# i have no idea on how to dump a stream with other players -- nuba
}
}
}
 
my %room = (
l => '1de9c319-010c-4585-8617-210873935dfa',
325 => '90b5b79a-ceb6-4084-8cca-8977ff1aa729',
313 => '1c56eaf7-1178-4cb9-bf47-53e717ea74c2',
v => '5b80d7ae-5fc7-46c4-98ba-5f770a8be940',
);
 
my $catalog =
'http://ics.webcast.uwex.edu/mediasite/Catalog/pages/catalog.aspx?catalogId='
. ($room{lc shift} || die "Room must be l v 313 325");
 
my $tree = HTML::TreeBuilder->new_from_url($catalog);
 
my $url =
$tree->look_down(qw(_tag span class PresentationCard_OnAir))
->look_up(qw(_tag tr))
->look_down(qw(_tag a href) =>
qr!^http://ics\.webcast\.uwex\.edu/mediasite/Viewer!)
->attr('href');
 
my @parts = ($url =~ /peid=(\w{8})(\w{4})(\w{4})(\w{4})(\w+)\w\w\z/)
or die;
 
my $new = "http://video.ics.uwex.edu/" . join('-', @parts);
 
#use 5.010; say $new; exit;
 
if ($^O =~ /Win32/) {
system start => $player, $dump_opts, $new;
} else {
system "$player $dump_opts $new"
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.