xmltv/grab/uk_rt tv_grab_uk_rt,1.46,1.47

Nick Morrott <[email protected]> Fri, 18 Mar 2016 01:33:30 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/uk_rt
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv12195/grab/uk_rt

Modified Files:
	tv_grab_uk_rt 
Log Message:
Improvements to credits handling:

* handle occurences of the delimiter (*) in role or actor name
* treat occurences of a missing role as an actor credit


Index: tv_grab_uk_rt
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/uk_rt/tv_grab_uk_rt,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** tv_grab_uk_rt	22 Aug 2015 00:54:26 -0000	1.46
--- tv_grab_uk_rt	18 Mar 2016 01:33:28 -0000	1.47
***************
*** 2723,2727 ****
      #
      # a) pairings of 'character*actor' with subsequent pairings
!     #    separated by '|' - '*' does not appear in any text
      # b) a comma separated list of actors with no character details
      #
--- 2723,2728 ----
      #
      # a) pairings of 'character*actor' with subsequent pairings
!     #    separated by '|' - the single '*' delimiter char should only appear
!     #    in text once but runs of '*' may additionally be seen
      # b) a comma separated list of actors with no character details
      #
***************
*** 2750,2755 ****
              my $seen_valid_roles = 0;
              my $seen_actor_roles = 0;
  
!             my @crew = ();
              my @actors = ();
  
--- 2751,2758 ----
              my $seen_valid_roles = 0;
              my $seen_actor_roles = 0;
+             my $seen_actor_missing_roles = 0;
  
!             my @given_crew = (); # as given in the listings
!             my @valid_crew = (); # after mapping to valid XMLTV roles
              my @actors = ();
  
***************
*** 2758,2763 ****
              foreach my $entry (@castlist) {
  
!                 # Check for bad cast entries
!                 next ENTRY if ($entry !~ m/^[^*]+[*]/);
  
                  # Populate cast list against known production roles if possible,
--- 2761,2782 ----
              foreach my $entry (@castlist) {
  
!                 $entry =~ s/^\s+//;
!                 $entry =~ s/\s+$//;
! 
!                 # Check for missing '*' separator in this entry
!                 if ($entry !~ m/[*]/) {
!                     t("    Missing separator in credits (entry: $entry), skipping");
!                     next ENTRY;
!                 }
!                 # Don't allow a missing crew/actor name (e.g. "Director*")
!                 if ($entry !~ m/[*][^*]+$/) {
!                     t("    Found empty credits name (entry: $entry), skipping");
!                     next ENTRY;
!                 }
!                 # Allow a missing crew role or character name (e.g. "*Patton Oswalt")
!                 if ($entry !~ m/^[^*]+[*]/) {
!                     t("    Missing credits role (entry: $entry), treating as actor entry");
!                     $entry = "MISSING_ROLE" . $entry;
!                 }
  
                  # Populate cast list against known production roles if possible,
***************
*** 2771,2775 ****
                  # roles, or ii) assign them as acting roles
                  #
!                 my ($given_role, $name) = split /\*/, $entry;
  
                  # Replace any actor given as Himself/Herself with the
--- 2790,2794 ----
                  # roles, or ii) assign them as acting roles
                  #
!                 my ($given_role, $name) = $entry =~ m/^(\S.*[^*])\*([^*].*)$/;
  
                  # Replace any actor given as Himself/Herself with the
***************
*** 2779,2800 ****
                  }
  
!                 $given_role = get_valid_xmltv_role($given_role);
  
!                 if (grep {$given_role =~ /^$_$/i} @valid_roles) {
!                     t("    Found valid crew role: " . $given_role);
!                     push @crew, [ $given_role, $name ];
!                     # push @{$p->{credits}{$given_role}}, [$name];
                      $seen_valid_roles++;
                  }
!                 elsif ($seen_valid_roles >= 1 && $seen_actor_roles == 0) {
                      # It's not a role that we currently handle, but we've
                      # seen other crew roles, so let's remember it
!                     # t("    Found possible crew role: " . $given_role);
!                     $seen_roles{$given_role}++;
                  }
                  else {
!                     t("    Found possible actor role: " . $given_role . " - " . $name);
                      push @actors, [ $given_role, $name ];
-                     # push @{$p->{credits}{'actor'}}, [$name, $given_role];
                      $seen_actor_roles++;
                  }
--- 2798,2823 ----
                  }
  
!                 my $valid_role = get_valid_xmltv_role($given_role);
  
!                 if (grep {$valid_role =~ /^$_$/i} @valid_roles) {
!                     t("    Found valid crew role: " . $valid_role);
!                     push @given_crew, [ $given_role, $name ];
!                     push @valid_crew, [ $valid_role, $name ];
                      $seen_valid_roles++;
                  }
!                 elsif ($given_role eq "MISSING_ROLE") {
!                     t("    Found possible actor entry without role: " . $name);
!                     push @actors, [ $given_role, $name ];
!                     $seen_actor_missing_roles++;
!                 }
!                 elsif ($seen_valid_roles >= 1 && $seen_actor_roles == 0 && $seen_actor_missing_roles == 0) {
                      # It's not a role that we currently handle, but we've
                      # seen other crew roles, so let's remember it
!                     # t("    Found possible crew role: " . $valid_role);
!                     $seen_roles{$valid_role}++ if $given_role ne "MISSING_ROLE";
                  }
                  else {
!                     t("    Found possible actor entry: " . $given_role . " - " . $name);
                      push @actors, [ $given_role, $name ];
                      $seen_actor_roles++;
                  }
***************
*** 2802,2813 ****
  
              # Prefer actors if we've seen 2 or fewer crew roles
!             if ($seen_actor_roles >= 1 && $seen_valid_roles <=2) {
!                 foreach my $actor ((@actors, @crew)) {
!                     push @{$p->{credits}{'actor'}}, [encode($xml_encoding, $actor->[1]), encode($xml_encoding, $actor->[0])];
                  }
              }
              # Otherwise, prefer crew roles
              else {
!                 foreach my $actor (@crew) {
                      push @{$p->{credits}{$actor->[0]}}, encode($xml_encoding, $actor->[1]);
                  }
--- 2825,2836 ----
  
              # Prefer actors if we've seen 2 or fewer crew roles
!             if (($seen_actor_roles + $seen_actor_missing_roles >= 1) && $seen_valid_roles <=2) {
!                 foreach my $actor ((@actors, @given_crew)) {
!                     push @{$p->{credits}{'actor'}}, [encode($xml_encoding, $actor->[1]), ($actor->[0] eq "MISSING_ROLE" ? undef : encode($xml_encoding, $actor->[0]))];
                  }
              }
              # Otherwise, prefer crew roles
              else {
!                 foreach my $actor (@valid_crew) {
                      push @{$p->{credits}{$actor->[0]}}, encode($xml_encoding, $actor->[1]);
                  }
***************
*** 2816,2820 ****
--- 2839,2848 ----
          # Next we check for CSV-style actor entries
          elsif ($cast =~ tr/,//) {
+             ENTRY:
              foreach my $actor (split /,/, $cast) {
+                 if ($actor !~ m/\S/) {
+                     t("    Found empty actor entry, skipping");
+                     next ENTRY;
+                 }
                  push @{$p->{credits}{actor}}, [ encode($xml_encoding, $actor) ];
              }


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140