Skip to content

Commit

Permalink
Fix tvmaze.py lookup by timestamp at midnight
Browse files Browse the repository at this point in the history
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: MythTV#717
  • Loading branch information
SteveErl committed Feb 10, 2023
1 parent e237945 commit ac957d6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mythtv/programs/scripts/metadata/Television/tvmaze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit ac957d6

Please sign in to comment.