X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FVimeoGrabber.pm;h=4371e532033d8b4dfe15a5c48e89568691b1a940;hb=c41cdd5161342c69724537a5094fb9e270f48c55;hp=3e8ce6a4a1277abbc2f71d0dea2c532046afcb9c;hpb=d5eef9cc4f276f621e37618a09e9b304b378a2df;p=videosite.git diff --git a/videosite/VimeoGrabber.pm b/videosite/VimeoGrabber.pm index 3e8ce6a..4371e53 100644 --- a/videosite/VimeoGrabber.pm +++ b/videosite/VimeoGrabber.pm @@ -3,10 +3,10 @@ # # 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; @@ -37,6 +37,7 @@ sub _parse { my $p = XML::Simple->new(); my $t; my $dlurl; + my $hd; my $dlpath; my $timestamp; my $hash; @@ -62,24 +63,35 @@ sub _parse { return undef; } - $dlurl = $t->{'xml'}->{'video'}->{'hd_file'} || $t->{'xml'}->{'video'}->{'file'}; - $timestamp = $t->{'xml'}->{'timestamp'}; - - unless(defined($dlurl)) { - return undef; + if (exists($t->{'xml'}->{'video'}->{'isHD'}) and (0 != $t->{'xml'}->{'video'}->{'isHD'})) { + $self->debug('Selecting HD video'); + $hd = '/?q=hd'; + } else { + $self->debug('Selecting SD video'); + $hd = ''; } + $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); - # 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 { + unless(defined($dlurl)) { + $self->error('No dlurl found in XML'); 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'})) {