mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-10 16:57:45 +08:00
Fix for #1031. Improvement to previous commit.
This commit is contained in:
parent
a9da6e3343
commit
e47aed6490
4 changed files with 85 additions and 74 deletions
|
@ -377,19 +377,38 @@ class SeriesEditSave(Resource):
|
|||
if lang == ['None']:
|
||||
lang = 'None'
|
||||
|
||||
seriesIdList = []
|
||||
seriesidLangList = []
|
||||
seriesidHiList = []
|
||||
seriesidForcedList = []
|
||||
for item in request.form.getlist('seriesid[]'):
|
||||
seriesid = item.lstrip('row_')
|
||||
try:
|
||||
if len(lang):
|
||||
database.execute("UPDATE table_shows SET languages=? WHERE sonarrSeriesId=?", (str(lang), seriesid))
|
||||
if len(hi):
|
||||
database.execute("UPDATE table_shows SET hearing_impaired=? WHERE sonarrSeriesId=?", (hi[0], seriesid))
|
||||
if len(forced):
|
||||
database.execute("UPDATE table_shows SET forced=? WHERE sonarrSeriesId=?", (forced[0], seriesid))
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
list_missing_subtitles(no=seriesid)
|
||||
seriesIdList.append(seriesid)
|
||||
if len(lang):
|
||||
seriesidLangList.append([str(lang), seriesid])
|
||||
if len(hi):
|
||||
seriesidHiList.append([hi[0], seriesid])
|
||||
if len(forced):
|
||||
seriesidForcedList.append([forced[0], seriesid])
|
||||
|
||||
try:
|
||||
if len(lang):
|
||||
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
|
||||
|
||||
|
@ -884,19 +903,37 @@ class MoviesEditSave(Resource):
|
|||
if lang == ['None']:
|
||||
lang = 'None'
|
||||
|
||||
radarrIdList = []
|
||||
radarrIdLangList = []
|
||||
radarrIdHiList = []
|
||||
radarrIdForcedList = []
|
||||
for item in request.form.getlist('radarrid[]'):
|
||||
radarrid = item.lstrip('row_')
|
||||
try:
|
||||
if len(lang):
|
||||
database.execute("UPDATE table_movies SET languages=? WHERE radarrId=?", (str(lang), radarrid))
|
||||
if len(hi):
|
||||
database.execute("UPDATE table_movies SET hearing_impaired=? WHERE radarrId=?", (hi[0], radarrid))
|
||||
if len(forced):
|
||||
database.execute("UPDATE table_movies SET forced=? WHERE radarrId=?", (forced[0], radarrid))
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
list_missing_subtitles_movies(no=radarrid)
|
||||
radarrIdList.append(radarrid)
|
||||
if len(lang):
|
||||
radarrIdLangList.append([str(lang), radarrid])
|
||||
if len(hi):
|
||||
radarrIdHiList.append([hi[0], radarrid])
|
||||
if len(forced):
|
||||
radarrIdForcedList.append([forced[0], radarrid])
|
||||
try:
|
||||
if len(lang):
|
||||
database.execute("UPDATE table_movies SET languages=? WHERE radarrId=?", radarrIdLangList,
|
||||
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
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ def store_subtitles_movie(original_path, reversed_path):
|
|||
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:
|
||||
episodes_subtitles_clause = " WHERE table_episodes.sonarrSeriesId=" + str(no)
|
||||
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],
|
||||
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:
|
||||
movies_subtitles_clause = " WHERE radarrId=" + str(no)
|
||||
else:
|
||||
|
@ -293,7 +294,8 @@ def list_missing_subtitles_movies(no=None):
|
|||
(missing_subtitles_item[0], 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():
|
||||
|
|
|
@ -65,37 +65,16 @@
|
|||
|
||||
events.on('event', function (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({
|
||||
url: "{{ url_for('api.movies') }}?radarrid=" + event_json.movie,
|
||||
url: "{{ url_for('api.movies') }}",
|
||||
success: function (data) {
|
||||
if (data.data.length) {
|
||||
$('#movies').DataTable().rows.add(data.data);
|
||||
$('#movies').DataTable().columns.adjust().draw(false);
|
||||
$('#movies').DataTable().ajax.reload(resetPaging = false);
|
||||
$('[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') }}",
|
||||
method: "POST",
|
||||
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 () {
|
||||
table.rows().deselect();
|
||||
$('#languages_select').selectpicker('val', '');
|
||||
|
|
|
@ -65,37 +65,16 @@
|
|||
|
||||
events.on('event', function (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({
|
||||
url: "{{ url_for('api.series') }}?seriesid=" + event_json.series,
|
||||
url: "{{ url_for('api.series') }}",
|
||||
success: function (data) {
|
||||
if (data.data.length) {
|
||||
$('#series').DataTable().rows.add(data.data);
|
||||
$('#series').DataTable().columns.adjust().draw(false);
|
||||
$('#series').DataTable().ajax.reload(resetPaging = false);
|
||||
$('[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') }}",
|
||||
method: "POST",
|
||||
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 () {
|
||||
table.rows().deselect();
|
||||
$('#languages_select').selectpicker('val', '');
|
||||
|
|
Loading…
Reference in a new issue