Skip to content

Commit

Permalink
Support multiple episodes with same index (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelarnauts committed Jul 23, 2023
1 parent ff46259 commit ea0c88e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion resources/lib/modules/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def show_program_season(self, program, season):
# Show the season that was selected
seasons = [program_obj.seasons[season]]

listing = [Menu.generate_titleitem(e) for s in seasons for e in list(s.episodes.values())]
listing = [Menu.generate_titleitem(e) for s in seasons for e in s.episodes]

# Sort by episode number by default. Takes seasons into account.
kodiutils.show_listing(listing, program_obj.name, content='episodes', sort=['episode', 'duration'])
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/vtmgo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Season:
def __init__(self, number=None, episodes=None, channel=None, legal=None):
"""
:type number: str
:type episodes: dict[int, Episode]
:type episodes: list[Episode]
:type channel: str
:type legal: str
"""
Expand Down
10 changes: 5 additions & 5 deletions resources/lib/vtmgo/vtmgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def get_program(self, program_id, cache=CACHE_AUTO):

seasons = {}
for item_season in program.get('seasonIndices', []):
episodes = {}
episodes = []

# Fetch season
season_response = util.http_get(API_ENDPOINT + '/%s/detail/%s?selectedSeasonIndex=%s' % (self._mode(), program_id, item_season),
Expand All @@ -265,7 +265,7 @@ def get_program(self, program_id, cache=CACHE_AUTO):
season = json.loads(season_response.text).get('selectedSeason')

for item_episode in season.get('episodes', []):
episodes[item_episode.get('index')] = Episode(
episodes.append(Episode(
episode_id=item_episode.get('id'),
program_id=program_id,
program_name=program.get('name'),
Expand All @@ -283,7 +283,7 @@ def get_program(self, program_id, cache=CACHE_AUTO):
aired=item_episode.get('broadcastTimestamp'),
progress=item_episode.get('playerPositionSeconds', 0),
watched=item_episode.get('doneWatching', False),
)
))

seasons[item_season] = Season(
number=item_season,
Expand Down Expand Up @@ -314,7 +314,7 @@ def get_episode_from_program(program, episode_id):
:rtype Episode
"""
for season in list(program.seasons.values()):
for episode in list(season.episodes.values()):
for episode in season.episodes:
if episode.episode_id == episode_id:
return episode

Expand All @@ -331,7 +331,7 @@ def get_next_episode_from_program(program, season, number):
next_season_episode = None

# First, try to find a match in the current season
for episode in [e for s in list(program.seasons.values()) for e in list(s.episodes.values())]:
for episode in [e for s in list(program.seasons.values()) for e in s.episodes]:
if episode.season == season and episode.number == number + 1:
return episode
if episode.season == season + 1 and episode.number == 1:
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def modify_xml(file, version, news, python=None):
if os.path.isfile(f):
shutil.copy(f, dest)
else:
shutil.copytree(f, os.path.join(dest, f))
shutil.copytree(f, os.path.join(dest, f), dirs_exist_ok=True)

# Update addon.xml for matrix and create zip
modify_xml(os.path.join(dest, 'addon.xml'), addon_info['version'] + '+matrix.1', addon_info['news'], '3.0.0')
Expand Down

0 comments on commit ea0c88e

Please sign in to comment.