1 # (c) 2008 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
4 # Grabber for mncast.com
6 package videosite::MNCastGrabber;
8 use videosite::GrabberBase;
9 @ISA = qw(videosite::GrabberBase);
11 use LWP::Simple qw(!get);
20 my $self = $class->SUPER::new();
22 $self->{'NAME'} = 'mncast';
23 $self->{'PATTERNS'} = ['(http://www\.mncast\.com/\?(\d+))'];
26 $self->_prepare_parameters();
45 $metadata->{'URL'} = $url;
46 $metadata->{'ID'} = $2;
47 $metadata->{'TYPE'} = 'video';
48 $metadata->{'SOURCE'} = $self->{'NAME'};
49 $metadata->{'TITLE'} = undef;
50 $metadata->{'DLURL'} = undef;
52 # First, get a webpage containing the video ID
53 unless(defined($content = LWP::Simple::get(sprintf('http://www.mncast.com/player/index.asp?mnum=%s', $2)))) {
54 $self->error('Could not download player page');
58 $p = HTML::TokeParser->new(\$content);
60 while ($t = $p->get_tag('script')) {
61 if ($p->get_text() =~ m|strMID = \x22([^\x22]+)\x22|s) {
67 # Get the XML file containing the video metadata
68 unless(defined($content = LWP::Simple::get(sprintf('http://www.mncast.com/_MovieInfo_/_MovieInfoXML_Tag_v2.asp?movieID=%s&loginPNum=-1&player=0', $vid)))) {
69 $self->error('Could not download XML metadata');
73 # There is no XML header in the data, which makes XML::Simple unhappy
74 $content = '<?xml version="1.0" encoding="UTF-8"?>' . $content;
75 $p = XML::Simple->new();
77 unless(defined($t = $p->XMLin($content, KeepRoot => 1))) {
78 $self->error('Could not parse XML metadata');
82 $metadata->{'DLURL'} = sprintf('http://%s.flv', $t->{'moviedata'}->{'url'});
83 $metadata->{'TITLE'} = $t->{'moviedata'}->{'title'};
85 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
86 $self->error('Could not extract download URL and title');