Merge branch 'master' of ssh://ryoko:22003/home/sun/GIT/videosite
[videosite.git] / videosite / VimeoGrabber.pm
index 951e014..6b1dd60 100644 (file)
@@ -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;
@@ -20,6 +19,8 @@ sub new {
     my $self = $class->SUPER::new();
 
     $self->{'NAME'} = 'vimeo';
+    $self->{_SELFTESTURL} = 'http://vimeo.com/35055590';
+    $self->{_SELFTESTTITLE} = 'Hello';
     $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*vimeo.com/(\d+))'];
 
     bless($self, $class);
@@ -53,7 +54,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;
     }
@@ -70,8 +71,9 @@ sub _parse {
         $self->debug('Selecting SD video');
         $hd = '';
     }
-    $timestamp = $t->{'xml'}->{'timestamp'};
-    $dlurl = sprintf('http://vimeo.com/moogaloop/play/clip:%s/1/%d%s', $metadata->{'ID'}, $timestamp, $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);
 
     unless(defined($dlurl)) {
         $self->error('No dlurl found in XML');