- Rework download URL finder for youtube, fixing recent breakage
authorRalf Ertzinger <sun@ryoko.camperquake.de>
Fri, 25 Jan 2008 20:35:40 +0000 (21:35 +0100)
committerRalf Ertzinger <sun@ryoko.camperquake.de>
Fri, 25 Jan 2008 20:35:40 +0000 (21:35 +0100)
videosite/YouTubeGrabber.pm

index 2cb55c1..006ec17 100644 (file)
@@ -73,14 +73,18 @@ sub _parse {
         if ('meta' eq $e->[0]) {
             if ('title' eq $e->[1]->{'name'}) {
                 $metadata->{'TITLE'} = $e->[1]->{'content'};
+                $self->debug('Title found: %s', $metadata->{'TITLE'});
             }
         }
     }
 
     # Look for the download URL
     foreach $e (@text) {
-        if ($e->[0] =~ m|/watch_fullscreen\?(.*)\&fs|) {
-            $metadata->{'DLURL'} = 'http://www.youtube.com/get_video.php?' . $1;
+        if ($e->[0] =~ m|/watch_fullscreen\?(.+)\x27|) {
+            my %args = map { my @a = split(/=/); ($a[0], $a[1]) } split(/&/, $1);
+            $metadata->{'DLURL'} = sprintf('http://www.youtube.com/get_video.php?video_id=%s&t=%s',
+                    $metadata->{'ID'}, $args{'t'});
+                $self->debug('URL found: %s', $metadata->{'DLURL'});
         }
     }