- # sort seasons by index by default (they´re coming back unsorted from the api)
- seasons_sorted = []
- for season_id in season_list:
- seasons_sorted.append(int(season_list[season_id]['idx']))
- seasons_sorted.sort()
- return self.kodi_helper.build_season_listing(seasons_sorted=seasons_sorted, season_list=season_list, build_url=self.build_url)
+
+ # Extract episode numbers and associated keys.
+ d = [(v['idx'], k) for k, v in season_list.items()]
+
+ # sort seasons by index by default (they´re coming back unsorted from the api)
+ seasons_sorted = [season_list[k] for (_, k) in sorted(d)]
+
+ for season in seasons_sorted:
+ season['tvshowtitle'] = tvshowtitle
+
+ return self.kodi_helper.build_season_listing(seasons_sorted=seasons_sorted, build_url=self.build_url)