Wimp: Use JSON parser to handle player args
authorRalf Ertzinger <ralf@skytale.net>
Sun, 8 May 2011 11:28:47 +0000 (13:28 +0200)
committerRalf Ertzinger <ralf@skytale.net>
Sun, 8 May 2011 11:28:47 +0000 (13:28 +0200)
videosite/WimpGrabber.pm

index cda5a95..83599a6 100644 (file)
@@ -10,6 +10,7 @@ use videosite::GrabberBase;
 
 use LWP::Simple qw(!get);
 use HTML::Parser;
+use videosite::JSArrayParser;
 use Data::Dumper;
 
 use strict;
@@ -72,8 +73,25 @@ sub _parse {
 
     # Look for the download URL
     foreach $e (@text) {
-        if ($e->[0] =~ m|\.setup\(.*file:\s*"([^\x22]+)"|) {
-            $metadata->{'DLURL'} = $1;
+        if ($e->[0] =~ m|\.setup\((.*)\);$|) {
+            my $jsp;
+            my $r;
+
+            $self->debug("Found JSON: %s", $1);
+            $jsp = videosite::JSArrayParser->new();
+            $self->debug("Using %s to parse", ref($jsp));
+            $r = $jsp->parse($1);
+
+            unless(defined($r)) {
+                $self->error("Found information hash, but could not parse");
+                return undef;
+            }
+
+            $self->debug("Parsed information: %s", Dumper($r));
+
+            if (exists($r->{'file'})) {
+                $metadata->{'DLURL'} = $r->{'file'};
+            }
         }
     }