From: Ralf Ertzinger Date: Sun, 8 May 2011 11:28:47 +0000 (+0200) Subject: Wimp: Use JSON parser to handle player args X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=videosite.git;a=commitdiff_plain;h=717cceda344e9bebb0f0d000a4905bd755c3a1a2 Wimp: Use JSON parser to handle player args --- diff --git a/videosite/WimpGrabber.pm b/videosite/WimpGrabber.pm index cda5a95..83599a6 100644 --- a/videosite/WimpGrabber.pm +++ b/videosite/WimpGrabber.pm @@ -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'}; + } } }