pull/884/head
Louis Vézina 5 years ago
parent a8e6b2c0b0
commit 8230208ce5

@ -270,7 +270,7 @@ class EpisodesSubtitlesUpload(Resource):
if sceneName == "null":
sceneName = "None"
language = request.form.get('language')
forced = True if request.form.get('forced') == '1' else False
forced = True if request.form.get('forced') == 'on' else False
upload = request.files.get('upload')
sonarrSeriesId = request.form.get('sonarrSeriesId')
sonarrEpisodeId = request.form.get('sonarrEpisodeId')

@ -27,6 +27,8 @@
<link href="{{ url_for('static',filename='css/bazarr.css') }}" id="theme" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='datatables/datatables.min.css') }}">
<link rel="stylesheet" type="text/css"
href="{{ url_for('static',filename='datatables/rowGroup.dataTables.min.css') }}">
<link rel="stylesheet" type="text/css"
href="{{ url_for('static',filename='datatables/responsive.dataTables.min.css') }}">
<link rel="stylesheet" type="text/css"
@ -246,6 +248,7 @@
<script src="{{ url_for('static',filename='plugins/sticky-kit-master/dist/sticky-kit.min.js') }}"></script>
<!--Custom JavaScript -->
<script src="{{ url_for('static',filename='datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ url_for('static',filename='datatables/dataTables.rowGroup.min.js') }}"></script>
<script src="{{ url_for('static',filename='datatables/dataTables.responsive.min.js') }}"></script>
<script src="{{ url_for('static',filename='plugins/datatables.net-bs4/js/dataTables.bootstrap4.min.js') }}"></script>
<script src="{{ url_for('static',filename='js/custom.js') }}"></script>

