xmltv/grab/sd_json tv_grab_sd_json,1.9,1.10

Kevin Groeneveld <[email protected]> Sun, 05 Jun 2016 20:14:50 +0000
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/sd_json
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20643

Modified Files:
	tv_grab_sd_json 
Log Message:
tv_grab_sd_json: Allow configuration of previously-shown format.
    
By the XMLTV spec the time should not be included (unless it is actually
known). Older versions of MythTV require it otherwise MythTV assumes UTC
which causes the wrong date to be stored. However there have been reports
that including the time breaks newer versions of MythTV. Lets make it
configurable to accommodate both cases.


Index: tv_grab_sd_json
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/sd_json/tv_grab_sd_json,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** tv_grab_sd_json	28 May 2016 01:56:20 -0000	1.9
--- tv_grab_sd_json	5 Jun 2016 20:14:48 -0000	1.10
***************
*** 96,100 ****
  	[ 'mythtv',  '%s',                           'MythTV Internal DD Grabber Format' ],
  );
! my $channel_id_format;
  
  my $cache_schema = 1;
--- 96,104 ----
  	[ 'mythtv',  '%s',                           'MythTV Internal DD Grabber Format' ],
  );
! 
! my @previously_shown_formats = (
! 	[ 'date',     '%Y%m%d',          'Date Only' ],
! 	[ 'datetime', '%Y%m%d%H%M%S %z', 'Date And Time' ],
! );
  
  my $cache_schema = 1;
***************
*** 134,150 ****
  });
  
! # set channel_id_format based on config file
! if($conf->{'channel-id-format'}->[0]) {
! 	for my $format (@channel_id_formats) {
! 		if($format->[0] eq $conf->{'channel-id-format'}->[0]) {
! 			$channel_id_format = $format->[1];
! 			last;
  		}
  	}
  }
! if(!$channel_id_format) {
! 	print STDERR "Valid channel ID format not specified in config, using default.\n" unless $quiet;
! 	$channel_id_format = $channel_id_formats[0]->[1];
! }
  
  # default days to largish value
--- 138,164 ----
  });
  
! sub get_conf_format {
! 	my ($config, $options, $text) = @_;
! 	my $result;
! 
! 	if($conf->{$config}->[0]) {
! 		for my $format (@{$options}) {
! 			if($format->[0] eq $conf->{$config}->[0]) {
! 				$result = $format->[1];
! 				last;
! 			}
  		}
  	}
+ 
+ 	if(!$result) {
+ 		print STDERR "Valid $text not specified in config, using default.\n" unless $quiet;
+ 		$result = $options->[0]->[1];
+ 	}
+ 
+ 	return $result;
  }
! 
! my $channel_id_format = get_conf_format('channel-id-format', \@channel_id_formats, 'channel ID format');
! my $previously_shown_format = get_conf_format('previously-shown-format', \@previously_shown_formats, 'previously shown format');
  
  # default days to largish value
***************
*** 387,390 ****
--- 401,417 ----
  		$w->end_selectone();
  
+ 		$w->start_selectone({
+ 			id => 'previously-shown-format',
+ 			description => [ [ 'As the JSON data only includes the previously shown date normally the XML output should only have the date. However some programs such as older versions of MythTV also need a time.', 'en' ] ],
+ 			title => [ [ 'Select previously shown format', 'en' ] ],
+ 		});
+ 		for my $format (@previously_shown_formats) {
+ 			$w->write_option({
+ 				value => $format->[0],
+ 				text  => [ [ $format->[2], 'en' ] ],
+ 			});
+ 		}
+ 		$w->end_selectone();
+ 
  		$w->end('login');
  	}
***************
*** 1192,1201 ****
  		my $dt = DateTime::Format::ISO8601->parse_datetime($date);
  
! 		# mythtv needs full date and time even though xmltv only requires date.
! 		# No timezone is specified in the source data so lets assume the local
! 		# timezone otherwise UTC will be assumed which can cause mythtv to
! 		# store the wrong date.
  		$dt->set_time_zone('local');
! 		$previously_shown{'start'} = $dt->strftime('%Y%m%d');
  	}
  
--- 1219,1230 ----
  		my $dt = DateTime::Format::ISO8601->parse_datetime($date);
  
! 		# Older versions of mythtv needs full date and time even though xmltv
! 		# only requires date. No timezone is specified in the source data so
! 		# lets assume the local timezone otherwise UTC will be assumed which
! 		# can cause mythtv to store the wrong date. Whether we actually
! 		# include the time in the output depends on the selected format in
! 		# the config file.
  		$dt->set_time_zone('local');
! 		$previously_shown{'start'} = $dt->strftime($previously_shown_format);
  	}
  


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e