From ac957d6785f0aa0a9238f761202660310bf5e60b Mon Sep 17 00:00:00 2001 From: Steve Erlenborn <1751095+SteveErl@users.noreply.github.com> Date: Thu, 9 Feb 2023 22:43:20 -0600 Subject: [PATCH] Fix tvmaze.py lookup by timestamp at midnight From https://www.tvmaze.com/faq/15/episodes : To ensure that the episode airdates on TVmaze are in line with the dates used by TV guides and listings worldwide, episodes that start airing at or after midnight but before 5:00 are considered part of the previous day. This commit checks for a starting time prior to 5am. If found, the date of the previous day will be used when searching for episodes. Refs: #717 --- .../programs/scripts/metadata/Television/tvmaze.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mythtv/programs/scripts/metadata/Television/tvmaze.py b/mythtv/programs/scripts/metadata/Television/tvmaze.py index c3243b49e2a..b8a89621af4 100755 --- a/mythtv/programs/scripts/metadata/Television/tvmaze.py +++ b/mythtv/programs/scripts/metadata/Television/tvmaze.py @@ -242,8 +242,17 @@ def buildNumbers(args, opts): if dtInTgtZone: # get episode info based on inetref and datetime in target zone try: - #print('get_show_episodes_by_date(', inetref, ',', dtInTgtZone, ')') - episodes = tvmaze.get_show_episodes_by_date(inetref, dtInTgtZone) + # From https://www.tvmaze.com/faq/15/episodes : + # To ensure that the episode airdates on TVmaze are + # in line with the dates used by TV guides and listings + # worldwide, episodes that start airing at or after + # midnight but before 5:00 are considered part of the + # previous day. + if dtInTgtZone.hour < 5: + episodes = tvmaze.get_show_episodes_by_date(inetref, dtInTgtZone - timedelta(hours=5)) + else: + episodes = tvmaze.get_show_episodes_by_date(inetref, dtInTgtZone) + except SystemExit: episodes = [] time_match_list = []