xmltv/grab/fi/fi/source foxtv.pm, 2.01, 2.02 mtv3.pm, 2.03, 2.04
Stefan Becker <[email protected]>
| Newsgroups | gmane.comp.tv.xmltv.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xmltv/xmltv/grab/fi/fi/source
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5277/grab/fi/fi/source
Modified Files:
foxtv.pm mtv3.pm
Log Message:
- mtv3: updated after site changed considerably
- NOTE: mtv3 has new channel IDs!
- foxtv: don't use episode name if it is the same as title
Index: foxtv.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/fi/fi/source/foxtv.pm,v
retrieving revision 2.01
retrieving revision 2.02
diff -C2 -d -r2.01 -r2.02
*** foxtv.pm 1 Nov 2013 22:55:13 -0000 2.01
--- foxtv.pm 20 Nov 2013 07:58:21 -0000 2.02
***************
*** 181,186 ****
# Description can be empty or "-"
undef $desc if ($desc eq '') || ($desc eq '-');
undef $episode_name
! if defined($episode_name) && ($episode_name eq '');
debug(3, "List entry fox ($hour:$minute) $title");
--- 181,188 ----
# Description can be empty or "-"
undef $desc if ($desc eq '') || ($desc eq '-');
+ # Episode name can be the same as the title
undef $episode_name
! if defined($episode_name) &&
! (($episode_name eq '') || ($episode_name eq $title));
debug(3, "List entry fox ($hour:$minute) $title");
Index: mtv3.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/fi/fi/source/mtv3.pm,v
retrieving revision 2.03
retrieving revision 2.04
diff -C2 -d -r2.03 -r2.04
*** mtv3.pm 1 Nov 2013 22:55:13 -0000 2.03
--- mtv3.pm 20 Nov 2013 07:58:21 -0000 2.04
***************
*** 24,74 ****
sub description { 'mtv3.fi' }
- # Grab channels from one group page
- sub _get_channels($$) {
- my($channels, $page) = @_;
-
- # Fetch & parse HTML
- my $root = fetchTree("http://www.mtv3.fi/tvopas/${page}.shtml", "iso-8859-1");
- if ($root) {
-
- #
- # Channel name & order can be found from the headers in this table:
- #
- # <table cellspacing="0" cellpadding="0" border="0" class="ohjelmisto" id="ohjelmisto">
- # <tr>
- # <th width="17%"><div title="MTV3 Leffa" class="channel-logo channel-mtv3-leffa">MTV3 Leffa</div></th>
- # <th width="17%"><div title="C More First" class="channel-logo channel-cmore-first">C More First</div></th>
- # ...
- # </tr>
- # ...
- # </table>
- #
- if (my $container = $root->look_down("class" => "ohjelmisto")) {
- if ((my @headers = $container->find("th")) &&
- (my @entries = $container->find("td"))) {
-
- if (@entries >= @headers) {
- my $count = 0;
-
- debug(2, "Source mtv3.fi found " . scalar(@headers) . " channels in group ${page}");
- foreach my $option (@headers) {
- my $name = $option->as_text();
- my $class = $entries[$count++]->attr("class");
-
- if (length($name) && defined($class) &&
- (my($index) = ($class =~ /^kanava(\d+)$/))) {
- debug(3, "channel '$name' (${index}.${page})");
- $channels->{"${index}.${page}.mtv3.fi"} = "fi $name";
- }
- }
- }
- }
- }
-
- # Done with the HTML tree
- $root->delete();
- }
- }
-
# Grab channel list
sub channels {
--- 24,27 ----
***************
*** 80,110 ****
#
! # Channel list can be found from this dropdown:
! #
! # <select onchange="window.open(this.options[this.selectedIndex].value,'_self')">
! # <option value="#">Valitse kanava</option>
! # <option value="/tvopas/index.shtml">YLE1</option>
! # ...
! # <option value="/tvopas/muutkanavat.shtml">KinoTV</option>
! # <option value="/tvopas/muutkanavat.shtml">Digiviihde</option>
! # </select>
#
! # Unfortunately they are not in the correct order
#
! if (my $container = $root->look_down("onchange" => qr/^window.open/)) {
! if (my @options = $container->find("option")) {
! my %pages;
! debug(2, "Source mtv3.fi found " . scalar(@options) . " channels");
! foreach my $option (@options) {
! my $id = $option->attr("value");
! if (defined($id) &&
! (my($page) = ($id =~ m,^/tvopas/(\w+)\.shtml$,))) {
! $pages{$page}++;
}
}
- debug(2, "Source mtv3.fi found " . scalar(keys %pages) . " groups");
- _get_channels(\%channels, $_) foreach (keys %pages);
}
}
--- 33,66 ----
#
! # Channel list can be found from the headers of this table:
#
! # <table class="ohjelmakartta" cellspacing="0" cellpadding="0" border="0">
! # <thead>
! # <tr class="logot">
! # <th class="logo logo-old yle1"><span>yle1</span></th>
! # <th class="logo logo-old yle2"><span>yle2</span></th>
! # <th class="logo mtv3"><span>mtv3</span></th>
! # ...
! # <th class="logo logo-old jim"><span>jim</span></th>
! # </thead>
! # ...
! # </table>
#
! if (my $container = $root->look_down("class" => "ohjelmakartta")) {
! if (my @headers = $container->find("th")) {
! debug(2, "Source mtv3.fi found " . scalar(@headers) . " channels");
! foreach my $header (@headers) {
! my $name = $header->as_text();
!
! # Unfortunately the HTML code does not show the real channel name
! if (defined($name) && length($name)) {
! # Underscore is not a valid XMLTV channel ID character
! (my $id = $name) =~ s/_/-/g;
! debug(3, "channel '$id' ($name)");
! $channels{"${id}.mtv3.fi"} = "fi $name";
}
}
}
}
***************
*** 130,137 ****
# Get channel number from XMLTV id
! return unless my($channel, $page) = ($id =~ /^(\d+)\.([^.]+)\.mtv3\.fi$/);
# Fetch & parse HTML
! my $root = fetchTree("http://www.mtv3.fi/tvopas/${page}.shtml/$today",
"iso-8859-1");
if ($root) {
--- 86,96 ----
# Get channel number from XMLTV id
! return unless my($channel) = ($id =~ /^([^.]+)\.mtv3\.fi$/);
!
! # Replace Dash with Underscore for node search
! $channel =~ s/-/_/g;
# Fetch & parse HTML
! my $root = fetchTree("http://www.mtv3.fi/tvopas/index.shtml/$today",
"iso-8859-1");
if ($root) {
***************
*** 141,157 ****
# Programmes for a channel can be found in a separate <td> node
#
! # <table ... class="ohjelmisto" id="ohjelmisto">
! # <tr id="tvopas0400">
! # <td ... class="kanava1">
! # <div class="ohjelma uutiset"><span class="aika">04:00</span>
! # <a class="nimi" href="http://www.mtv3.fi/tvopas/ohjelma.shtml/yle1/20110212/1/uutisikkuna">Uutisikkuna</a>
! # <div class="clearall"></div>
! # <div class="seloste">
! # <div class="tvsel_aika">12.02.2011 klo 04:00-08:00</div>
! # <div class="tvsel_sarjateksti"></div>
! # </div>
! # </div>
! # ...
! # </td>
#
# First entry is always at $today.
--- 100,136 ----
# Programmes for a channel can be found in a separate <td> node
#
! # <table class="ohjelmakartta" ...>
! # <tbody>
! # ...
! # <td class="yle1">
! # <ul>
! # <li class="program">
! # <a href="#" name="mtv3etusivu_tvopas_ohjelmakartta">
! # <span class="starttime">04:00</span>
! # <span class="name">Uutisikkuna</span>
! # <span class="popup">
! # <span class="top">
! # <span class="name">Uutisikkuna</span>
! # <span class="times">
! # <span class="date">20.11.2013 </span>
! # klo 04:00 - 05:55
! # </span>
! # <span class="logo"></span>
! # </span>
! # <span class="description"></span>
! # <span class="bottom">
! # <span class="episodename"><b>Jakso:</b> Keskiviikko</span>
! # <span class="duration"><b>Kesto:</b> 01:55</span>
! # </span>
! # ...
! # </span>
! # </a>
! # </li>
! # ...
! # </ul>
! # </td>
! # ...
! # </tbody>
! # </table>
#
# First entry is always at $today.
***************
*** 162,184 ****
# reduce network traffic!
#
! if (my $container = $root->look_down("class" => "ohjelmisto")) {
my $day = $today;
if (my @cells = $container->look_down("_tag" => "td",
! "class" => qr/^kanava${channel}$/)) {
foreach my $cell (@cells) {
! if (my @programmes = $cell->look_down("class" => qr/^ohjelma/)) {
foreach my $programme (@programmes) {
! my $title = $programme->look_down("class" => qr/^nimi/);
! my $time = $programme->look_down("class" => "tvsel_aika");
if ($title && $time &&
(my ($start, $end) =
! ($time->as_text() =~ /(\d{2}:\d{2})-(\d{2}:\d{2})$/))) {
$title = $title->as_text();
! my($category) = ($programme->attr("class") =~ /^ohjelma\s+(.+)/);
! my $desc = $programme->look_down("class" => "tvsel_kuvaus");
$desc = $desc->as_text() if $desc;
--- 141,166 ----
# reduce network traffic!
#
! if (my $container = $root->look_down("class" => "ohjelmakartta")) {
my $day = $today;
if (my @cells = $container->look_down("_tag" => "td",
! "class" => $channel)) {
!
foreach my $cell (@cells) {
! if (my @programmes = $cell->find("li")) {
foreach my $programme (@programmes) {
! my $title = $programme->look_down("class" => "name");
! my $time = $programme->look_down("class" => "times");
if ($title && $time &&
(my ($start, $end) =
! ($time->as_text() =~ /klo\s+(\d{2}:\d{2})\s+-\s+(\d{2}:\d{2})/))) {
$title = $title->as_text();
! # Strip "hd" and "live" from category
! my($category) = ($programme->attr("class") =~ /^program\s+(.+)/);
! $category =~ s/(?:hd|live)// if defined($category);
! my $desc = $programme->look_down("class" => "description");
$desc = $desc->as_text() if $desc;
***************
*** 191,195 ****
}
! debug(3, "List entry ${channel}.${page} ($start -> $stop) $title");
debug(4, $desc) if defined $desc;
--- 173,177 ----
}
! debug(3, "List entry ${channel} ($start -> $stop) $title");
debug(4, $desc) if defined $desc;
***************
*** 200,217 ****
# Handle optional episode titles
! if (my @episodes = $programme->look_down("class" => "tvsel_jaksonimi")) {
!
! # First episode title is in finnish, second is in english
! foreach my $language (qw(fi en)) {
! last unless my $episode = shift(@episodes);
! # Strip trailing period or parenthesis
! ($episode = $episode->as_text()) =~ s/\.\s*$//;
! $episode = $1 if ($episode =~ /^\s*\(\s*(.+)\s*\)\s*$/);
! # Set episode title if it is NOT the same as the title
! $object->episode($episode, $language)
! unless $episode eq $title;
! }
}
--- 182,193 ----
# Handle optional episode titles
! if (my $episode = $programme->look_down("class" => "episodename")) {
! # Strip starting "Jakso:" text
! ($episode = $episode->as_text()) =~ s/^Jakso:\s+//;
! # Set episode title if it is NOT the same as the title
! $object->episode($episode, "fi")
! unless $episode eq $title;
}
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk