Skip to content

Commit

Permalink
fetch show metadata when building episode scrobble request so that we…
Browse files Browse the repository at this point in the history
… can include the show id's and the correct year
  • Loading branch information
Cornishman committed Dec 8, 2021
1 parent 047a79f commit e122e59
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,7 @@ def build_episode(cls, episode, guid, part):

# Retrieve episode number
season_num, episodes = ModuleManager['matcher'].process(episode)

# If matching only a single episode, scrobble it with just id's
if len(episodes) == 1:
return {
'episode': {
'ids': ids
}
}


if len(episodes) > 0 and part - 1 < len(episodes):
episode_num = episodes[part - 1]
elif len(episodes) > 0:
Expand All @@ -115,16 +107,22 @@ def build_episode(cls, episode, guid, part):
log.warn('Matcher didn\'t return a valid result - season_num: %r, episodes: %r', season_num, episodes)
episode_num = episode.index

# Process guid episode identifier overrides
if guid.season is not None:
season_num = guid.season
# Get the show metadata
if episode.show:
show_metadata = Metadata.get(episode.show.rating_key)
show_ids = Identifier.get_ids(show_metadata.guids, strict=False)

if show_metadata:
show = {
'title': show_metadata.title,
'year': show_metadata.year,

'ids': show_ids
}

# Build request
return {
'show': {
'title': episode.show.title,
'year': episode.year,
},
'show': show,
'episode': {
'title': episode.title,

Expand Down

0 comments on commit e122e59

Please sign in to comment.