mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-02-24 23:07:36 +08:00
WIP
This commit is contained in:
parent
d738bab732
commit
4ce8c55e83
3 changed files with 96 additions and 22 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -54,6 +54,18 @@
|
|||
<div><i class="fas fa-search align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
|
||||
<div class="align-bottom text-themecolor small text-center">Search</div>
|
||||
</button>
|
||||
<button class="btn btn-outline" id="manual_button">
|
||||
<div><i class="fas fa-user align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
|
||||
<div class="align-bottom text-themecolor small text-center">Manual</div>
|
||||
</button>
|
||||
<button class="btn btn-outline" id="upload_button">
|
||||
<div><i class=" fas fa-cloud-upload-alt align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
|
||||
<div class="align-bottom text-themecolor small text-center">Upload</div>
|
||||
</button>
|
||||
<button class="btn btn-outline" id="history_button">
|
||||
<div><i class="fas fa-history align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
|
||||
<div class="align-bottom text-themecolor small text-center">History</div>
|
||||
</button>
|
||||
</div>
|
||||
{% endblock bcleft %}
|
||||
|
||||
|
@ -104,9 +116,13 @@
|
|||
<tr>
|
||||
<th>Subtitles Path</th>
|
||||
<th>Language(s)</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<br>
|
||||
<h5 style="font-weight: 500;">Missing Subtitles</h5>
|
||||
<span id="missingSubtitles"></span>
|
||||
</div>
|
||||
|
||||
<div id="manualSearchModal" class="modal" tabindex="-1" role="dialog">
|
||||
|
@ -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 + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + '">' + value.code2 + '</span> ';
|
||||
languages += '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + '">' + value.code2 + '</span> ';
|
||||
}
|
||||
|
||||
$('#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 += '<button class="get_subtitle btn btn-secondary btn-sm" type="button" data-toggle="tooltip" data-placement="right" data-original-title="' + value.name + '" data-language="' + value.code3 + '">' + value.code2 + ' <i class="fas fa-search"></i></button> ';
|
||||
}
|
||||
|
||||
$('#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 '<span class="badge badge-secondary">' + data['name'] + '</span>';
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "data" : null,
|
||||
"render": function(data) {
|
||||
if (data['path']) {
|
||||
return '<button type="button" class="remove_subtitles close" aria-label="Close" data-toggle="tooltip" data-placement="right" title="Delete Subtitles File" data-language='+data['code3']+' data-subtitlesPath="'+data['path']+'"><span aria-hidden="true">×</span></button>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue