1 # (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
6 package videosite::BlipTVGrabber;
8 use videosite::GrabberBase;
9 @ISA = qw(videosite::GrabberBase);
19 my $self = $class->SUPER::new();
21 $self->{'NAME'} = 'bliptv';
22 $self->{_SELFTESTURL} = 'http://blip.tv/rebelliouspixelscom/buffy-vs-edward-twilight-remixed-2274024';
23 $self->{_SELFTESTTITLE} = 'Buffy vs Edward (Twilight Remixed)';
24 $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*blip.tv/\S+/\S+)'];
27 $self->_prepare_parameters();
46 $metadata->{'URL'} = $url;
47 $metadata->{'TYPE'} = 'video';
48 $metadata->{'SOURCE'} = $self->{"NAME"};
49 $metadata->{'ID'} = undef;
50 $metadata->{'TITLE'} = undef;
51 $metadata->{'DLURL'} = undef;
53 unless(defined($content = $self->simple_get($url, $ua))) {
54 $self->error('Could not download page');
58 $p = HTML::TokeParser->new(\$content);
59 while ($tag = $p->get_tag('link')) {
60 if (($tag->[0] eq 'link') and
61 exists($tag->[1]->{'rel'}) and
62 ($tag->[1]->{'rel'} eq 'alternate') and
63 exists($tag->[1]->{'type'}) and
64 ($tag->[1]->{'type'} eq 'application/rss+xml')) {
66 $xml = $tag->[1]->{'href'};
67 $self->debug("Found RSS link: %s", $xml);
71 unless(defined($xml)) {
72 $self->error("Could not find RSS link");
76 # Download the XML file containing the stream information
78 unless(defined($content = $self->simple_get(sprintf('http://blip.tv%s', $xml), $ua))) {
79 $self->error('Could not download XML metadata');
83 $xml = XML::Simple::XMLin($content, KeepRoot => 1);
84 $metadata->{'DLURL'} = $xml->{'rss'}->{'channel'}->{'item'}->{'enclosure'}->{'url'};
85 $metadata->{'TITLE'} = $xml->{'rss'}->{'channel'}->{'item'}->{'title'};
86 $metadata->{'ID'} = $xml->{'rss'}->{'channel'}->{'item'}->{'blip:posts_id'};
88 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
89 $self->error('Could not determine download URL');