xmltv/grab/uk_rt tv_grab_uk_rt, 1.35, 1.36 prog_titles_to_process, 1.496, 1.497

Nick Morrott <[email protected]>
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-serv28946/grab/uk_rt

Modified Files:
	tv_grab_uk_rt prog_titles_to_process 
Log Message:
Add a new fxup routine to allow arbitrary text to be removed from a programme's subtitle. This routine is less specific than the current type 7 but should allow common text to be removed from a subtitle automatically without the need for multiple type 7 fixups for the same title

Index: prog_titles_to_process
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/uk_rt/prog_titles_to_process,v
retrieving revision 1.496
retrieving revision 1.497
diff -C2 -d -r1.496 -r1.497
*** prog_titles_to_process	1 Dec 2013 05:17:45 -0000	1.496
--- prog_titles_to_process	1 Dec 2013 10:09:35 -0000	1.497
***************
*** 84,88 ****
  #     be left empty but the field itself must be present.
  #
! # 11) The text in the second fileld contains a programme 'brand' and a new title to
  #     be extracted from subtitle field and promoted to programme titlei, replacing
  #     the brand title. These fields are separated by a tilde (~).
--- 84,88 ----
  #     be left empty but the field itself must be present.
  #
! # 11) The text in the second field contains a programme 'brand' and a new title to
  #     be extracted from subtitle field and promoted to programme titlei, replacing
  #     the brand title. These fields are separated by a tilde (~).
***************
*** 93,96 ****
--- 93,101 ----
  #     genre.
  #
+ # 13) The text in the second field contains a programme title and arbitrary text to
+ #     be removed from the start/end of the programme's subtitle, separated by a
+ #     tilde (~). If the text to be removed precedes or follows a colon/hyphen, the
+ #     colon/hyphen is removed also.
+ #
  # Non-title information to remove from beginning of titles
  # Works with original title details seen in source
***************
*** 6070,6071 ****
--- 6075,6080 ----
  12|The Best of Ed Sullivan~Entertainment
  12|The Hobbit Special~Entertainment
+ #
+ # Arbitrary text to be removed from start/end of given programme's subtitle.
+ #
+ 13|Dispatches~Channel 4 Dispatches

Index: tv_grab_uk_rt
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/uk_rt/tv_grab_uk_rt,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** tv_grab_uk_rt	1 Dec 2013 05:59:07 -0000	1.35
--- tv_grab_uk_rt	1 Dec 2013 10:09:35 -0000	1.36
***************
*** 213,217 ****
  my %replacement_episodes;     # key = title, value = hash (where key = old ep, value = new ep)
  my %replacement_cats;         # key = title, value = category
- my %replacement_cats_film;    # key = title, value = category
  my %replacement_title_eps;    # key = 'old_title . '|' . old_ep', value = (new_title, new_ep)
  my %replacement_title_desc;   # key = 'old_title . '|' . old_ep' . '|' . 'old_desc', value = (new_title, new_ep)
--- 213,216 ----
***************
*** 220,223 ****
--- 219,224 ----
  my %replacement_ep_from_desc; # key = title, value = hash (where key = desc, value = new ep)
  my %demoted_title;            # key = title, value = title
+ my %replacement_cats_film;    # key = title, value = category
+ my %subtitle_remove_text;     # key = title, value = hash (where key/value = text to remove)
  my %uc_prog_titles;           # key = title, value = title
  my %new_title_in_subtitle_fixed; # key = 'title . '|' . episode', value = hashref (keys are title and episode)
***************
*** 1603,1606 ****
--- 1604,1619 ----
                  next PROG_TITLE_ENTRY;
              }
+             elsif ($code eq '13') {
+                 my @fields = split( /~/, $process_text, 2);
+                 if (scalar @fields != 2) {
+                     t("[13] Invalid number of fields (need 2) in processing text: '" . $process_text . "'");
+                     next PROG_TITLE_ENTRY;
+                 }
+                 my( $title, $text_to_remove ) = @fields;
+                 push @{$subtitle_remove_text{$title}}, $text_to_remove;
+                 t("[13] Will remove text '" . $text_to_remove . "' from subtitle for title '" . $title . "'");
+                 $have_title_data = 1;
+                 next PROG_TITLE_ENTRY;
+             }
              else {
                  t("Unknown code seen in prog_titles_to_process file,"
***************
*** 2399,2402 ****
--- 2412,2419 ----
      # Next, process subtitles to make them consistent
      #
+     # Remvoe text from programme subtitles (type = 13)
+     if (! $prog->{'_subtitles_processed'}) {
+         process_subtitle_remove_text($prog);
+     }
      # Look for inconsistent programme subtitles (type = 7)
      if (! $prog->{'_subtitles_processed'}) {
***************
*** 3281,3284 ****
--- 3298,3331 ----
  }
  
+ # Process text to remove from subtitles. The %subtitle_remove_text data structure
+ # is a hash of arrays.
+ #
+ sub process_subtitle_remove_text {
+     my $prog = shift;
+ 
+     if ($have_title_data && %subtitle_remove_text && defined $prog->{'_episode'}) {
+         my $title = $prog->{'_title'};
+         my $episode = $prog->{'_episode'};
+         if ($subtitle_remove_text{$title}) {
+             REMOVE_TEXT:
+             foreach my $remove_text (sort @{$subtitle_remove_text{$title}}) {
+                 if ($prog->{'_episode'} =~ m/^(\Q$remove_text\E)(?:\s*:|\s*-|\s+)\s*(.*)$/) {
+                     $prog->{'_episode'} = $2;
+                     t("      Removed text '" . $remove_text . "' from subtitle for title '" . $prog->{'_title'} . "'");
+                     $prog->{'_subtitles_processed'} = 1;
+                     last REMOVE_TEXT;
+                 }
+                 # We need a non-greedy match at the start of the subtitle
+                 elsif ($prog->{'_episode'} =~ m/^(.*?)\s*(?::|-)?\s*(\Q$remove_text\E)$/) {
+                     $prog->{'_episode'} = $1;
+                     t("      Removed text '" . $remove_text . "' from subtitle for title '" . $prog->{'_title'} . "'");
+                     $prog->{'_subtitles_processed'} = 1;
+                     last REMOVE_TEXT;
+                 }
+             }
+         }
+     }
+ }
+ 
  # Replace an inconsistent or missing episode subtitle based a given description.
  # The description should therefore be unique for each episode of the programme.


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.