use GrabberBase;
@ISA = qw(GrabberBase);
-use LWP::Simple qw(!get);
-use HTML::Parser;
+use HTMLHelper;
use Data::Dumper;
use strict;
my $pattern = shift;
my $content;
my $metadata = {};
- my $p = HTML::Parser->new(api_version => 3);
- my @accum;
- my @text;
- my $e;
+ my $p = HTMLHelper->new();
+ my $n;
$url =~ m|$pattern|;
$url = $1;
$metadata->{'TITLE'} = undef;
$metadata->{'DLURL'} = undef;
- unless(defined($content = LWP::Simple::get($1))) {
+ unless(defined($content = $p->load($1))) {
$self->error('Could not download %s', $url);
return undef;
}
- $p->handler(start => \@accum, "tagname, attr");
- $p->report_tags(qw(meta));
- $p->utf8_mode(1);
- $p->parse($content);
-
- # Look for the title in the meta tags
- foreach $e (@accum) {
- if ('meta' eq $e->[0]) {
- if ('embed_video_title' eq $e->[1]->{'name'}) {
- $metadata->{'TITLE'} = $e->[1]->{'content'};
- }
-
- if ('embed_video_thumb_url' eq $e->[1]->{'name'}) {
- $metadata->{'DLURL'} = $e->[1]->{'content'};
- $metadata->{'DLURL'} =~ s/\.jpg$/\.flv/;
- }
- }
+ $n = $p->findnodes('meta[@name="embed_video_title"]');
+ if (defined($n)) {
+ $metadata->{'TITLE'} = $n->{'content'};
+ }
+
+ $n = $p->findnodes('meta[@name="embed_video_thumb_url"]');
+ if (defined($n)) {
+ $metadata->{'DLURL'} = $n->{'content'};
+ $metadata->{'DLURL'} =~ s/\.jpg$/\.flv/;
}
unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
use GrabberBase;
@ISA = qw(GrabberBase);
-use LWP::Simple qw(!get);
-use HTML::Parser;
+use HTMLHelper;
use Data::Dumper;
use strict;
my $pattern = shift;
my $content;
my $metadata = {};
- my $p = HTML::Parser->new(api_version => 3);
- my @accum;
- my @text;
- my $e;
+ my $p = HTMLHelper->new();
+ my $n;
$url =~ m|$pattern|;
$url = $1;
$metadata->{'TITLE'} = undef;
$metadata->{'DLURL'} = undef;
- unless(defined($content = LWP::Simple::get(sprintf('http://www.broadcaster.com/clip/%s', $2)))) {
+ unless(defined($content = $p->load(sprintf('http://www.broadcaster.com/clip/%s', $2)))) {
$self->error('Could not download %s', $url);
return undef;
}
- $p->handler(start => \@accum, "tagname, attr");
- $p->handler(text => \@text, "text");
- $p->report_tags(qw(script));
- $p->utf8_mode(1);
- $p->parse($content);
-
# Look for the title
- foreach $e (@text) {
- if ($e->[0] =~ m|\&page_title=([^\x22]+)\x22|s) {
- $metadata->{'TITLE'} = $1;
- last;
- }
- }
+ ($metadata->{'TITLE'}) = grep { $_ =~ m|\&page_title=([^\x22]+)\x22|s && {$_ = $1} }
+ map { join("", @{$_->content()}) }
+ grep { defined($_->content()) }
+ $p->findnodes('script');
# Look for the download URL
- foreach $e (@text) {
- if ($e->[0] =~ m|\&clip_loc=.+?cache.broadcaster.com.+?escape\(\x22([^\x22]+)\x22\)|s) {
- $metadata->{'DLURL'} = 'http://cache.broadcaster.com/peoplecaster/' . $1;
- last;
- }
- }
+ ($metadata->{'DLURL'}) = grep { $_ =~ m|\&clip_loc=.+?cache.broadcaster.com.+?escape\(\x22([^\x22]+)\x22\)|s && {$_ = 'http://cache.broadcaster.com/peoplecaster/' .$1} }
+ map { join("", @{$_->content()}) }
+ grep { defined($_->content()) }
+ $p->findnodes('script');
unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
$self->error('Could not determine download URL');