mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-02-25 07:15:56 +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:
|
if seriesId:
|
||||||
result = database.execute("SELECT * FROM table_shows WHERE sonarrSeriesId=? ORDER BY sortTitle ASC LIMIT ? "
|
result = database.execute("SELECT * FROM table_shows WHERE sonarrSeriesId=? ORDER BY sortTitle ASC LIMIT ? "
|
||||||
"OFFSET ?", (seriesId, length, start))
|
"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:
|
else:
|
||||||
result = database.execute("SELECT * FROM table_shows ORDER BY sortTitle ASC LIMIT ? OFFSET ?", (length, start))
|
result = database.execute("SELECT * FROM table_shows ORDER BY sortTitle ASC LIMIT ? OFFSET ?", (length, start))
|
||||||
for item in result:
|
for item in result:
|
||||||
|
@ -109,6 +113,12 @@ class Series(Resource):
|
||||||
item.update({"episodeFileCount": database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE "
|
item.update({"episodeFileCount": database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE "
|
||||||
"sonarrSeriesId=?", (item['sonarrSeriesId'],),
|
"sonarrSeriesId=?", (item['sonarrSeriesId'],),
|
||||||
only_one=True)['count']})
|
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)
|
return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=result)
|
||||||
|
|
||||||
|
|
||||||
|
@ -445,6 +455,10 @@ class Movies(Resource):
|
||||||
if moviesId:
|
if moviesId:
|
||||||
result = database.execute("SELECT * FROM table_movies WHERE radarrId=? ORDER BY sortTitle ASC LIMIT ? "
|
result = database.execute("SELECT * FROM table_movies WHERE radarrId=? ORDER BY sortTitle ASC LIMIT ? "
|
||||||
"OFFSET ?", (moviesId, length, start))
|
"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:
|
else:
|
||||||
result = database.execute("SELECT * FROM table_movies ORDER BY sortTitle ASC LIMIT ? OFFSET ?",
|
result = database.execute("SELECT * FROM table_movies ORDER BY sortTitle ASC LIMIT ? OFFSET ?",
|
||||||
(length, start))
|
(length, start))
|
||||||
|
@ -490,7 +504,7 @@ class Movies(Resource):
|
||||||
if item['missing_subtitles']:
|
if item['missing_subtitles']:
|
||||||
item.update({"missing_subtitles": ast.literal_eval(item['missing_subtitles'])})
|
item.update({"missing_subtitles": ast.literal_eval(item['missing_subtitles'])})
|
||||||
for i, subs in enumerate(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]),
|
item['missing_subtitles'][i] = {"name": language_from_alpha2(language[0]),
|
||||||
"code2": language[0],
|
"code2": language[0],
|
||||||
"code3": alpha3_from_alpha2(language[0]),
|
"code3": alpha3_from_alpha2(language[0]),
|
||||||
|
@ -502,6 +516,12 @@ class Movies(Resource):
|
||||||
|
|
||||||
# Confirm if path exist
|
# Confirm if path exist
|
||||||
item.update({"exist": os.path.isfile(mapped_path)})
|
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)
|
return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=result)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -842,6 +842,12 @@
|
||||||
$('#seriesForced').text('Forced: ' + seriesDetails['forced']);
|
$('#seriesForced').text('Forced: ' + seriesDetails['forced']);
|
||||||
$('#seriesDescription').text(seriesDetails['overview']);
|
$('#seriesDescription').text(seriesDetails['overview']);
|
||||||
|
|
||||||
|
if (seriesDetails['desired_languages'] == '[]') {
|
||||||
|
$('#search_button').hide();
|
||||||
|
} else {
|
||||||
|
$('#search_button').show();
|
||||||
|
}
|
||||||
|
|
||||||
$('[data-toggle="tooltip"]').tooltip({html: true});
|
$('[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><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>
|
<div class="align-bottom text-themecolor small text-center">Search</div>
|
||||||
</button>
|
</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>
|
</div>
|
||||||
{% endblock bcleft %}
|
{% endblock bcleft %}
|
||||||
|
|
||||||
|
@ -104,9 +116,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Subtitles Path</th>
|
<th>Subtitles Path</th>
|
||||||
<th>Language(s)</th>
|
<th>Language(s)</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
|
<br>
|
||||||
|
<h5 style="font-weight: 500;">Missing Subtitles</h5>
|
||||||
|
<span id="missingSubtitles"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="manualSearchModal" class="modal" tabindex="-1" role="dialog">
|
<div id="manualSearchModal" class="modal" tabindex="-1" role="dialog">
|
||||||
|
@ -314,14 +330,14 @@
|
||||||
getLanguages();
|
getLanguages();
|
||||||
getEnabledLanguages();
|
getEnabledLanguages();
|
||||||
|
|
||||||
|
//test
|
||||||
$('#movieSubtitles').on('click', '.remove_subtitles', function(e){
|
$('#movieSubtitles').on('click', '.remove_subtitles', function(e){
|
||||||
$(this).tooltip('dispose');
|
$(this).tooltip('dispose');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const values = {
|
const values = {
|
||||||
moviePath: $(this).attr("data-moviePath"),
|
moviePath: movieDetails['mapped_path'],
|
||||||
language: $(this).attr("data-language"),
|
language: $(this).data("language"),
|
||||||
subtitlesPath: $(this).attr("data-subtitlesPath"),
|
subtitlesPath: $(this).data("subtitlespath"),
|
||||||
radarrId: movieDetails['radarrId'],
|
radarrId: movieDetails['radarrId'],
|
||||||
tmdbid: movieDetails['tmdbId']
|
tmdbid: movieDetails['tmdbId']
|
||||||
};
|
};
|
||||||
|
@ -337,19 +353,20 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.get_subtitle').on('click', function(e){
|
$(document).on('click', '.get_subtitle', function(e){
|
||||||
$(this).tooltip('dispose');
|
$(this).tooltip('dispose');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const values = {
|
const values = {
|
||||||
moviePath: $(this).attr("data-moviepath"),
|
moviePath: movieDetails['mapped_path'],
|
||||||
sceneName: $(this).attr("data-scenename"),
|
sceneName: movieDetails['sceneName'],
|
||||||
language: $(this).attr("data-language"),
|
language: $(this).attr("data-language"),
|
||||||
hi: $(this).attr("data-hi"),
|
hi: movieDetails['hearing_impaired'],
|
||||||
forced: $(this).attr("data-forced"),
|
forced: movieDetails['forced'],
|
||||||
radarrId: movieDetails['radarrId'],
|
radarrId: movieDetails['radarrId'],
|
||||||
title: movieDetails['title']
|
title: movieDetails['title']
|
||||||
};
|
};
|
||||||
var button = $(this).closest('button');
|
var button = $(this).closest('button' +
|
||||||
|
'');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.moviesubtitlesdownload') }}",
|
url: "{{ url_for('api.moviesubtitlesdownload') }}",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -361,15 +378,15 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#manual_search').on('click', function(e){
|
$('#manual_button').on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$("#movie_title_span").html(movieDetails['title']);
|
$("#movie_title_span").html(movieDetails['title']);
|
||||||
$("#movie_path_span").html($(this).attr("data-moviePath"));
|
$("#movie_path_span").html(movieDetails['mapped_path']);
|
||||||
$("#movie_scenename_span").html($(this).attr("data-sceneName"));
|
$("#movie_scenename_span").html(movieDetails['sceneName']);
|
||||||
|
|
||||||
moviePath = $(this).attr("data-moviePath");
|
moviePath = movieDetails['mapped_path'];
|
||||||
sceneName = $(this).attr("data-sceneName");
|
sceneName = movieDetails['sceneName'];
|
||||||
language = $(this).attr("data-language");
|
language = movieDetails['desired_languages'];
|
||||||
hi = movieDetails['hearing_impaired'];
|
hi = movieDetails['hearing_impaired'];
|
||||||
forced = movieDetails['forced'];
|
forced = movieDetails['forced'];
|
||||||
radarrId = movieDetails['radarrId'];
|
radarrId = movieDetails['radarrId'];
|
||||||
|
@ -498,7 +515,7 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#upload_subtitle').on('click', function(e){
|
$('#upload_button').on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$("#upload_movie_title_span").html(movieDetails['title']);
|
$("#upload_movie_title_span").html(movieDetails['title']);
|
||||||
$('#upload_moviePath').val($(this).data("moviepath"));
|
$('#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');
|
$(this).tooltip('dispose');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$("#movie_history_title_span").html(movieDetails['title']);
|
$("#movie_history_title_span").html(movieDetails['title']);
|
||||||
|
|
||||||
radarrId = $(this).data("radarrid");
|
radarrId = movieDetails['radarrId'];
|
||||||
|
|
||||||
$('#movie_history_result').DataTable( {
|
$('#movie_history_result').DataTable( {
|
||||||
destroy: true,
|
destroy: true,
|
||||||
|
@ -688,13 +705,13 @@
|
||||||
$('#movieMappedPath').text(movieDetails['mapped_path']);
|
$('#movieMappedPath').text(movieDetails['mapped_path']);
|
||||||
$('#movieMappedPath').attr("data-original-title", movieDetails['mapped_path']);
|
$('#movieMappedPath').attr("data-original-title", movieDetails['mapped_path']);
|
||||||
|
|
||||||
var languages = '';
|
|
||||||
if (movieDetails['languages'] !== 'None') {
|
if (movieDetails['languages'] !== 'None') {
|
||||||
|
var languages = '';
|
||||||
movieDetails['languages'].forEach(appendFunc);
|
movieDetails['languages'].forEach(appendFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendFunc(value) {
|
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);
|
$('#movieSubtitlesLanguages').html(languages);
|
||||||
|
@ -702,8 +719,30 @@
|
||||||
$('#movieForced').text('Forced: ' + movieDetails['forced']);
|
$('#movieForced').text('Forced: ' + movieDetails['forced']);
|
||||||
$('#movieDescription').text(movieDetails['overview']);
|
$('#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});
|
$('[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({
|
var table = $('#movieSubtitles').DataTable({
|
||||||
destroy: true,
|
destroy: true,
|
||||||
language: {
|
language: {
|
||||||
|
@ -733,6 +772,15 @@
|
||||||
return '<span class="badge badge-secondary">' + data['name'] + '</span>';
|
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