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+)'],
27 return bless($self, $class);
44 $metadata->{'URL'} = $url;
45 $metadata->{'TYPE'} = 'video';
46 $metadata->{'SOURCE'} = $self->{"NAME"};
47 $metadata->{'ID'} = undef;
48 $metadata->{'TITLE'} = undef;
49 $metadata->{'DLURL'} = undef;
51 unless(defined($content = $self->simple_get($url, $ua))) {
52 $self->error('Could not download page');
56 $p = HTML::TokeParser->new(\$content);
57 while ($tag = $p->get_tag('link')) {
58 if (($tag->[0] eq 'link') and
59 exists($tag->[1]->{'rel'}) and
60 ($tag->[1]->{'rel'} eq 'alternate') and
61 exists($tag->[1]->{'type'}) and
62 ($tag->[1]->{'type'} eq 'application/rss+xml')) {
64 $xml = $tag->[1]->{'href'};
65 $self->debug("Found RSS link: %s", $xml);
69 unless(defined($xml)) {
70 $self->error("Could not find RSS link");
74 # Download the XML file containing the stream information
76 unless(defined($content = $self->simple_get(sprintf('http://blip.tv%s', $xml), $ua))) {
77 $self->error('Could not download XML metadata');
81 $xml = XML::Simple::XMLin($content, KeepRoot => 1);
82 $metadata->{'DLURL'} = $xml->{'rss'}->{'channel'}->{'item'}->{'enclosure'}->{'url'};
83 $metadata->{'TITLE'} = $xml->{'rss'}->{'channel'}->{'item'}->{'title'};
84 $metadata->{'ID'} = $xml->{'rss'}->{'channel'}->{'item'}->{'blip:posts_id'};
86 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
87 $self->error('Could not determine download URL');