1 # (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
4 # Grabber for liveleak.com
6 package videosite::LiveLeakGrabber;
8 use videosite::GrabberBase;
9 @ISA = qw(videosite::GrabberBase);
18 my $self = $class->SUPER::new(
20 PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*liveleak.com/view\?i=([^\&]+))'],
23 return bless($self, $class);
38 $metadata->{'URL'} = $url;
39 $metadata->{'ID'} = $2;
40 $metadata->{'TYPE'} = 'video';
41 $metadata->{'SOURCE'} = $self->{'NAME'};
42 $metadata->{'TITLE'} = undef;
43 $metadata->{'DLURL'} = undef;
45 # Get the site to extract the title
46 unless(defined($content = $self->simple_get($url, $ua))) {
47 $self->error('Could not download page');
51 $p = HTML::TokeParser->new(\$content);
54 if ($p->get_tag('title')) {
55 $metadata->{'TITLE'} = $p->get_text();
56 $metadata->{'TITLE'} =~ s/^LiveLeak\.com\s+-\s+(.+)$/$1/im;
59 # Get the file containing the video metadata
60 unless(defined($content = $self->simple_get(sprintf('http://www.liveleak.com/mi?token=%s', $2), $ua))) {
61 $self->error('Could not download metadata');
65 unless ($content =~ m/file_location=([^\&]+)\&/) {
66 $self->error('Could not find download URL');
69 $metadata->{'DLURL'} = $1;
70 $metadata->{'DLURL'} =~ s/%(..)/chr(hex($1))/ge;
72 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
73 $self->error('Could not extract download URL and title');