xmltv/lib Augment.pm,1.2,1.3
Geoff <[email protected]> Thu, 10 Dec 2015 09:00:43 +0000
| Newsgroups | gmane.comp.tv.xmltv.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xmltv/xmltv/lib
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2188
Modified Files:
Augment.pm
Log Message:
Allow wildcards in rule #6 title matching
Index: Augment.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/lib/Augment.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Augment.pm 10 Dec 2015 08:46:35 -0000 1.2
--- Augment.pm 10 Dec 2015 09:00:41 -0000 1.3
***************
*** 139,143 ****
use Encode;
! our $VERSION = 0.001001;
use base 'Exporter';
--- 139,143 ----
use Encode;
! our $VERSION = 0.005068;
use base 'Exporter';
***************
*** 2133,2136 ****
--- 2133,2142 ----
out: "Antiques Roadshow / " category "Entertainment" + "Arts" + "Shopping"
+ You can specify a wildcard with the title by using %% which represents any number
+ of characters.
+ So for example "News%%" will match "News", "News and Weather", "Newsnight", etc.
+ But be careful; "%%News%%" will also match "John Craven's Newsround", "Eurosport News",
+ "Election Newsroom Live", "Have I Got News For You", "Scuzz Meets Jason Newsted", etc.
+
=cut
***************
*** 2160,2168 ****
LOOP:
! foreach (@{ $self->{'rules'}->{$ruletype}->{$idx} }) {
my ( $line, $key, $value ) = ( $_->{'line'}, $_->{'key'}, $_->{'value'} );
_d(4,"\t $line, $key, $value");
! if ($prog->{'_title'} eq $key) {
#_d(4,dd(4,$prog->{'_genres'}));
--- 2166,2178 ----
LOOP:
! # append any rules which start with a wildcard
! # (todo: this doesn't work for "x%%...")
! foreach ( @{ $self->{'rules'}->{$ruletype}->{$idx} } , @{ $self->{'rules'}->{$ruletype}->{'%%'} } ) {
my ( $line, $key, $value ) = ( $_->{'line'}, $_->{'key'}, $_->{'value'} );
_d(4,"\t $line, $key, $value");
! my $_key = $self->replace_wild($key);
!
! if ($prog->{'_title'} =~ m/$_key/i ) {
#_d(4,dd(4,$prog->{'_genres'}));
***************
*** 2189,2193 ****
--- 2199,2208 ----
l(sprintf("\t Replaced genre(s) '%s' with '%s' (#%s.%s)",
$old, $new, $ruletype, $line));
+ # if using a wildcard, we could mod many progs with this one rule so let's report all of them
+ if ($key =~ m/%%/) {
+ $self->add_to_audit ($me, $key.'~'.$prog->{'_title'}, $prog);
+ } else {
$self->add_to_audit ($me, $key, $prog);
+ }
$prog->{'_subtitles_processed'} = 1;
***************
*** 3503,3506 ****
--- 3518,3532 ----
+ # Replace our wildcards ("%%") in the rule's key
+ #
+ sub replace_wild () {
+ my ($self, $key) = @_;
+ if ($key =~ m/%%/) {
+ $key =~ s/%%/\.\*\?/g
+ }
+ return "^$key\$";
+ }
+
+
# Create an xmltv_ns compatible episode number.
# Automatically resets the base to zero on series/episode/part numbers
------------------------------------------------------------------------------