pull/884/head
Louis Vézina 5 years ago
parent 04b487611c
commit ca98498f74

@ -132,7 +132,8 @@ def update_series():
removed_series = list(set(current_shows_db_list) - set(current_shows_sonarr)) removed_series = list(set(current_shows_db_list) - set(current_shows_sonarr))
for series in removed_series: for series in removed_series:
database.execute("DELETE FROM table_shows WHERE sonarrSEriesId=?",(series,)) database.execute("DELETE FROM table_shows WHERE sonarrSeriesId=?",(series,))
event_stream.write(type='series', action='delete', series=series)
# Update existing series in DB # Update existing series in DB
series_in_db_list = [] series_in_db_list = []
@ -148,7 +149,6 @@ def update_series():
query = dict_converter.convert(updated_series) query = dict_converter.convert(updated_series)
database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''', database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''',
query.values + (updated_series['sonarrSeriesId'],)) query.values + (updated_series['sonarrSeriesId'],))
event_stream.write(type='series', action='update', series=updated_series['sonarrSeriesId']) event_stream.write(type='series', action='update', series=updated_series['sonarrSeriesId'])
# Insert new series in DB # Insert new series in DB

@ -518,22 +518,7 @@ def series():
@app.route('/serieseditor/') @app.route('/serieseditor/')
@login_required @login_required
def serieseditor(): def serieseditor():
return render_template('serieseditor.html')
# Get missing count
missing_count = database.execute("SELECT COUNT(*) as count FROM table_shows", only_one=True)['count']
# Get series list
data = database.execute("SELECT tvdbId, title, path, languages, hearing_impaired, sonarrSeriesId, poster, "
"audio_language, forced FROM table_shows ORDER BY sortTitle ASC")
# path_replace
dict_mapper.path_replace(data)
# Get languages list
languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1")
return render_template('serieseditor.html', bazarr_version=bazarr_version, rows=data, languages=languages,
missing_count=missing_count, base_url=base_url,
single_language=settings.general.getboolean('single_language'), current_port=settings.general.port)
@app.route('/search_json/<query>', methods=['GET']) @app.route('/search_json/<query>', methods=['GET'])

