Off-by-one in mythtv original airdate when fed with tv_grab_sd_json
Ian Campbell <[email protected]> Sun, 22 May 2016 16:41:13 +0100
| Newsgroups | gmane.comp.tv.xmltv.general |
|---|---|
| Message-ID | <[email protected]> |
Since switching to SD I've noticed that first showings seem to have
their original airdate set to the day before.
Myth has ended up with this:
mysql> select programid,originalairdate,starttime,substring(description,1,35) from program where title like 'Have I Got News For You';
+----------------+-----------------+---------------------+-------------------------------------+
| programid | originalairdate | starttime | substring(description,1,35) |
+----------------+-----------------+---------------------+-------------------------------------+
| EP012601600205 | 2016-05-19 | 2016-05-20 20:00:00 | Gary Lineker hosts, with regular te |
| EP012601600206 | 2016-05-26 | 2016-05-27 20:00:00 | Katherine Ryan hosts, with regular |
That second episode was describe in the XML as:
<programme start="20160527200000 +0000" stop="20160527203000 +0000" channel="24321">
<title>Have I Got News for You</title>
<desc>Katherine Ryan hosts, with regular[...]
[...]
<previously-shown start="20160527000000 +0100" />
In the JSON it was:
"originalAirDate" : "2016-05-27",
I think the issue is the TZ, mythtv is interpreting "20160527000000
+0100" as "20160526230000 +0000" hence the off by one. I think this all
stems from SD only giving a date but
tv_grab_sd_json:get_program_previously_shown fabricating a full
datetime because :
# 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%H%M%S %z');
However judging from
https://github.com/MythTV/mythtv/blob/master/mythtv/programs/mythfilldatabase/xmltvparser.cpp#L122
this has not been true since ff5ab278 in 2013 (released in myth 0.27)
where support for dates without times was added (among other fixes).
https://github.com/MythTV/mythtv/commit/ff5ab27842c522f9e054876a8eb69a51b8c86a2e
I'm running myth 0.28 so this works for me:
diff --git a/grab/sd_json/tv_grab_sd_json
b/grab/sd_json/tv_grab_sd_json
index 9c16f65..71c5d2e 100644
--- a/grab/sd_json/tv_grab_sd_json
+++ b/grab/sd_json/tv_grab_sd_json
@@ -1153,13 +1153,7 @@ sub get_program_previously_shown {
my $date = $details->{'originalAirDate'};
if($date) {
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%H%M%S %z');
+ $previously_shown{'start'} = $dt->strftime('%Y%m%d');
}
if(scalar keys %previously_shown) {
But I suppose that won't work for everyone.
If %H%M%S is always "000000" in this context perhaps offsetting %H by
%z would offset mythtv's adjustment everywhere? i.e if the xml had been
<previously-shown start="20160527010000 +0100" />
I think the answer would have been correct.
Looking at the pre-ff5ab278 mythtv code I'm not convinced it wouldn't
also be correct to explicitly specify the TZ as "UTC" or "+0000",
resulting in a zero offset.
Could also just drop previously-shown from the XML, no information is
better than wrong information IMHO (and my previous grabbers didn't
have it anyway). Especially since xmltv and mythtv don't agree on the
semantics of this field anyway (xmltv has it as the most recent
previous showing, not the original airdate).
Ian.
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
xmltv-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmltv-users