diff options
author | morpheus65535 <[email protected]> | 2021-06-09 13:58:36 -0400 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2021-06-09 13:58:36 -0400 |
commit | 054d1174000cae371ff17fe348db4ce26e71e947 (patch) | |
tree | e58379c25a588a20eff600345f83c20f726b68fb | |
parent | 19983a0f226b9367bd6a9f3f6889474594c5c22a (diff) | |
download | bazarr-054d1174000cae371ff17fe348db4ce26e71e947.tar.gz bazarr-054d1174000cae371ff17fe348db4ce26e71e947.zip |
Added backend API call for upcoming languages/providers filters fix to history stats.
-rw-r--r-- | bazarr/api.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bazarr/api.py b/bazarr/api.py index eb392baaa..ba50f48e0 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -349,6 +349,25 @@ class Badges(Resource): class Languages(Resource): @authenticate def get(self): + history = request.args.get('history') + if history and history not in ['False', 'false', '0']: + languages = list(TableHistory.select(TableHistory.language).dicts()) + languages += list(TableHistoryMovie.select(TableHistoryMovie.language).dicts()) + languages_list = list(set([x['language'].split(':')[0] for x in languages])) + languages_dicts = [] + for language in languages_list: + code2 = None + if len(language) == 2: + code2 = language + elif len(language) == 3: + code2 = alpha2_from_alpha3(language) + + if not any(x['code2'] == code2 for x in languages_dicts): + languages_dicts.append({ + 'code2': code2, + 'name': language_from_alpha2(language) + }) + return jsonify(sorted(languages_dicts, key=itemgetter('name'))) result = TableSettingsLanguages.select(TableSettingsLanguages.name, TableSettingsLanguages.code2, TableSettingsLanguages.enabled)\ @@ -1108,6 +1127,22 @@ class MoviesSubtitles(Resource): class Providers(Resource): @authenticate def get(self): + history = request.args.get('history') + if history and history not in ['False', 'false', '0']: + providers = list(TableHistory.select(TableHistory.provider) + .where(TableHistory.provider != None) + .dicts()) + providers += list(TableHistoryMovie.select(TableHistoryMovie.provider) + .where(TableHistoryMovie.provider != None) + .dicts()) + providers_list = list(set([x['provider'] for x in providers])) + providers_dicts = [] + for provider in providers_list: + providers_dicts.append({ + 'name': provider + }) + return jsonify(data=sorted(providers_dicts, key=itemgetter('name'))) + throttled_providers = list_throttled_providers() providers = list() |