You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/views/settingssonarr.html

528 lines
24 KiB

5 years ago
{% extends '_main.html' %}
5 years ago
5 years ago
{% block title %}Sonarr - Bazarr{% endblock %}
5 years ago
5 years ago
{% block page_head %}
5 years ago
5 years ago
{% endblock page_head %}
{% block bcleft %}
<div class="">
<button class="btn btn-outline" id="save_button">
<div>
<span class="fa-stack">
<i class="fas fa-save fa-stack-2x align-top text-themecolor text-center font-20" aria-hidden="true"></i>
<i id="save_button_checkmark" class="fas fa-check fa-stack-2x" style="color:green;"></i>
</span>
5 years ago
</div>
5 years ago
<div class="align-bottom text-themecolor small text-center">Save</div>
</button>
</div>
{% endblock bcleft %}
{% block bcright %}
{% endblock bcright %}
{% block body %}
<div class="container-fluid" style="padding-top: 3em;">
<form class="form" name="settings_form" id="settings_form">
<h4>Use Sonarr</h4>
<hr/>
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<b>Enabled</b>
5 years ago
</div>
5 years ago
<div class="form-group col-sm-1">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="settings-general-use_sonarr" name="settings-general-use_sonarr">
<span class="custom-control-label" for="settings-general-use_sonarr"></span>
</label>
5 years ago
</div>
</div>
5 years ago
<br>
5 years ago
5 years ago
<div id="sonarr_div">
<h4>Host</h4>
<hr/>
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<b>Hostname or IP Address</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-sonarr-ip" name="settings-sonarr-ip" value="{{settings.sonarr.ip}}">
5 years ago
<label>Hostname or IP4 Address of Sonarr</label>
5 years ago
</div>
5 years ago
</div>
5 years ago
<br>
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<b>Port Number</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-sonarr-port" name="settings-sonarr-port" value="{{settings.sonarr.port}}">
5 years ago
<label>TCP Port of Sonarr</label>
5 years ago
</div>
</div>
5 years ago
<br>
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<b>URL Base</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-sonarr-base_url" name="settings-sonarr-base_url" value="{{settings.sonarr.base_url}}">
5 years ago
<label>Base URL for Sonarr (default: '/')</label>
5 years ago
</div>
5 years ago
</div>
5 years ago
<br>
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<b>SSL Enabled</b>
</div>
<div class="form-group col-sm-1">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="settings-sonarr-ssl" name="settings-sonarr-ssl">
<span class="custom-control-label" for="settings-sonarr-ssl"></span>
</label>
</div>
5 years ago
</div>
5 years ago
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<b>API Key</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-sonarr-apikey" name="settings-sonarr-apikey" value="{{settings.sonarr.apikey}}">
5 years ago
<label>API Key for Sonarr (32 alphanumeric characters)</label>
5 years ago
</div>
</div>
5 years ago
<br>
5 years ago
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<button type="button" class="btn btn-secondary" id="test_sonarr_connection">Test</button>
</div>
<div class="col-sm-4">
<span id="test_sonarr_span"></span>
</div>
</div>
<br>
5 years ago
<h4>Options</h4>
<hr/>
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<b>Minimum Score</b>
</div>
<div class="col-sm-8">
<input class="slider" id="settings-general-minimum_score" name="settings-general-minimum_score" data-slider-id='settings-general-minimum_score' type="text" data-slider-min="1" data-slider-max="100" data-slider-step="1" data-slider-value="{{settings.general.minimum_score}}"/>
<span class="slider_span"></span>
5 years ago
</div>
5 years ago
</div>
5 years ago
<div class="row">
<div class="col-sm-3 text-right">
</div>
<div class="col-sm-8">
<label for="settings-general-minimum_score">Minimum score for an Episodes Subtitle to be downloaded (0 to 100).</label>
</div>
</div>
5 years ago
<br>
<div class="row">
5 years ago
<div class="col-sm-3 text-right">
5 years ago
<b>Download Only Monitored</b>
</div>
5 years ago
<div class="form-group col-sm-8">
5 years ago
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="settings-sonarr-only_monitored" name="settings-sonarr-only_monitored">
<span class="custom-control-label" for="settings-sonarr-only_monitored"></span>
</label>
5 years ago
<label>Automatic download of Subtitles will only happen for monitored episodes in Sonarr.</label>
5 years ago
</div>
5 years ago
</div>
<div class="row">
<div class="col-sm-3 text-right">
<b>Excluded Tags</b>
</div>
<div class="form-group col-sm-8">
<input type="text" id="settings-sonarr-excluded_tags" name="settings-sonarr-excluded_tags" data-role="tagsinput">
<label>Episodes from series with those tags (case sensitive) in Sonarr will be excluded from automatic download of Subtitles.</label>
</div>
</div>
<div class="row">
<div class="col-sm-3 text-right">
<b>Excluded Series Types</b>
</div>
<div class="form-group col-sm-8">
<select class="form-control selectpicker" id="settings-sonarr-excluded_series_types" name="settings-sonarr-excluded_series_types" multiple>
<option value="standard">Standard</option>
<option value="anime">Anime</option>
<option value="daily">Daily</option>
</select>
<label for="settings-sonarr-excluded_series_types">Episodes from series with those types in Sonarr will be excluded from automatic download of Subtitles.</label><br>
</div>
</div>
5 years ago
<br>
5 years ago
<h4>Path Mappings</h4>
5 years ago
<hr/>
4 years ago
<h5>Some tips to ensure things goes smoothly:</h5>
<ul>
<li>You should create a mapping for each Root Folders you have configured in Sonarr</li>
<li>Point Bazarr to the folder containing all of your tv shows, not a specific one. eg. "/tv shows" and not "/tv shows/the simpsons"</li>
<li>UNC path under Windows must be typed manually. eg. "\\server\share"</li>
</ul>
5 years ago
<div class="row">
5 years ago
<div class="col-sm-8">
<table class="table table-striped" id="path_mapping" style="width:100%;">
5 years ago
5 years ago
</table>
</div>
5 years ago
</div>
5 years ago
<br>
5 years ago
</div>
5 years ago
</form>
5 years ago
</div>
5 years ago
<div id="addModal" 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">Add Path Mapping</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="add_form" id="add_form">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 text-right">
Path for Sonarr
</div>
<div class="col-sm-8">
4 years ago
<input type="text" class="form-control" id="add_path_sonarr" name="add_path_sonarr" value="" placeholder="Browse or type...">
<div class="filetree" id="sonarr_browser"></div>
5 years ago
</div>
</div>
<br>
<div class="row">
<div class="col-sm-3 text-right">
Path for Bazarr
</div>
<div class="col-sm-8">
4 years ago
<input type="text" class="form-control" id="add_path_bazarr" name="add_path_bazarr" value="" placeholder="Browse or type...">
<div class="filetree" id="bazarr_browser"></div>
5 years ago
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" id="add_save_button" class="btn btn-info">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<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">Edit Path Mapping</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">
Path for Sonarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="edit_path_sonarr" name="edit_path_sonarr" value="">
</div>
</div>
<br>
<div class="row">
<div class="col-sm-3 text-right">
Path for Bazarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="edit_path_bazarr" name="edit_path_bazarr" value="">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" id="edit_save_button" class="btn btn-info">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<div id="deleteModal" 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">Delete Path Mapping</h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to delete this path mapping?
</div>
<div class="modal-footer">
<button type="submit" id="delete_yes_button" class="btn btn-info">Yes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
5 years ago
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
5 years ago
// Show warning if there's unsaved changes in the settings_form
var form_changed = false;
$(window).on('beforeunload', function() {
if (form_changed) {
return "";
}
});
5 years ago
// Hide checkmark over save button
$('#save_button_checkmark').hide();
5 years ago
$('#save_button').prop('disabled', true).css('cursor', 'not-allowed');
5 years ago
// Set Select input values
var types = jQuery.makeArray({{ settings.sonarr.excluded_series_types|safe }})
$('#settings-sonarr-excluded_series_types').selectpicker('val', types);
5 years ago
// Hide *_div on Select input changed to None
$('#settings-general-use_sonarr').on('change', function() {
if ($(this).prop('checked')) {
$('#sonarr_div').show();
} else {
$('#sonarr_div').hide();
}
});
// Set tags input values
$('settings-sonarr-excluded_tags').tagsinput({
confirmKeys: [9, 13, 32, 44]
});
var tags = jQuery.makeArray({{ settings.sonarr.excluded_tags|safe }})
$(tags).each(function (index, value) {
$('#settings-sonarr-excluded_tags').tagsinput('add', value);
});
$('#settings-sonarr-excluded_tags').tagsinput('refresh');
5 years ago
// Set Checkbox input values
5 years ago
$('#settings-general-use_sonarr').prop('checked', {{'true' if settings.general.getboolean('use_sonarr') else 'false'}}).trigger('change');
$('#settings-sonarr-ssl').prop('checked', {{'true' if settings.sonarr.getboolean('ssl') else 'false'}});
$('#settings-sonarr-only_monitored').prop('checked', {{'true' if settings.sonarr.getboolean('only_monitored') else 'false'}});
5 years ago
$('#save_button').on('click', function() {
var formdata = new FormData(document.getElementById("settings_form"));
// Make sure all checkbox input are sent with true/false value
$('input[type=checkbox]').each(function () {
formdata.set($(this).prop('id'), $(this).prop('checked'));
});
5 years ago
formdata.append('settings-general-path_mappings', JSON.stringify(table.rows().data().toArray()));
formdata.set('settings-sonarr-excluded_tags', JSON.stringify($("#settings-sonarr-excluded_tags").tagsinput('items')));
5 years ago
var types_array = [];
$('#settings-sonarr-excluded_series_types :selected').each(function(i, selected){
types_array[i] = $(selected).val();
});
formdata.set('settings-sonarr-excluded_series_types', JSON.stringify(types_array));
5 years ago
$.ajax({
url: "{{ url_for('api.savesettings') }}",
data: formdata,
processData: false,
contentType: false,
type: 'POST',
complete: function () {
$('#save_button_checkmark').show();
5 years ago
form_changed = false;
5 years ago
$('#save_button').prop('disabled', true).css('cursor', 'not-allowed');
5 years ago
setTimeout(
function()
{
$('#save_button_checkmark').hide();
}, 2000);
}
});
});
5 years ago
var path_mapping = jQuery.makeArray({{ settings.general.path_mappings|safe }})
path_mapping = $.grep(path_mapping, function(v) {
return v[0] !== "" || v[1] !== "";
});
var table = $('#path_mapping').DataTable({
data: path_mapping,
5 years ago
columns: [{
5 years ago
title: "Path for Sonarr",
type: "text"
},
{
title: "Path for Bazarr",
type: "text"
}],
dom: 'Bfrtip',
select: {
style: 'single'
},
language: {
zeroRecords: 'No Path Mappings'
},
searching: false,
ordering: false,
lengthChange: true,
5 years ago
responsive: true,
5 years ago
paging: false,
info: false,
5 years ago
buttons: [{
text: 'Add',
5 years ago
action: function () {
if (form_changed) {
alert('You must save changes before adding a path mapping.')
} else {
$('#addModal').modal('show');
}
5 years ago
}
5 years ago
},
{
5 years ago
extend: 'selected',
5 years ago
text: 'Edit',
5 years ago
action: function () {
$('#edit_path_sonarr').val(table.row( { selected: true } ).data()[0]);
$('#edit_path_bazarr').val(table.row( { selected: true } ).data()[1]);
$('#editModal').modal('show');
}
5 years ago
},
{
5 years ago
extend: 'selected',
5 years ago
text: 'Delete',
5 years ago
action: function () {
$('#deleteModal').modal('show');
}
5 years ago
}]
});
5 years ago
4 years ago
$('#addModal').on('hidden.bs.modal', function() {
$('#add_form')[0].reset();
$('#sonarr_browser').jstree('destroy');
$('#sonarr_browser').slimScroll({destroy: true});
$('#bazarr_browser').jstree('destroy');
$('#bazarr_browser').slimScroll({destroy: true});
})
$('#addModal').on('show.bs.modal', function() {
$('#sonarr_browser').slimScroll({
height: '200px',
start: 'top'
});
$('#sonarr_browser').jstree({
'core' : {
'data' : {
'url' : '{{ url_for('api.browsesonarrfs') }}',
'data' : function (node) {
if (node.original === undefined) {
return {'path': ''};
} else {
return {'path': node.original.path};
}
}
},
'themes' : {
'dots' : false
4 years ago
}
}
}).on('changed.jstree', function (e, data) {
$('#add_path_sonarr').val(data.node.original.path);
});
$('#bazarr_browser').slimScroll({
height: '200px',
start: 'top'
});
$('#bazarr_browser').jstree({
'core' : {
'data' : {
'url' : '{{ url_for('api.browsebazarrfs') }}',
'data' : function (node) {
if (node.original === undefined) {
return {'path': ''};
} else {
return {'path': node.original.path};
}
}
},
'themes' : {
'dots' : false
4 years ago
}
}
}).on('changed.jstree', function (e, data) {
$('#add_path_bazarr').val(data.node.original.path);
});
})
5 years ago
$('#add_save_button').on('click', function(e) {
e.preventDefault();
table.row.add([ $('#add_path_sonarr').val(), $('#add_path_bazarr').val()]).draw();
$('#addModal').modal('hide');
5 years ago
$('#settings_form').trigger('change');
5 years ago
});
$('#edit_save_button').on('click', function(e) {
e.preventDefault();
table.row( { selected: true } ).data([ $('#edit_path_sonarr').val(), $('#edit_path_bazarr').val()]);
$('#editModal').modal('hide');
5 years ago
$('#settings_form').trigger('change');
5 years ago
});
$('#delete_yes_button').on('click', function(e) {
e.preventDefault();
table.row( { selected: true } ).remove().draw();
$('#deleteModal').modal('hide');
5 years ago
$('#settings_form').trigger('change');
5 years ago
});
$('#test_sonarr_connection').on('click', function() {
5 years ago
$('#test_sonarr_span').html('<div class="spinner-border" role="status"><span class="sr-only">Loading...</span></div>');
5 years ago
if ($('#settings-sonarr-ssl').is(':checked')) {
var protocol = 'https';
} else {
var protocol = 'http';
}
var sonarr_url = $('#settings-sonarr-ip').val() + ":" + $('#settings-sonarr-port').val() + $('#settings-sonarr-base_url').val().replace(/\/$/, "") + "/api/system/status?apikey=" + $('#settings-sonarr-apikey').val();
$.getJSON("{{ url_for('test_url') }}/" + protocol + "/" + encodeURIComponent(sonarr_url), function (data) {
if (data.status) {
$('#test_sonarr_span').text('Test Successful: Sonarr v' + data.version).css('color', 'green');
} else {
5 years ago
console.log(data);
$('#test_sonarr_span').text('Test Failed: ' + data.error).css('color', 'red');
5 years ago
}
});
});
5 years ago
// monitor changes to the settings_form
$('#settings_form').on('change', function() {
form_changed = true;
5 years ago
$('#save_button').prop('disabled', false).css('cursor', 'auto');
5 years ago
})
5 years ago
});
5 years ago
</script>
{% endblock tail %}