Fixed multiple episodes subtitles upload to use the first episode number found. #1562

This commit is contained in:
morpheus65535 2021-09-28 06:39:36 -04:00
parent 66585ec765
commit 56ffa722e5

View file

@ -2014,10 +2014,16 @@ class SubtitleNameInfo(Resource):
if 'subtitle_language' in guessit_result:
result['subtitle_language'] = str(guessit_result['subtitle_language'])
if 'episode' in guessit_result:
result['episode'] = int(guessit_result['episode'])
else:
result['episode'] = 0
if 'episode' in guessit_result:
if isinstance(guessit_result['episode'], list):
# for multiple episodes file, choose the first episode number
if len(guessit_result['episode']):
# make sure that guessit returned a list of more than 0 items
result['episode'] = int(guessit_result['episode'][0])
elif isinstance(guessit_result['episode'], (str, int)):
# if single episode (should be int but just in case we cast it to int)
result['episode'] = int(guessit_result['episode'])
if 'season' in guessit_result:
result['season'] = int(guessit_result['season'])