1 # (c) 2009 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
6 package videosite::VeohGrabber;
8 use videosite::GrabberBase;
9 @ISA = qw(videosite::GrabberBase);
17 my $self = $class->SUPER::new(
19 _SELFTESTURL => 'http://www.veoh.com/watch/v18348952fyn2twbe',
20 _SELFTESTTITLE => '518_2 kureyon shinchan',
21 PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*veoh.com/+watch/(\w+)\??)'],
24 return bless($self, $class);
44 $metadata->{'URL'} = $url;
45 $metadata->{'ID'} = $2;
46 $metadata->{'TYPE'} = 'video';
47 $metadata->{'SOURCE'} = $self->{'NAME'};
48 $metadata->{'TITLE'} = undef;
49 $metadata->{'DLURL'} = undef;
51 unless(defined($content = $self->simple_get(sprintf('http://www.veoh.com/watch/%s', $2), $ua))) {
52 $self->error('Could not download');
56 $p = HTML::TokeParser->new(\$content);
58 while ($t = $p->get_tag('script')) {
59 if ($t->[0] eq 'script') {
60 my $e = $p->get_text();
63 if ($e =~ m|__watch.videoDetailsJSON = '([^\x27]+)|) {
64 $self->debug("Found JSON: %s", $1);
65 $jsp = videosite::JSArrayParser->new();
69 $self->error("Found information hash, but could not parse");
73 $self->debug("Parsed JSON: %s", Dumper($r));
75 unless(exists($r->{previewUrl})) {
76 $self->error("previewUrl not found in information hash");
80 $metadata->{'DLURL'} = $r->{previewUrl};
81 $metadata->{'TITLE'} = $r->{title};
86 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
87 $self->error('Could not extract download URL and title');