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+)\??)'],
25 return bless($self, $class);
45 $metadata->{'URL'} = $url;
46 $metadata->{'ID'} = $2;
47 $metadata->{'TYPE'} = 'video';
48 $metadata->{'SOURCE'} = $self->{'NAME'};
49 $metadata->{'TITLE'} = undef;
50 $metadata->{'DLURL'} = undef;
52 unless(defined($content = $self->simple_get(sprintf('http://www.veoh.com/watch/%s', $2), $ua))) {
53 $self->error('Could not download');
57 $p = HTML::TokeParser->new(\$content);
59 while ($t = $p->get_tag('script')) {
60 if ($t->[0] eq 'script') {
61 my $e = $p->get_text();
64 if ($e =~ m|__watch.videoDetailsJSON = '([^\x27]+)|) {
65 $self->debug("Found JSON: %s", $1);
66 $jsp = videosite::JSArrayParser->new();
70 $self->error("Found information hash, but could not parse");
74 $self->debug("Parsed JSON: %s", Dumper($r));
76 unless(exists($r->{previewUrl})) {
77 $self->error("previewUrl not found in information hash");
81 $metadata->{'DLURL'} = $r->{previewUrl};
82 $metadata->{'TITLE'} = $r->{title};
87 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
88 $self->error('Could not extract download URL and title');