@ -31,9 +31,13 @@
href="{{ url_for('static',filename='datatables/rowGroup.dataTables.min.css') }}"> href="{{ url_for('static',filename='datatables/rowGroup.dataTables.min.css') }}">
<link rel="stylesheet" type="text/css" <link rel="stylesheet" type="text/css"
href="{{ url_for('static',filename='datatables/responsive.dataTables.min.css') }}"> href="{{ url_for('static',filename='datatables/responsive.dataTables.min.css') }}">
<link rel="stylesheet" type="text/css"
href="{{ url_for('static',filename='datatables/select.bootstrap4.min.css') }}">
<link rel="stylesheet" type="text/css"
href="{{ url_for('static',filename='datatables/buttons.dataTables.min.css') }}">
<link rel="stylesheet" type="text/css" <link rel="stylesheet" type="text/css"
href="{{ url_for('static',filename='plugins/datatables.net-bs4/css/dataTables.bootstrap4.min.css') }}"> href="{{ url_for('static',filename='plugins/datatables.net-bs4/css/dataTables.bootstrap4.min.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/css/bootstrap-select.css" /> <link rel="stylesheet" href="{{ url_for('static',filename='css/bootstrap-select.css') }}" />
<style> <style>
table.dataTable tbody td { table.dataTable tbody td {
@ -142,8 +146,12 @@
<nav class="sidebar-nav"> <nav class="sidebar-nav">
<ul id="sidebarnav"> <ul id="sidebarnav">
{% if settings.general.getboolean('use_sonarr') %} {% if settings.general.getboolean('use_sonarr') %}
<li><a href="{{ url_for('series') }}"><i class="fas fa-play"></i><span <li><a href="#"><i class="fas fa-play"></i><span
class="hide-menu"> Series</span></a> class="hide-menu"> Series</span></a>
<ul aria-expanded="false" class="collapse">
<li><a href="{{ url_for('series') }}"> Series List</a></li>
<li><a href="{{ url_for('serieseditor') }}"> Mass Editor</a></li>
</ul>
</li> </li>
{% endif %} {% endif %}
{% if settings.general.getboolean('use_radarr') %} {% if settings.general.getboolean('use_radarr') %}
@ -256,10 +264,12 @@
<script src="{{ url_for('static',filename='datatables/jquery.dataTables.min.js') }}"></script> <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.rowGroup.min.js') }}"></script>
<script src="{{ url_for('static',filename='datatables/dataTables.responsive.min.js') }}"></script> <script src="{{ url_for('static',filename='datatables/dataTables.responsive.min.js') }}"></script>
<script src="{{ url_for('static',filename='datatables/dataTables.select.min.js') }}"></script>
<script src="{{ url_for('static',filename='datatables/dataTables.buttons.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='plugins/datatables.net-bs4/js/dataTables.bootstrap4.min.js') }}"></script>
<script src="{{ url_for('static',filename='js/custom.js') }}"></script> <script src="{{ url_for('static',filename='js/custom.js') }}"></script>
<script src="{{ url_for('static',filename='js/socket.io.js') }}"></script> <script src="{{ url_for('static',filename='js/socket.io.js') }}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/js/bootstrap-select.min.js"></script> <script src="{{ url_for('static',filename='js/bootstrap-select.min.js') }}"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {

@ -660,6 +660,9 @@
$('#edit_languages_select').empty(); $('#edit_languages_select').empty();
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').selectpicker({maxOptions: 1});
}
$.each(enabledLanguages, function (i, item) { $.each(enabledLanguages, function (i, item) {
$('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>'); $('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>');
}); });
@ -789,7 +792,7 @@
function seriesDetailsRefresh() { function seriesDetailsRefresh() {
$.ajax({ $.ajax({
url: "{{ url_for('api.series') }}?id={{id}}" url: "{{ url_for('api.series') }}?seriesid={{id}}"
}).done(function (data) { }).done(function (data) {
seriesDetails = data.data[0]; seriesDetails = data.data[0];
$(document).prop('title', seriesDetails['title'] + ' - Bazarr'); $(document).prop('title', seriesDetails['title'] + ' - Bazarr');
@ -828,7 +831,6 @@
function getLanguages() { function getLanguages() {
$.ajax({ $.ajax({
url: "{{ url_for('api.languages') }}?enabled=false", url: "{{ url_for('api.languages') }}?enabled=false",
async: false,
success:function(data) { success:function(data) {
availableLanguages = data; availableLanguages = data;
} }
@ -838,7 +840,6 @@
function getEnabledLanguages() { function getEnabledLanguages() {
$.ajax({ $.ajax({
url: "{{ url_for('api.languages') }}?enabled=true", url: "{{ url_for('api.languages') }}?enabled=true",
async: false,
success:function(data) { success:function(data) {
enabledLanguages = data; enabledLanguages = data;
} }

@ -142,9 +142,6 @@
}); });
var table = $('#series').DataTable({ var table = $('#series').DataTable({
"dom":
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"processing": false, "processing": false,
"serverSide": true, "serverSide": true,
"searching": false, "searching": false,
@ -229,6 +226,9 @@
$('#edit_languages_select').empty(); $('#edit_languages_select').empty();
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').selectpicker({maxOptions: 1});
}
$.each(enabledLanguages, function (i, item) { $.each(enabledLanguages, function (i, item) {
$('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>'); $('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>');
}); });
@ -267,7 +267,6 @@
function getLanguages() { function getLanguages() {
$.ajax({ $.ajax({
url: "{{ url_for('api.languages') }}?enabled=false", url: "{{ url_for('api.languages') }}?enabled=false",
async: false,
success:function(data) { success:function(data) {
availableLanguages = data; availableLanguages = data;
} }
@ -277,7 +276,6 @@
function getEnabledLanguages() { function getEnabledLanguages() {
$.ajax({ $.ajax({
url: "{{ url_for('api.languages') }}?enabled=true", url: "{{ url_for('api.languages') }}?enabled=true",
async: false,
success:function(data) { success:function(data) {
enabledLanguages = data; enabledLanguages = data;
} }

@ -1,188 +1,264 @@
<!DOCTYPE html> {% extends '_main.html' %}
<html lang="en">
<head> {% block title %}Series - Bazarr{% endblock %}
<script src="{{base_url}}static/jquery/jquery-latest.min.js"></script>
<script src="{{base_url}}static/semantic/semantic.min.js"></script> {% block bcleft %}
<script src="{{base_url}}static/jquery/tablesort.js"></script> <div id="buttons"></div>
<link rel="stylesheet" href="{{base_url}}static/semantic/semantic.min.css"> {% endblock bcleft %}
<link rel="apple-touch-icon" sizes="120x120" href="{{base_url}}static/apple-touch-icon.png"> {% block bcright %}
<link rel="icon" type="image/png" sizes="32x32" href="{{base_url}}static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="{{base_url}}static/favicon-16x16.png"> {% endblock bcright %}
<link rel="manifest" href="{{base_url}}static/manifest.json">
<link rel="mask-icon" href="{{base_url}}static/safari-pinned-tab.svg" color="#5bbad5"> {% block body %}
<link rel="shortcut icon" href="{{base_url}}static/favicon.ico"> <table id="series" class="table table-striped" style="width:100%">
<meta name="msapplication-config" content="{{base_url}}static/browserconfig.xml"> <thead>
<meta name="theme-color" content="#ffffff"> <tr>
<th></th>
<title>Series Editor - Bazarr</title> <th>Name</th>
<th>Audio Language</th>
<style> <th>Subtitles Languages</th>
body { <th>Hearing-Impaired</th>
background-color: #272727; <th>Forced</th>
} </tr>
#fondblanc { </thead>
background-color: #ffffff; </table>
border-radius: 0;
box-shadow: 0 0 5px 5px #ffffff; <div id="editModal" class="modal" tabindex="-1" role="dialog">
margin-top: 32px; <div class="modal-dialog modal-lg" role="document">
margin-bottom: 3em; <div class="modal-content">
padding: 2em 3em 2em 3em; <div class="modal-header">
} <h5 class="modal-title"><span id="edit_series_title_span"></span></h5><br>
#tableseries { <button type="button" class="close" data-dismiss="modal" aria-label="Close">
padding-top: 1em; <span aria-hidden="true">&times;</span>
} </button>
#bottommenu { </div>
background-color: #333333; <form class="form" name="edit_form" id="edit_form">
box-shadow: 0 0 10px 1px #333; <div class="modal-body">
padding: 10px; <div class="container-fluid">
} <div class="row">
#bottomform { <div class="col-sm-3 text-right">
width: 100%; Audio Language
padding-left: 8em; </div>
margin-bottom: -1em !important; <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_sonarrSeriesId" name="sonarrSeriesId" 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 === 'series' && event_json.action === 'insert') {
$.ajax({
url: "{{ url_for('api.series') }}?seriesid=" + event_json.series,
success: function (data) {
if (data.data.length) {
$('#series').DataTable().rows.add(data.data);
$('#series').DataTable().columns.adjust().draw(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]);
$('[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});
}
}
});
var table = $('#series').DataTable({
"processing": true,
"serverSide": true,
"searching": false,
"ordering": true,
"order": [ 1, 'asc'],
"lengthChange": true,
"responsive": true,
"paging": false,
"ajax": "{{ url_for('api.series') }}",
"columnDefs": [ {
"orderable": false,
"className": 'select-checkbox',
"targets": 0
} ],
"select": {
"style": 'multi',
"selector": 'td:first-child'
},
"columns": [
{"defaultContent": ""},
{"data": null,
"render": function (data) {
return '<a href="{{ url_for( 'episodes' ) }}' + data.sonarrSeriesId + '">' + data.title + '</a>'
}
},
{"data": "audio_language.name"},
{
"data": "languages",
"render": function (data) {
if (data !== 'None') {
var languages = '';
data.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.name + '">' + value.code2 + '</span> ';
}
}
},
{
"data": "hearing_impaired",
"className": "dt-center"
},
{
"data": "forced",
"className": "dt-center"
}
]
});
new $.fn.dataTable.Buttons( table, {
"buttons": [
'selectAll',
'selectNone'
]
} );
table.buttons().container().appendTo('#buttons');
});
$('#series').on('click', '.edit_button', function(e){
e.preventDefault();
$("#edit_series_title_span").html($(this).data('title'));
$("#edit_audio_language_span").html($(this).data('audiolanguage'));
$('#edit_sonarrSeriesId').val($(this).data('sonarrseriesid'));
$('#edit_languages_select').empty();
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').selectpicker({maxOptions: 1});
} }
</style> $.each(enabledLanguages, function (i, item) {
</head> $('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>');
<body> });
<div id='loader' class="ui page dimmer"> $("#edit_languages_select").selectpicker("refresh");
<div id="loader_text" class="ui indeterminate text loader">Loading...</div> var selected_languages = Array();
</div> $.each(Array.from($(this).data('languages')), function (i, item) {
% include('menu.tpl') selected_languages.push(item.code2);
});
<div id="fondblanc" class="ui container"> $('#edit_languages_select').selectpicker('val', selected_languages);
<table id="tableseries" class="ui very basic selectable sortable table"> $('#hi_checkbox').prop('checked', ($(this).data('hi') === 'True'));
<thead> $('#edit_forced_select').val($(this).data('forced')).change();
<tr>
<th class="no-sort collapsing"> $('#editModal')
<div class="ui checkbox"> .modal({
<input id='selectall' type="checkbox"> focus: false
<label></label> });
</div>
</th>
<th class="sorted ascending">Name</th>
<th>Audio Language</th>
<th>Subtitles Language(s)</th>
<th>Hearing-Impaired</th>
<th>Forced</th>
</tr>
</thead>
<tbody>
%import ast
%import os
%for row in rows:
<tr class="selectable">
<td class="collapsing">
<div class="ui checkbox">
<input id='{{row['sonarrSeriesId']}}' type="checkbox" class="selected">
<label></label>
</div>
</td>
<td><a href="{{base_url}}episodes/{{row['sonarrSeriesId']}}">{{row['title']}}</a></td>
<td>{{row['audio_language']}}</td>
<td>
%subs_languages = ast.literal_eval(str(row['languages']))
%if subs_languages is not None:
%for subs_language in subs_languages:
<div class="ui tiny label">{{subs_language}}</div>
%end
%end
</td>
<td>{{!"" if row['hearing_impaired'] is None else row['hearing_impaired']}}</td>
<td>{{!"" if row['forced'] is None else row['forced']}}</td>
</tr>
%end
</tbody>
</table>
</div>
<div id='bottommenu' class="ui inverted bottom fixed menu">
<form id='bottomform' action="{{base_url}}edit_serieseditor" method="POST" class="ui form">
<input type="hidden" name="series" id="checked" />
<div class="fields">
<div class="eight wide field">
<label style='color: white;'>Subtitles Language(s)</label>
<select name="languages" {{!'multiple="" ' if single_language is False else ''}}class="select ui disabled selection dropdown">
<option value="">No Change</option>
<option value="None">None</option>
%for language in languages:
<option value="{{language['code2']}}">{{language['name']}}</option>
%end
</select>
</div>
<div class="field">
<label style='color: white;'>Hearing-Impaired</label>
<select name="hearing_impaired" class="select ui disabled selection dropdown">
<option value="">No Change</option>
<option value="True">True</option>
<option value="False">False</option>
</select>
</div>
<div class="field">
<label style='color: white;'>Forced</label>
<select name="forced" class="select ui disabled selection dropdown">
<option value="">No change</option>
<option value="False">False</option>
<option value="True">True</option>
<option value="Both">Both</option>
</select>
</div>
<div class='field'>
<label style='color: white;'><span id='count'>0</span> Series Selected</label>
<button type="submit" id="save" name="save" value="save" class="ui disabled blue approve button">Save</button>
</div>
</div>
</form>
</div>
% include('footer.tpl')
<br><br><br><br>
</body>
</html>
<script>
if (sessionStorage.scrolly) {
$(window).scrollTop(sessionStorage.scrolly);
sessionStorage.clear();
}
$('table').tablesort();
$('a, button').on('click', function(){
$('#loader').addClass('active');
});
$('.modal')
.modal({
autofocus: false
}); });
$('.selected').on('change', function() { $('#edit_form').on('submit', function(e){
$("#count").text($('.selected:checked').length); e.preventDefault();
if ( $('.selected:checked').length > 0 ) { var formdata = new FormData(document.getElementById("edit_form"));
$('.select').removeClass('disabled');
$('#save').removeClass('disabled'); $.ajax({
} url: "{{ url_for('api.series') }}?seriesid=" + $('#edit_sonarrSeriesId').val(),
else { data: formdata,
$('.select').addClass('disabled'); processData: false,
$('#save').addClass('disabled'); contentType: false,
} type: 'POST',
success: function(){
const result = []; //seriesDetailsRefresh();
$('.selected:checked').each(function(i){ $('#editModal').modal('hide');
result.push($(this).attr('id')); }
});
}); });
$("#checked").val(result);
}); function getLanguages() {
$.ajax({
$('#selectall').on('change', function() { url: "{{ url_for('api.languages') }}?enabled=false",
if ( $('#selectall').is(":checked") ) { success:function(data) {
$('.selected').prop('checked', true).trigger('change'); availableLanguages = data;
} }
else { });
$('.selected').prop('checked', false).trigger('change'); }
}
}); function getEnabledLanguages() {
$.ajax({
$('.select').dropdown(); url: "{{ url_for('api.languages') }}?enabled=true",
</script> success:function(data) {
enabledLanguages = data;
}
});
}
</script>
{% endblock tail %}

Loading…
Cancel
Save