public
Created

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
#! /usr/bin/perl
# USAGE: yapc-vlc ROOM
# where ROOM is L, V, 313, or 325
# Based on the work of Christoph Jokubonis:
# http://mail.pm.org/pipermail/vienna-pm/2012-June/003125.html
 
use strict;
use warnings;
 
use IPC::Cmd qw[can_run];
use List::Util qw(first);
use HTML::TreeBuilder 5 -weak;
 
my $player = first { can_run($_) } qw(vlc vlc.exe mplayer mplayer.exe wmplayer.exe);
 
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, $new;
} else {
system "$player $new &";
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.