Fix for #1031. Improvement to previous commit.

pull/1038/head
Louis Vézina 4 years ago
parent a9da6e3343
commit e47aed6490

@ -377,19 +377,38 @@ class SeriesEditSave(Resource):
if lang == ['None']: if lang == ['None']:
lang = 'None' lang = 'None'
seriesIdList = []
seriesidLangList = []
seriesidHiList = []
seriesidForcedList = []
for item in request.form.getlist('seriesid[]'): for item in request.form.getlist('seriesid[]'):
seriesid = item.lstrip('row_') seriesid = item.lstrip('row_')
try: seriesIdList.append(seriesid)
if len(lang): if len(lang):
database.execute("UPDATE table_shows SET languages=? WHERE sonarrSeriesId=?", (str(lang), seriesid)) seriesidLangList.append([str(lang), seriesid])
if len(hi): if len(hi):
database.execute("UPDATE table_shows SET hearing_impaired=? WHERE sonarrSeriesId=?", (hi[0], seriesid)) seriesidHiList.append([hi[0], seriesid])
if len(forced): if len(forced):
database.execute("UPDATE table_shows SET forced=? WHERE sonarrSeriesId=?", (forced[0], seriesid)) seriesidForcedList.append([forced[0], seriesid])
except:
pass try:
else: if len(lang):
list_missing_subtitles(no=seriesid) database.execute("UPDATE table_shows SET languages=? WHERE sonarrSeriesId=?", seriesidLangList,
execute_many=True)
if len(hi):
database.execute("UPDATE table_shows SET hearing_impaired=? WHERE sonarrSeriesId=?", seriesidHiList,
execute_many=True)
if len(forced):
database.execute("UPDATE table_shows SET forced=? WHERE sonarrSeriesId=?", seriesidForcedList,
execute_many=True)
except:
pass
else:
for seriesId in seriesIdList:
list_missing_subtitles(no=seriesId, update_wanted=False)
event_stream(type='series_editor', action='update')
event_stream(type='badges')
return '', 204 return '', 204
@ -884,19 +903,37 @@ class MoviesEditSave(Resource):
if lang == ['None']: if lang == ['None']:
lang = 'None' lang = 'None'
radarrIdList = []
radarrIdLangList = []
radarrIdHiList = []
radarrIdForcedList = []
for item in request.form.getlist('radarrid[]'): for item in request.form.getlist('radarrid[]'):
radarrid = item.lstrip('row_') radarrid = item.lstrip('row_')
try: radarrIdList.append(radarrid)
if len(lang): if len(lang):
database.execute("UPDATE table_movies SET languages=? WHERE radarrId=?", (str(lang), radarrid)) radarrIdLangList.append([str(lang), radarrid])
if len(hi): if len(hi):
database.execute("UPDATE table_movies SET hearing_impaired=? WHERE radarrId=?", (hi[0], radarrid)) radarrIdHiList.append([hi[0], radarrid])
if len(forced): if len(forced):
database.execute("UPDATE table_movies SET forced=? WHERE radarrId=?", (forced[0], radarrid)) radarrIdForcedList.append([forced[0], radarrid])
except: try:
pass if len(lang):
else: database.execute("UPDATE table_movies SET languages=? WHERE radarrId=?", radarrIdLangList,
list_missing_subtitles_movies(no=radarrid) execute_many=True)
if len(hi):
database.execute("UPDATE table_movies SET hearing_impaired=? WHERE radarrId=?", radarrIdHiList,
execute_many=True)
if len(forced):
database.execute("UPDATE table_movies SET forced=? WHERE radarrId=?", radarrIdForcedList,
execute_many=True)
except:
pass
else:
for radarrId in radarrIdList:
list_missing_subtitles_movies(no=radarrId, update_wanted=False)
event_stream(type='movies_editor', action='update')
event_stream(type='badges')
return '', 204 return '', 204

@ -169,7 +169,7 @@ def store_subtitles_movie(original_path, reversed_path):
return actual_subtitles return actual_subtitles
def list_missing_subtitles(no=None, epno=None): def list_missing_subtitles(no=None, epno=None, update_wanted=True):
if no is not None: if no is not None:
episodes_subtitles_clause = " WHERE table_episodes.sonarrSeriesId=" + str(no) episodes_subtitles_clause = " WHERE table_episodes.sonarrSeriesId=" + str(no)
elif epno is not None: elif epno is not None:
@ -233,10 +233,11 @@ def list_missing_subtitles(no=None, epno=None):
event_stream(type='episode', action='update', series=missing_subtitles_item[2], event_stream(type='episode', action='update', series=missing_subtitles_item[2],
episode=missing_subtitles_item[1]) episode=missing_subtitles_item[1])
event_stream(type='badges') if update_wanted:
event_stream(type='badges')
def list_missing_subtitles_movies(no=None): def list_missing_subtitles_movies(no=None, update_wanted=True):
if no is not None: if no is not None:
movies_subtitles_clause = " WHERE radarrId=" + str(no) movies_subtitles_clause = " WHERE radarrId=" + str(no)
else: else:
@ -293,7 +294,8 @@ def list_missing_subtitles_movies(no=None):
(missing_subtitles_item[0], missing_subtitles_item[1])) (missing_subtitles_item[0], missing_subtitles_item[1]))
event_stream(type='movie', action='update', movie=missing_subtitles_item[1]) event_stream(type='movie', action='update', movie=missing_subtitles_item[1])
event_stream(type='badges') if update_wanted:
event_stream(type='badges')
def series_full_scan_subtitles(): def series_full_scan_subtitles():