@ -3,7 +3,7 @@
{% block title %}Series - Bazarr{% endblock %}
{% block head %}
<style>
<style>
#seriesFanart {
background-repeat: no-repeat;
background-size: cover;
@ -32,26 +32,26 @@
span {
margin-right: 0.5em;
}
</style>
</style>
{% endblock head %}
{% block bcleft %}
<div class="">
<div class="">
<button class="btn btn-outline">
<i class="fas fa-sync align-top text-themecolor text-center font-20" aria-hidden="true"></i>
<span class="align-bottom text-themecolor small text-center">Update</span>
</button>
</div>
</div>
{% endblock bcleft %}
{% block bcright %}
<div class="d-flex m-t-5 justify-content-end">
<div class="d-flex m-t-5 justify-content-end">
<h5 class="m-t-0 text-themecolor">Some page settings</h5>
</div>
</div>
{% endblock bcright %}
{% block body %}
<div class="container-fluid" id="seriesFanart">
<div class="container-fluid" id="seriesFanart">
<div class="row justify-content-md-center" id="seriesDetails">
<div class="col-sm-auto" id="seriesPosterColumn">
<img id="seriesPoster" src="">
@ -80,8 +80,8 @@
</div>
</div>
</div>
</div>
<div class="container-fluid">
</div>
<div class="container-fluid">
<!-- Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<table id="episodes" class="table table-striped" style="width:100%">
@ -97,9 +97,9 @@
</tr>
</thead>
</table>
</div>
</div>
<div id="manualSearchModal" class="modal" tabindex="-1" role="dialog">
<div id="manualSearchModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -132,9 +132,9 @@
</div>
</div>
</div>
</div>
</div>
<div id="uploadModal" class="modal" tabindex="-1" role="dialog">
<div id="uploadModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -143,8 +143,8 @@
<span aria-hidden="true">&times;</span>
</button>
</div>
<form class="form" name="upload_form" id="upload_form">
<div class="modal-body">
<form class="form" name="upload_form" id="upload_form" method="post" enctype="multipart/form-data">
<div class="container-fluid">
<div class="row">
<div class="col-sm-2 text-right">
@ -177,19 +177,25 @@
</div>
</div>
</div>
</form>
<input type="hidden" id="upload_episodePath" name="episodePath" value="" />
<input type="hidden" id="upload_sceneName" name="sceneName" value="" />
<input type="hidden" id="upload_sonarrSeriesId" name="sonarrSeriesId" value="" />
<input type="hidden" id="upload_sonarrEpisodeId" name="sonarrEpisodeId" value="" />
<input type="hidden" id="upload_title" name="title" value="" />
</div>
<div class="modal-footer">
<button type="button" id="upload_save_button" class="btn btn-primary">Save</button>
<button type="submit" id="upload_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>
</div>
{% endblock body %}
{% block tail %}
<script>
<script>
// make the filename appear in upload file dialog once a file have been selected.
$(document).ready(function () {
document.querySelector('.custom-file-input').addEventListener('change',function(e){
@ -241,8 +247,13 @@
"ordering": false,
"lengthChange": false,
"responsive": true,
"pageLength": 250,
"pageLength": 100,
"ajax": "{{ url_for('api.episodes') }}?id={{id}}",
rowGroup: {
dataSrc: function(data) {
return 'Season ' + data.season;
}
},
"columns": [
{"data": "monitored",
"render": function (data, type, row) {
@ -291,12 +302,20 @@
},
{"data": null,
"render": function (data) {
return '<a href="" class="manual_search badge badge-secondary" data-season='+data.season+' data-episode='+data.episode+' data-episode_title="'+data.title+'" data-episodePath="'+data.mapped_path+'" data-sceneName="'+data.scene_name+'" data-language="'+data.desired_languages+'" data-sonarrEpisodeId='+data.sonarrEpisodeId+'><i class="fas fa-user"></i></a>';
if (data.desired_languages !== '[]') {
return '<a href="" class="manual_search badge badge-secondary" data-season=' + data.season + ' data-episode=' + data.episode + ' data-episode_title="' + data.title + '" data-episodePath="' + data.mapped_path + '" data-sceneName="' + data.scene_name + '" data-language="' + data.desired_languages + '" data-sonarrEpisodeId=' + data.sonarrEpisodeId + '><i class="fas fa-user"></i></a>';
} else {
return ''
}
}
},
{"data": null,
"render": function (data) {
return '<a href="" class="upload_subtitle badge badge-secondary" data-episodePath="'+data.path+'" data-sceneName"'+data.scene_name+'" data-sonarrEpisodeId="'+data.sonarrEpisodeId+'" data-season="'+data.season+'" data-episode="'+data.episode+'" data-episode_title="'+data.title+'"><i class="fas fa-cloud-upload-alt"></i></a>';
if (data.desired_languages !== '[]') {
return '<a href="" class="upload_subtitle badge badge-secondary" data-episodePath="'+data.mapped_path+'" data-sceneName"'+data.scene_name+'" data-sonarrSeriesId="'+seriesDetails['sonarrSeriesId']+'" data-sonarrEpisodeId="'+data.sonarrEpisodeId+'" data-season="'+data.season+'" data-episode="'+data.episode+'" data-episode_title="'+data.title+'"><i class="fas fa-cloud-upload-alt"></i></a>';
} else {
return ''
}
}
}
]
@ -397,7 +416,8 @@
$('#search_result').DataTable( {
destroy: true,
language: {
zeroRecords: 'No Subtitles Found For This Episode'
zeroRecords: 'No Subtitles Found For This Episode',
processing: "Searching (possibly solving captcha)..."
},
paging: true,
lengthChange: false,
@ -476,9 +496,49 @@
});
});
$('#search_result').on('click', '.manual_download', function(e){
e.preventDefault();
const values = {
episodePath: $(this).attr("data-episodepath"),
sceneName: $(this).attr("data-scenename"),
language: $(this).attr("data-language"),
hi: seriesDetails['hearing_impaired'],
forced: $(this).attr("data-forced"),
provider: $(this).attr("data-provider"),
subtitle: $(this).attr("data-subtitle"),
sonarrSeriesId: seriesDetails['sonarrSeriesId'],
sonarrEpisodeId: $(this).attr('data-sonarrepisodeid'),
title: seriesDetails['title']
};
var cell = $(this).closest('td');
$.ajax({
url: "{{ url_for('api.episodessubtitlesmanualdownload') }}",
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(data) {
$('#episodes').DataTable().ajax.reload(null, false);
$('#manualSearchModal').modal('hide');
if (data['responseJSON']) {
console.log(data['responseJSON'][0]);
} else {
console.log("No subtitle downloaded.");
}
}
});
});
$('#episodes').on('click', '.upload_subtitle', function(e){
e.preventDefault();
$("#upload_series_title_span").html(seriesDetails['title'] + ' - ' + $(this).data("season") + 'x' + $(this).data("episode") + ' - ' + $(this).data("episode_title"));
$('#upload_episodePath').val($(this).data("episodepath"));
$('#upload_sceneName').val($(this).data("scenename"));
$('#upload_sonarrSeriesId').val($(this).data("sonarrseriesid"));
$('#upload_sonarrEpisodeId').val($(this).data("sonarrepisodeid"));
$('#upload_title').val($(this).data("episode_title"));
var languages = Array.from(seriesDetails['languages']);
var is_pb = languages.includes('pb');
@ -490,30 +550,33 @@
text : item.name
}));
});
/*
const values = {
episodePath: $(this).data("episodePath"),
sceneName: $(this).data("sceneName"),
language: seriesDetails['languages'],
forced: "valeur du checkbox (0 ou 1)",
hi: seriesDetails['hearing_impaired'],
sonarrSeriesId: seriesDetails['sonarrSeriesId'],
sonarrEpisodeId: $(this).data("sonarrEpisodeId"),
title: seriesDetails['title']
};
$.ajax({
url: "{{ url_for('api.episodessubtitlesupload') }}",
type: "POST",
dataType: "json",
data: values
});
*/
$('#uploadModal')
.modal({
focus: false
});
});
$('#upload_form').on('submit', function(e){
e.preventDefault();
var formdata = new FormData(document.getElementById("upload_form"));
$.ajax({
url: "{{ url_for('api.episodessubtitlesupload') }}",
data: formdata,
processData: false,
contentType: false,
type: 'POST',
success: function(){
$('#episodes').DataTable().ajax.reload(null, false);
$('#uploadModal').modal('hide');
}
});
});
$('#uploadModal').on('hidden.bs.modal', function () {
$(this).find('form')[0].reset();
});
});
</script>
</script>
{% endblock tail %}

Loading…
Cancel
Save