Skip to content

Commit

Permalink
Fix setting of TvMaze show runtime
Browse files Browse the repository at this point in the history
The script tvmaze/show.py had a line which retrieved the episode
duration from the metadata provider, but then assigned it to
num_episodes, which makes no sense. There is no code looking for
num_episodes, but there is code looking for runtime, so the line
has been fixed to assign to runtime.

Using the TVmaze service for metadata lookup, there are rare
cases where the 'runtime' field is empty, but 'averageRuntime'
is not. This happened when looking up metadata for a TV show
called "Everything's Trash". Note that the database entry for
this show was subsequently updated to include the missing
'runtime' field. But on the night it was recorded, and for
several days later, that field was null.

Here's an excerpt of the original metadata for "Everything's Trash":

"id":60518,
"url":"https://www.tvmaze.com/shows/60518/everythings-trash",
"name":"Everything's Trash",
"type":"Scripted",
"language":"English",
"genres":[],
"status":"Running",
"runtime":null,
"averageRuntime":30,

To handle this type of scenario, when the 'runtime' field is null,
read the duration from the 'averageRuntime' field. If both are null,
then avoid trying to cast that value to an integer in tvmaze.py.

Refs: MythTV#654
  • Loading branch information
SteveErl committed Nov 13, 2022
1 parent 35eccb4 commit e48f67b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mythtv/bindings/python/tvmaze/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def __init__(self, data):
self.language = show.get('language')
self.genres = show.get('genres')
self.status = show.get('status')
self.num_episodes = show.get('runtime')
self.runtime = show.get('runtime')
# Sometimes runtime is empty, but averageRuntime is not
if self.runtime is None:
self.runtime = show.get('averageRuntime')
self.seasons = {}
self._episode_list = []
self.specials = {}
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/scripts/metadata/Television/tvmaze.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ def buildSingleItem(inetref, season, episode_id):
elif show_info.premiere_date:
m.releasedate = check_item(m, ("releasedate", show_info.premiere_date))
m.year = check_item(m, ("year", show_info.premiere_date.year))
m.runtime = check_item(m, ("runtime", int(ep_info.duration)))
if ep_info.duration:
m.runtime = check_item(m, ("runtime", int(ep_info.duration)))

for actor in show_info.cast:
try:
Expand Down

0 comments on commit e48f67b

Please sign in to comment.