pull/884/head
Louis Vézina 5 years ago
parent bb0fce1259
commit 0b406c8a1e

@ -97,7 +97,8 @@ class Episodes(Resource):
row_count = database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE sonarrSeriesId=?",
(seriesId,), only_one=True)['count']
if seriesId:
result = database.execute("SELECT * FROM table_episodes WHERE sonarrSeriesId=?", (seriesId,))
result = database.execute("SELECT * FROM table_episodes WHERE sonarrSeriesId=? ORDER BY season DESC, "
"episode DESC", (seriesId,))
else:
return "Series ID not provided", 400
for item in result:

@ -57,7 +57,7 @@ from list_subtitles import store_subtitles, store_subtitles_movie, series_scan_s
from get_subtitle import download_subtitle, series_download_subtitles, movies_download_subtitles, \
manual_search, manual_download_subtitle, manual_upload_subtitle
from utils import history_log, history_log_movie, get_sonarr_version, get_radarr_version
from helper import path_replace_reverse, path_replace_reverse_movie
from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie
from scheduler import *
from notifier import send_notifications, send_notifications_movie
from subliminal_patch.extensions import provider_registry as provider_manager
@ -1481,12 +1481,14 @@ def remove_subtitles():
sonarrEpisodeId = request.form.get('sonarrEpisodeId')
try:
os.remove(subtitlesPath)
os.remove(path_replace(subtitlesPath))
result = language_from_alpha3(language) + " subtitles deleted from disk."
history_log(0, sonarrSeriesId, sonarrEpisodeId, result, language=alpha2_from_alpha3(language))
except OSError as e:
logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath)
store_subtitles(path_replace_reverse(episodePath), episodePath)
store_subtitles(episodePath, path_replace(episodePath))
return ''
@app.route('/remove_subtitles_movie', methods=['POST'])

@ -107,7 +107,7 @@
url: "{{ url_for('api.series') }}?id={{id}}",
})
.done(function( data ) {
var seriesDetails = data.data[0];
seriesDetails = data.data[0];
$('#seriesFanart').css('background-image', "url('{{ url_for('image_proxy', url='MediaCover/'+id+'/fanart.jpg') }}')");
$('#seriesPoster').attr("src","{{ url_for('image_proxy', url='MediaCover/'+id+'/poster-250.jpg') }}");
$('#seriesTitle').text(seriesDetails['title']);
@ -159,18 +159,22 @@
},
{"data": "episode"},
{"data": "title"},
{"data": "subtitles",
{"data": null,
"render": function (data) {
if (data !== 'None') {
if (data.subtitles !== 'None') {
var languages = '';
data.forEach(appendFunc);
data.subtitles.forEach(appendFunc);
return languages;
} else {
return null;
}
function appendFunc(value) {
languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value[0].name + '">' + value[0].code2 + '</span> ';
if (value[1] === null) {
languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value[0].name + '">' + value[0].code2 + '</span> ';
} else {
languages = languages + '<a href="" class="remove_subtitles badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value[0].name + '" data-episodePath="'+data.path+'" data-language="'+value[0].code3+'" data-subtitlesPath="'+value[1]+'" data-sonarrEpisodeId='+data.sonarrEpisodeId+'>' + value[0].code2 + ' <i class="far fa-trash-alt"></i></a> ';
}
}
}
},
@ -193,6 +197,34 @@
{"data": "title"}
]
});
$('#episodes').on('click', '.remove_subtitles', function(e){
e.preventDefault()
const values = {
episodePath: $(this).attr("data-episodePath"),
language: $(this).attr("data-language"),
subtitlesPath: $(this).attr("data-subtitlesPath"),
sonarrSeriesId: seriesDetails['sonarrSeriesId'],
sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"),
tvdbid: seriesDetails['tvdbId']
};
var cell = $(this).closest('td');
$.ajax({
url: "{{ url_for('remove_subtitles') }}",
type: "POST",
dataType: "json",
data: values,
beforeSend: function() {
cell.html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
},
complete: function() {
$('#episodes').DataTable().ajax.reload(null, false);
alert("test");
}
});
});
});
</script>
{% endblock tail %}

Loading…
Cancel
Save