pull/884/head
Louis Vézina 5 years ago
parent e365607c16
commit ec2c7af031

@ -439,15 +439,18 @@ class Movies(Resource):
length = request.args.get('length') or -1
draw = request.args.get('draw')
moviesId = request.args.get('id')
moviesId = request.args.get('radarrid')
row_count = database.execute("SELECT COUNT(*) as count FROM table_movies", only_one=True)['count']
if moviesId:
result = database.execute("SELECT * FROM table_movies WHERE radarrId=? ORDER BY sortTitle ASC LIMIT ? "
"OFFSET ?", (length, start), (moviesId,))
"OFFSET ?", (moviesId, length, start))
else:
result = database.execute("SELECT * FROM table_movies ORDER BY sortTitle ASC LIMIT ? OFFSET ?",
(length, start))
for item in result:
# Add Datatables rowId
item.update({"DT_RowId": 'row_' + str(item['radarrId'])})
# Parse audio language
if item['audio_language']:
item.update({"audio_language": {"name": item['audio_language'],
@ -495,6 +498,43 @@ class Movies(Resource):
return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=result)
def post(self):
radarrId = request.args.get('radarrid')
lang = request.form.getlist('languages')
if len(lang) > 0:
pass
else:
lang = 'None'
single_language = settings.general.getboolean('single_language')
if single_language:
if str(lang) == "['None']":
lang = 'None'
else:
lang = str(lang)
else:
if str(lang) == "['']":
lang = '[]'
hi = request.form.get('hi')
forced = request.form.get('forced')
if hi == "on":
hi = "True"
else:
hi = "False"
result = database.execute("UPDATE table_movies SET languages=?, hearing_impaired=?, forced=? WHERE "
"radarrId=?", (str(lang), hi, forced, radarrId))
list_missing_subtitles_movies(no=radarrId)
event_stream.write(type='movie', action='update', movie=radarrId)
return '', 204
class HistorySeries(Resource):
def get(self):
start = request.args.get('start') or 0
@ -739,6 +779,7 @@ class WantedMovies(Resource):
api.add_resource(Badges, '/badges')
api.add_resource(Languages, '/languages')
api.add_resource(Series, '/series')
api.add_resource(SeriesEditSave, '/series_edit_save')
api.add_resource(Episodes, '/episodes')
@ -750,8 +791,12 @@ api.add_resource(EpisodesSubtitlesUpload, '/episodes_subtitles_upload')
api.add_resource(EpisodesScanDisk, '/episodes_scan_disk')
api.add_resource(EpisodesSearchMissing, '/episodes_search_missing')
api.add_resource(EpisodesHistory, '/episodes_history')
api.add_resource(Movies, '/movies')
api.add_resource(HistorySeries, '/history_series')
api.add_resource(HistoryMovies, '/history_movies')
api.add_resource(WantedSeries, '/wanted_series')
api.add_resource(WantedMovies, '/wanted_movies')

@ -43,6 +43,8 @@
table.dataTable tbody td {
vertical-align: middle;
}
.tooltip { pointer-events: none; }
</style>
{% endblock head_css %}

@ -343,7 +343,12 @@
{"data": "episode"},
{"data": null,
"render": function (data) {
return '<a href="" data-toggle="tooltip" title="Path is: '+data.mapped_path+'" data-season='+data.season+' data-episode='+data.episode+' data-episodeTitle="'+data.title+'" data-sonarrEpisodeId='+data.sonarrEpisodeId+' class="episode_history">'+data.title+'</a>';
var title_path = '<a href="" data-toggle="tooltip" title="Path is: '+data.mapped_path+'" data-season='+data.season+' data-episode='+data.episode+' data-episodeTitle="'+data.title+'" data-sonarrEpisodeId='+data.sonarrEpisodeId+' class="episode_history">'+data.title+'</a>';
if (data.scene_name) {
return '<i class="fas fa-info-circle" data-toggle="tooltip" data-placement="right" title="' + data.scene_name + '"></i> ' + title_path;
} else {
return title_path;
}
}
},
{"data": null,

@ -28,14 +28,118 @@
<th>Subtitles Languages</th>
<th>Hearing-Impaired</th>
<th>Forced</th>
<th></th>
</tr>
</thead>
</table>
<div id="editModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><span id="edit_movies_title_span"></span></h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form class="form" name="edit_form" id="edit_form">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 text-right">
Audio Language
</div>
<div class="form-group col-sm-8 pl-sm-0">
<span id="edit_audio_language_span"></span>
</div>
</div>
<div class="row">
<div class="col-sm-3 text-right">
Subtitles Language(s)
</div>
<div class="form-group col-sm-8 pl-sm-0">
<select class="selectpicker" id="edit_languages_select" name="languages" multiple data-live-search="true"></select>
</div>
</div>
<div class="row">
<div class="col-sm-3 text-right">
Hearing-Impaired
</div>
<div class="form-group col-sm-1 pl-sm-0">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="hi_checkbox" name="hi">
<span class="custom-control-label" for="hi_checkbox"></span>
</label>
</div>
</div>
<div class="row">
<div class="col-sm-3 text-right">
Forced
</div>
<div class="form-group col-sm-8 pl-sm-0">
<select class="selectpicker" id="edit_forced_select" name="forced">
<option value="False">False</option>
<option value="True">True</option>
<option value="Both">Both</option>
</select>
</div>
</div>
</div>
<input type="hidden" id="edit_radarrId" name="radarrId" value="" />
</div>
<div class="modal-footer">
<button type="submit" id="edit_save_button" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
getLanguages();
getEnabledLanguages();
events.on('event', function(event) {
var event_json = JSON.parse(event);
if (event_json.type === 'movie' && event_json.action === 'insert') {
$.ajax({
url: "{{ url_for('api.movies') }}?radarrid=" + event_json.movie,
success: function (data) {
if (data.data.length) {
$('#movies').DataTable().rows.add(data.data);
$('#movies').DataTable().columns.adjust().draw(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]);
$('[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});
}
}
});
var table = $('#movies').DataTable({
"dom":
"<'row'<'col-sm-12'tr>>" +
@ -99,28 +203,86 @@
},
{
"data": "hearing_impaired",
"className": "dt-center",
"render": function (data) {
if (data === 'False') {
return '<i class="far fa-square"></i>';
} else if (data === 'True') {
return '<i class="far fa-check-square"></i>';
}
}
"className": "dt-center"
},
{
"data": "forced",
"className": "dt-center",
"className": "dt-center"
},
{
"data": null,
"render": function (data) {
if (data === 'False') {
return '<i class="far fa-square"></i>';
} else if (data === 'True') {
return '<i class="far fa-check-square"></i>';
}
return '<a href="" class="edit_button badge badge-secondary" data-radarrId='+data.radarrId+' data-audiolanguage="'+data.audio_language.name+'" data-title="'+data.title+'" data-languages='+JSON.stringify(data.languages)+' data-hi="'+data.hearing_impaired+'" data-forced="'+data.forced+'"><i class="fas fa-wrench"></i></a>';
}
}
]
});
});
$('#movies').on('click', '.edit_button', function(e){
e.preventDefault();
$("#edit_movies_title_span").html($(this).data('title'));
$("#edit_audio_language_span").html($(this).data('audiolanguage'));
$('#edit_radarrId').val($(this).data('radarrid'));
$('#edit_languages_select').empty();
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').selectpicker({maxOptions: 1});
}
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').append('<option value="None">None</option>');
}
$.each(enabledLanguages, function (i, item) {
$('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>');
});
$("#edit_languages_select").selectpicker("refresh");
var selected_languages = Array();
$.each(Array.from($(this).data('languages')), function (i, item) {
selected_languages.push(item.code2);
});
$('#edit_languages_select').selectpicker('val', selected_languages);
$('#hi_checkbox').prop('checked', ($(this).data('hi') === 'True'));
$('#edit_forced_select').val($(this).data('forced')).change();
$('#editModal')
.modal({
focus: false
});
});
$('#edit_form').on('submit', function(e){
e.preventDefault();
var formdata = new FormData(document.getElementById("edit_form"));
$.ajax({
url: "{{ url_for('api.movies') }}?radarrid=" + $('#edit_radarrId').val(),
data: formdata,
processData: false,
contentType: false,
type: 'POST',
success: function(){
$('#editModal').modal('hide');
}
});
});
function getLanguages() {
$.ajax({
url: "{{ url_for('api.languages') }}?enabled=false",
success:function(data) {
availableLanguages = data;
}
});
}
function getEnabledLanguages() {
$.ajax({
url: "{{ url_for('api.languages') }}?enabled=true",
success:function(data) {
enabledLanguages = data;
}
});
}
</script>
{% endblock tail %}

@ -259,7 +259,6 @@
contentType: false,
type: 'POST',
success: function(){
//seriesDetailsRefresh();
$('#editModal').modal('hide');
}
});

Loading…
Cancel
Save