mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-25 01:02:19 +00:00
Added backend API call for upcoming languages/providers filters fix to history stats.
This commit is contained in:
parent
19983a0f22
commit
054d117400
1 changed files with 35 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue