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);
19 my $self = $class->SUPER::new(
21 PATTERNS => ['(http://www\.mncast\.com/\?(\d+))'],
25 return bless($self, $class);
43 $metadata->{'URL'} = $url;
44 $metadata->{'ID'} = $2;
45 $metadata->{'TYPE'} = 'video';
46 $metadata->{'SOURCE'} = $self->{'NAME'};
47 $metadata->{'TITLE'} = undef;
48 $metadata->{'DLURL'} = undef;
50 # First, get a webpage containing the video ID
51 unless(defined($content = $self->simple_get(sprintf('http://www.mncast.com/player/index.asp?mnum=%s', $2), $ua))) {
52 $self->error('Could not download player page');
56 $p = HTML::TokeParser->new(\$content);
58 while ($t = $p->get_tag('script')) {
59 if ($p->get_text() =~ m|strMID = \x22([^\x22]+)\x22|s) {
65 # Get the XML file containing the video metadata
66 unless(defined($content = $self->simple_get(sprintf('http://www.mncast.com/_MovieInfo_/_MovieInfoXML_Tag_v2.asp?movieID=%s&loginPNum=-1&player=0', $vid), $ua))) {
67 $self->error('Could not download XML metadata');
71 # There is no XML header in the data, which makes XML::Simple unhappy
72 $content = '<?xml version="1.0" encoding="UTF-8"?>' . $content;
73 $p = XML::Simple->new();
75 unless(defined($t = $p->XMLin($content, KeepRoot => 1))) {
76 $self->error('Could not parse XML metadata');
80 $metadata->{'DLURL'} = sprintf('http://%s.flv', $t->{'moviedata'}->{'url'});
81 $metadata->{'TITLE'} = $t->{'moviedata'}->{'title'};
83 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
84 $self->error('Could not extract download URL and title');