diff --git a/bazarr/api.py b/bazarr/api.py index 32e9c9011..5081292b1 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -68,6 +68,10 @@ class Series(Resource): if seriesId: result = database.execute("SELECT * FROM table_shows WHERE sonarrSeriesId=? ORDER BY sortTitle ASC LIMIT ? " "OFFSET ?", (seriesId, length, start)) + desired_languages = database.execute("SELECT languages FROM table_shows WHERE sonarrSeriesId=?", + (seriesId,), only_one=True)['languages'] + if desired_languages == "None": + desired_languages = '[]' else: result = database.execute("SELECT * FROM table_shows ORDER BY sortTitle ASC LIMIT ? OFFSET ?", (length, start)) for item in result: @@ -109,6 +113,12 @@ class Series(Resource): item.update({"episodeFileCount": database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE " "sonarrSeriesId=?", (item['sonarrSeriesId'],), only_one=True)['count']}) + + # Add the series desired subtitles language code2 + try: + item.update({"desired_languages": desired_languages}) + except NameError: + pass return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=result) @@ -445,6 +455,10 @@ class Movies(Resource): if moviesId: result = database.execute("SELECT * FROM table_movies WHERE radarrId=? ORDER BY sortTitle ASC LIMIT ? " "OFFSET ?", (moviesId, length, start)) + desired_languages = database.execute("SELECT languages FROM table_movies WHERE radarrId=?", + (moviesId,), only_one=True)['languages'] + if desired_languages == "None": + desired_languages = '[]' else: result = database.execute("SELECT * FROM table_movies ORDER BY sortTitle ASC LIMIT ? OFFSET ?", (length, start)) @@ -490,7 +504,7 @@ class Movies(Resource): if item['missing_subtitles']: item.update({"missing_subtitles": ast.literal_eval(item['missing_subtitles'])}) for i, subs in enumerate(item['missing_subtitles']): - language = subs[0].split(':') + language = subs.split(':') item['missing_subtitles'][i] = {"name": language_from_alpha2(language[0]), "code2": language[0], "code3": alpha3_from_alpha2(language[0]), @@ -502,6 +516,12 @@ class Movies(Resource): # Confirm if path exist item.update({"exist": os.path.isfile(mapped_path)}) + + # Add the movie desired subtitles language code2 + try: + item.update({"desired_languages": desired_languages}) + except NameError: + pass return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=result) diff --git a/views/episodes.html b/views/episodes.html index 119e641c2..78f2cadd0 100644 --- a/views/episodes.html +++ b/views/episodes.html @@ -842,6 +842,12 @@ $('#seriesForced').text('Forced: ' + seriesDetails['forced']); $('#seriesDescription').text(seriesDetails['overview']); + if (seriesDetails['desired_languages'] == '[]') { + $('#search_button').hide(); + } else { + $('#search_button').show(); + } + $('[data-toggle="tooltip"]').tooltip({html: true}); }); } diff --git a/views/movie.html b/views/movie.html index b3744d8a4..4b68b5650 100644 --- a/views/movie.html +++ b/views/movie.html @@ -54,6 +54,18 @@
Search
+ + + {% endblock bcleft %} @@ -104,9 +116,13 @@ Subtitles Path Language(s) + +
+
Missing Subtitles
+