From 5c2651ba5610629365770749a4f272c8196e218e Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Sat, 7 Nov 2020 12:18:09 +0800 Subject: [PATCH 1/2] Update backend API to only send requirement info --- bazarr/api.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bazarr/api.py b/bazarr/api.py index 55659871a..b0273fde3 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -557,9 +557,22 @@ class SubtitleNameInfo(Resource): opts = dict() opts['type'] = 'episode' result = guessit(name, options=opts) + + res = dict() + if result['episode'] is not None: + res['episode'] = result['episode'] + else: + res['episode'] = 0 + + if result['season'] is not None: + res['season'] = result['season'] + else: + res['season'] = 0 + if 'subtitle_language' in result: - result['subtitle_language'] = str(result['subtitle_language']) - return jsonify(data=result) + res['subtitle_language'] = str(result['subtitle_language']) + + return jsonify(data=res) else: return '', 400 From 5e5b09ed8c7d7dc9509667353657fa590b424605 Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Sat, 7 Nov 2020 12:31:14 +0800 Subject: [PATCH 2/2] Fix some horrible if statement --- bazarr/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bazarr/api.py b/bazarr/api.py index b0273fde3..2b4745814 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -559,12 +559,12 @@ class SubtitleNameInfo(Resource): result = guessit(name, options=opts) res = dict() - if result['episode'] is not None: + if 'episode' in result: res['episode'] = result['episode'] else: res['episode'] = 0 - if result['season'] is not None: + if 'season' in result: res['season'] = result['season'] else: res['season'] = 0