xmltv/grab/eu_epgdata tv_grab_eu_epgdata,1.35,1.36

Jan Schneider <[email protected]>
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/grab/eu_epgdata
In directory vz-cvs-3.sog:/tmp/cvs-serv25865/grab/eu_epgdata

Modified Files:
	tv_grab_eu_epgdata 
Log Message:
Add automatic timezone detection (Andreas Benneke, Request #2799196).


Index: tv_grab_eu_epgdata
===================================================================
RCS file: /cvsroot/xmltv/xmltv/grab/eu_epgdata/tv_grab_eu_epgdata,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** tv_grab_eu_epgdata	8 Jun 2012 13:16:28 -0000	1.35
--- tv_grab_eu_epgdata	8 Jun 2012 13:16:47 -0000	1.36
***************
*** 200,209 ****
  
  our $tz = $conf->{tz}->[0];
! if (not $tz) {
!     $tz = 'local';
! }
! my $start_stop_parser =
!     DateTime::Format::Strptime->new( pattern => '%Y-%m-%d %H:%M:%S',
!                                      time_zone => $tz );
  
  sub config_stage {
--- 200,216 ----
  
  our $tz = $conf->{tz}->[0];
! # country is determined by the filenames downloaded from the server
! # and used to determine the time zone if not specified in the config
! our $country;
! my %country_tz = (
!     'at', 'Europe/Vienna',
!     'ch', 'Europe/Zurich',
!     'de', 'Europe/Berlin',
!     'es', 'Europe/Madrid',
!     'fr', 'Europe/Paris',
!     'it', 'Europe/Rome',
!     'nl', 'Europe/Amsterdam',
! );
! my $start_stop_parser;
  
  sub config_stage {
***************
*** 232,239 ****
          title => [ [ 'Time zone for your EPG data', 'en' ] ],
          description => [ 
!         [ 'Enter your time zone or the time offset from UTC here. 
!         Examples: "local" (your local system timezone), "Europe/Berlin", "+0100". (without quotation marks)',
              'en' ] ],
!         default => 'local',
      } );
  
--- 239,247 ----
          title => [ [ 'Time zone for your EPG data', 'en' ] ],
          description => [ 
!         [ 'Enter the time zone or the time offset from UTC of the data here.
!         Your may omit this to activate automatic detection.
!         Examples: "" (to activate automatic detection), "local" (your local system timezone), "Europe/Berlin", "+0100" (without quotation marks)',
              'en' ] ],
!         default => '',
      } );
  
***************
*** 259,262 ****
--- 267,285 ----
  our $writer = new XMLTV::Writer(%w_args);
  
+ # determine the timezone
+ if (not $tz) {
+     $tz = $country_tz{$country} if $country;
+ }
+ if (not $tz) {
+     warn "Unable to determine country/timezone of data. ",
+          "You may specify tz in your configuration. ",
+          "Falling back to your local system time zone.\n";
+     $tz = 'local';
+ }
+ warn "tz=", $tz, "\n" if $opt->{debug};
+ $start_stop_parser =
+     DateTime::Format::Strptime->new( pattern => '%Y-%m-%d %H:%M:%S',
+                                      time_zone => $tz );
+ 
  prepareinclude($conf,$opt);
  our @xmlfiles = downloadepg($opt->{days},$opt->{offset},$pin);
***************
*** 293,296 ****
--- 316,320 ----
              $channelgroup = sanitize($response->{"_headers"}{"x-epgdata-channelgroup"});
              $filename =~  s/^.*=//;
+             ($country) = ($filename =~ /[^_]*_[^_]*_([^_]*)_[^_]*/) unless $country; # format: xyz########_########_de_qy.zip
  
              warn "filename=", $filename, "\n" if $opt->{debug};


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
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.