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
+
@@ -314,14 +330,14 @@
getLanguages();
getEnabledLanguages();
-
+ //test
$('#movieSubtitles').on('click', '.remove_subtitles', function(e){
$(this).tooltip('dispose');
e.preventDefault();
const values = {
- moviePath: $(this).attr("data-moviePath"),
- language: $(this).attr("data-language"),
- subtitlesPath: $(this).attr("data-subtitlesPath"),
+ moviePath: movieDetails['mapped_path'],
+ language: $(this).data("language"),
+ subtitlesPath: $(this).data("subtitlespath"),
radarrId: movieDetails['radarrId'],
tmdbid: movieDetails['tmdbId']
};
@@ -337,19 +353,20 @@
});
});
- $('.get_subtitle').on('click', function(e){
+ $(document).on('click', '.get_subtitle', function(e){
$(this).tooltip('dispose');
e.preventDefault();
const values = {
- moviePath: $(this).attr("data-moviepath"),
- sceneName: $(this).attr("data-scenename"),
+ moviePath: movieDetails['mapped_path'],
+ sceneName: movieDetails['sceneName'],
language: $(this).attr("data-language"),
- hi: $(this).attr("data-hi"),
- forced: $(this).attr("data-forced"),
+ hi: movieDetails['hearing_impaired'],
+ forced: movieDetails['forced'],
radarrId: movieDetails['radarrId'],
title: movieDetails['title']
};
- var button = $(this).closest('button');
+ var button = $(this).closest('button' +
+ '');
$.ajax({
url: "{{ url_for('api.moviesubtitlesdownload') }}",
type: "POST",
@@ -361,15 +378,15 @@
});
});
- $('#manual_search').on('click', function(e){
+ $('#manual_button').on('click', function(e){
e.preventDefault();
$("#movie_title_span").html(movieDetails['title']);
- $("#movie_path_span").html($(this).attr("data-moviePath"));
- $("#movie_scenename_span").html($(this).attr("data-sceneName"));
+ $("#movie_path_span").html(movieDetails['mapped_path']);
+ $("#movie_scenename_span").html(movieDetails['sceneName']);
- moviePath = $(this).attr("data-moviePath");
- sceneName = $(this).attr("data-sceneName");
- language = $(this).attr("data-language");
+ moviePath = movieDetails['mapped_path'];
+ sceneName = movieDetails['sceneName'];
+ language = movieDetails['desired_languages'];
hi = movieDetails['hearing_impaired'];
forced = movieDetails['forced'];
radarrId = movieDetails['radarrId'];
@@ -498,7 +515,7 @@
});
});
- $('#upload_subtitle').on('click', function(e){
+ $('#upload_button').on('click', function(e){
e.preventDefault();
$("#upload_movie_title_span").html(movieDetails['title']);
$('#upload_moviePath').val($(this).data("moviepath"));
@@ -622,13 +639,13 @@
}
});
- $('#movie_history').on('click', function(e){
+ $('#history_button').on('click', function(e){
$(this).tooltip('dispose');
e.preventDefault();
$("#movie_history_title_span").html(movieDetails['title']);
- radarrId = $(this).data("radarrid");
+ radarrId = movieDetails['radarrId'];
$('#movie_history_result').DataTable( {
destroy: true,
@@ -688,13 +705,13 @@
$('#movieMappedPath').text(movieDetails['mapped_path']);
$('#movieMappedPath').attr("data-original-title", movieDetails['mapped_path']);
- var languages = '';
if (movieDetails['languages'] !== 'None') {
+ var languages = '';
movieDetails['languages'].forEach(appendFunc);
}
function appendFunc(value) {
- languages = languages + '' + value.code2 + ' ';
+ languages += '' + value.code2 + ' ';
}
$('#movieSubtitlesLanguages').html(languages);
@@ -702,8 +719,30 @@
$('#movieForced').text('Forced: ' + movieDetails['forced']);
$('#movieDescription').text(movieDetails['overview']);
+ if (movieDetails['missing_subtitles'] !== 'None') {
+ var missing_languages = '';
+ movieDetails['missing_subtitles'].forEach(missingAppendFunc);
+ }
+
+ function missingAppendFunc(value) {
+ missing_languages += ' ';
+ }
+
+ $('#missingSubtitles').html(missing_languages);
+
$('[data-toggle="tooltip"]').tooltip({html: true});
+ if (movieDetails['desired_languages'] == '[]') {
+ $('#search_button').hide();
+ $('#manual_button').hide();
+ $('#upload_button').hide();
+ } else {
+ $('#search_button').show();
+ $('#manual_button').show();
+ $('#upload_button').show();
+ }
+
+
var table = $('#movieSubtitles').DataTable({
destroy: true,
language: {
@@ -733,6 +772,15 @@
return '' + data['name'] + '';
}
}
+ },
+ { "data" : null,
+ "render": function(data) {
+ if (data['path']) {
+ return '';
+ } else {
+ return '';
+ }
+ }
}
]
});