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=([^\&]+))'],
24 return bless($self, $class);
39 $metadata->{'URL'} = $url;
40 $metadata->{'ID'} = $2;
41 $metadata->{'TYPE'} = 'video';
42 $metadata->{'SOURCE'} = $self->{'NAME'};
43 $metadata->{'TITLE'} = undef;
44 $metadata->{'DLURL'} = undef;
46 # Get the site to extract the title
47 unless(defined($content = $self->simple_get($url, $ua))) {
48 $self->error('Could not download page');
52 $p = HTML::TokeParser->new(\$content);
55 if ($p->get_tag('title')) {
56 $metadata->{'TITLE'} = $p->get_text();
57 $metadata->{'TITLE'} =~ s/^LiveLeak\.com\s+-\s+(.+)$/$1/im;
60 # Get the file containing the video metadata
61 unless(defined($content = $self->simple_get(sprintf('http://www.liveleak.com/mi?token=%s', $2), $ua))) {
62 $self->error('Could not download metadata');
66 unless ($content =~ m/file_location=([^\&]+)\&/) {
67 $self->error('Could not find download URL');
70 $metadata->{'DLURL'} = $1;
71 $metadata->{'DLURL'} =~ s/%(..)/chr(hex($1))/ge;
73 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
74 $self->error('Could not extract download URL and title');