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 _SELFTESTURL => 'http://blip.tv/rebelliouspixelscom/buffy-vs-edward-twilight-remixed-2274024',
22 _SELFTESTTITLE => 'Buffy vs Edward (Twilight Remixed)',
23 PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*blip.tv/\S+/\S+)'],
26 return bless($self, $class);
43 $metadata->{'URL'} = $url;
44 $metadata->{'TYPE'} = 'video';
45 $metadata->{'SOURCE'} = $self->{"NAME"};
46 $metadata->{'ID'} = undef;
47 $metadata->{'TITLE'} = undef;
48 $metadata->{'DLURL'} = undef;
50 unless(defined($content = $self->simple_get($url, $ua))) {
51 $self->error('Could not download page');
55 $p = HTML::TokeParser->new(\$content);
56 while ($tag = $p->get_tag('link')) {
57 if (($tag->[0] eq 'link') and
58 exists($tag->[1]->{'rel'}) and
59 ($tag->[1]->{'rel'} eq 'alternate') and
60 exists($tag->[1]->{'type'}) and
61 ($tag->[1]->{'type'} eq 'application/rss+xml')) {
63 $xml = $tag->[1]->{'href'};
64 $self->debug("Found RSS link: %s", $xml);
68 unless(defined($xml)) {
69 $self->error("Could not find RSS link");
73 # Download the XML file containing the stream information
75 unless(defined($content = $self->simple_get(sprintf('http://blip.tv%s', $xml), $ua))) {
76 $self->error('Could not download XML metadata');
80 $xml = XML::Simple::XMLin($content, KeepRoot => 1);
81 $metadata->{'DLURL'} = $xml->{'rss'}->{'channel'}->{'item'}->{'enclosure'}->{'url'};
82 $metadata->{'TITLE'} = $xml->{'rss'}->{'channel'}->{'item'}->{'title'};
83 $metadata->{'ID'} = $xml->{'rss'}->{'channel'}->{'item'}->{'blip:posts_id'};
85 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
86 $self->error('Could not determine download URL');