X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FVimeoGrabber.pm;h=89d315841318a4aa96e0be24bd8eba14c13f714c;hb=2d23e11ae4900b1be59bb26fbae73397161bccd7;hp=b293ed8e9991bd5fea39a581a41b691f724a0c65;hpb=6bbc740269f85c48aa0c9b25c274ca8a09ddc4a4;p=videosite.git diff --git a/videosite/VimeoGrabber.pm b/videosite/VimeoGrabber.pm index b293ed8..89d3158 100644 --- a/videosite/VimeoGrabber.pm +++ b/videosite/VimeoGrabber.pm @@ -3,12 +3,11 @@ # # Grabber for vimeo.com -package VimeoGrabber; +package videosite::VimeoGrabber; -use GrabberBase; -@ISA = qw(GrabberBase); +use videosite::GrabberBase; +@ISA = qw(videosite::GrabberBase); -use LWP::Simple qw(!get); use XML::Simple; use Digest::MD5 qw(md5_hex); use Data::Dumper; @@ -37,6 +36,7 @@ sub _parse { my $p = XML::Simple->new(); my $t; my $dlurl; + my $hd; my $dlpath; my $timestamp; my $hash; @@ -52,7 +52,7 @@ sub _parse { $metadata->{'DLURL'} = undef; # Get the XML file containing the video metadata - unless(defined($content = LWP::Simple::get(sprintf('http://www.vimeo.com/moogaloop/load/clip:%s/local?context=default&context_id=undefined', $2)))) { + unless(defined($content = $self->simple_get(sprintf('http://www.vimeo.com/moogaloop/load/clip:%s', $2)))) { $self->error('Could not download XML metadata'); return undef; } @@ -62,32 +62,35 @@ sub _parse { return undef; } - if (exists($t->{'xml'}->{'video'}->{'is_hd'}) and (0 != $t->{'xml'}->{'video'}->{'is_hd'})) { + if (exists($t->{'xml'}->{'video'}->{'isHD'}) and (0 != $t->{'xml'}->{'video'}->{'isHD'})) { $self->debug('Selecting HD video'); - $dlurl = $t->{'xml'}->{'video'}->{'hd_file'}; + $hd = '/?q=hd'; } else { $self->debug('Selecting SD video'); - $dlurl = $t->{'xml'}->{'video'}->{'file'}; + $hd = ''; } - $timestamp = $t->{'xml'}->{'timestamp'}; + $timestamp = $t->{'xml'}->{'request_signature_expires'}; + $hash = $t->{'xml'}->{'request_signature'}; + $dlurl = sprintf('http://vimeo.com/moogaloop/play/clip:%s/%s/%d%s', $metadata->{'ID'}, $hash, $timestamp, $hd); unless(defined($dlurl)) { $self->error('No dlurl found in XML'); return undef; } - # Vimeo appends a hash to the download URL, in order to thwart people like me. - # Unfortunately the algorithm isn't that complicated :) - if ($dlurl =~ m|http://bitcast.vimeo.com(.+)|) { - $dlpath = $1; - $timestamp += 1800; - $hash = md5_hex(sprintf('redFiretruck%s?e=%d', $dlpath, $timestamp)); - } else { - $self->error('Unknown dlurl scheme: %s', $dlurl); - return undef; - } - - $metadata->{'DLURL'} = sprintf('%s?e=%d&h=%s', $dlurl, $timestamp, $hash); + # # Vimeo appends a hash to the download URL, in order to thwart people like me. + # # Unfortunately the algorithm isn't that complicated :) + # if ($dlurl =~ m|http://bitcast.vimeo.com(.+)|) { + # $dlpath = $1; + # $timestamp += 1800; + # $hash = md5_hex(sprintf('redFiretruck%s?e=%d', $dlpath, $timestamp)); + # } else { + # $self->error('Unknown dlurl scheme: %s', $dlurl); + # return undef; + # } + + # $metadata->{'DLURL'} = sprintf('%s?e=%d&h=%s', $dlurl, $timestamp, $hash); + $metadata->{'DLURL'} = $dlurl; $metadata->{'TITLE'} = $t->{'xml'}->{'video'}->{'caption'}; unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {