Fix Autorenumber

This commit is contained in:
Alhaziel01
2021-03-03 12:15:13 +01:00
parent 6b909cfefc
commit bb202f3dd4
2 changed files with 11 additions and 4 deletions

View File

@@ -1454,7 +1454,14 @@ class Tmdb(object):
def get_list_episodes(self):
url = 'https://api.themoviedb.org/3/tv/{id}?api_key=a1ab8b8669da03637a4b98fa39c39228&language={lang}'.format(id=self.busqueda_id, lang=self.busqueda_idioma)
results = requests.get(url).json().get('seasons', [])
return results if 'Error' not in results else []
seasons = []
if results and 'Error' not in results:
for season in results:
url = 'https://api.themoviedb.org/3/tv/{id}/season/{season}?api_key=a1ab8b8669da03637a4b98fa39c39228&language={lang}'.format(id=self.busqueda_id, season=season['season_number'], lang=self.busqueda_idioma)
try: start_from = requests.get(url).json()['episodes'][0]['episode_number']
except: start_from = 1
seasons.append({'season_number':season['season_number'], 'episode_count':season['episode_count'], 'start_from':start_from})
return seasons
def get_videos(self):
"""

View File

@@ -191,20 +191,20 @@ class autorenumber():
seasons =[]
groupedSeasons = tmdb.get_group(self.group.replace('\n','').split('/')[-1])
for groupedSeason in groupedSeasons:
seasons.append({'season_number':groupedSeason['order'], 'episode_count':len(groupedSeason['episodes'])})
seasons.append({'season_number':groupedSeason['order'], 'episode_count':len(groupedSeason['episodes']), 'start_from':groupedSeason['episodes'][0]['episode_number']})
else:
seasons = tmdb.Tmdb(id_Tmdb=self.id).get_list_episodes()
count = 0
for season in seasons:
s = season['season_number']
c = season['episode_count']
fe = season['start_from']
self.seasonsdict[str(s)] = c
if s > 0:
for e in range(1, c + 1):
count += 1
self.epdict[count] = '{}x{:02d}'.format(s,e)
self.epdict[count] = '{}x{:02d}'.format(s, e + fe - 1)
if self.item.renumber or self.manual:
self.item.renumber = False