@ -65,37 +65,16 @@
events.on('event', function (event) { events.on('event', function (event) {
var event_json = JSON.parse(event); var event_json = JSON.parse(event);
if (event_json.type === 'movie' && event_json.action === 'insert') { if (event_json.type === 'movies_editor' && event_json.action === 'update') {
$.ajax({ $.ajax({
url: "{{ url_for('api.movies') }}?radarrid=" + event_json.movie, url: "{{ url_for('api.movies') }}",
success: function (data) { success: function (data) {
if (data.data.length) { if (data.data.length) {
$('#movies').DataTable().rows.add(data.data); $('#movies').DataTable().ajax.reload(resetPaging = false);
$('#movies').DataTable().columns.adjust().draw(false);
$('[data-toggle="tooltip"]').tooltip({html: true}); $('[data-toggle="tooltip"]').tooltip({html: true});
} }
} }
}) })
} else if (event_json.type === 'movie' && event_json.action === 'update') {
var rowId = $('#movies').DataTable().row('#row_' + event_json.movie);
if (rowId.length) {
$.ajax({
url: "{{ url_for('api.movies') }}?radarrid=" + event_json.movie,
success: function (data) {
if (data.data.length) {
$('#movies').DataTable().row(rowId).data(data.data[0]).draw('page');
$('[data-toggle="tooltip"]').tooltip({html: true});
}
}
})
}
} else if (event_json.type === 'movie' && event_json.action === 'delete') {
var rowId = $('#movies').DataTable().row('#row_' + event_json.movie);
if (rowId.length) {
$('#movies').DataTable().row(rowId).remove();
$('#movies').DataTable().columns.adjust().draw(false);
$('[data-toggle="tooltip"]').tooltip({html: true});
}
} }
}); });
@ -220,6 +199,13 @@
url: "{{ url_for('api.movieseditsave') }}", url: "{{ url_for('api.movieseditsave') }}",
method: "POST", method: "POST",
data: values, data: values,
beforeSend: function () {
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'wait');
},
success: function () { success: function () {
table.rows().deselect(); table.rows().deselect();
$('#languages_select').selectpicker('val', ''); $('#languages_select').selectpicker('val', '');

@ -65,37 +65,16 @@
events.on('event', function (event) { events.on('event', function (event) {
var event_json = JSON.parse(event); var event_json = JSON.parse(event);
if (event_json.type === 'series' && event_json.action === 'insert') { if (event_json.type === 'series_editor' && event_json.action === 'update') {
$.ajax({ $.ajax({
url: "{{ url_for('api.series') }}?seriesid=" + event_json.series, url: "{{ url_for('api.series') }}",
success: function (data) { success: function (data) {
if (data.data.length) { if (data.data.length) {
$('#series').DataTable().rows.add(data.data); $('#series').DataTable().ajax.reload(resetPaging = false);
$('#series').DataTable().columns.adjust().draw(false);
$('[data-toggle="tooltip"]').tooltip({html: true}); $('[data-toggle="tooltip"]').tooltip({html: true});
} }
} }
}) })
} else if (event_json.type === 'series' && event_json.action === 'update') {
var rowId = $('#series').DataTable().row('#row_' + event_json.series);
if (rowId.length) {
$.ajax({
url: "{{ url_for('api.series') }}?seriesid=" + event_json.series,
success: function (data) {
if (data.data.length) {
$('#series').DataTable().row(rowId).data(data.data[0]).draw('page');
$('[data-toggle="tooltip"]').tooltip({html: true});
}
}
})
}
} else if (event_json.type === 'series' && event_json.action === 'delete') {
var rowId = $('#series').DataTable().row('#row_' + event_json.series);
if (rowId.length) {
$('#series').DataTable().row(rowId).remove();
$('#series').DataTable().columns.adjust().draw(false);
$('[data-toggle="tooltip"]').tooltip({html: true});
}
} }
}); });
@ -214,6 +193,13 @@
url: "{{ url_for('api.serieseditsave') }}", url: "{{ url_for('api.serieseditsave') }}",
method: "POST", method: "POST",
data: values, data: values,
beforeSend: function () {
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'wait');
},
success: function () { success: function () {
table.rows().deselect(); table.rows().deselect();
$('#languages_select').selectpicker('val', ''); $('#languages_select').selectpicker('val', '');

Loading…
Cancel
Save