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/movie.html

937 lines
31 KiB

5 years ago
{% extends '_main.html' %}
{% block title %}Movie - Bazarr{% endblock %}
5 years ago
{% block page_head %}
5 years ago
<style>
#movieFanart {
background-repeat: no-repeat;
background-size: cover;
background-position: top center;
box-sizing: initial;
margin-left: -32px;
5 years ago
margin-top: -5px;
5 years ago
padding: 2em;
}
5 years ago
#movieDetails {
padding: 30px;
background: rgba(0, 0, 0, 0.7);
color: white;
margin: -32px;
}
5 years ago
#moviePoster {
5 years ago
max-height: 250px;
5 years ago
}
5 years ago
h1 {
color: white;
}
5 years ago
span {
margin-right: 0.5em;
}
5 years ago
.badge {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: middle;
}
5 years ago
</style>
5 years ago
{% endblock page_head %}
5 years ago
{% block bcleft %}
<div class="">
<button class="btn btn-outline" id="scan_button">
<div><i class="fas fa-sync align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Scan Disk</div>
</button>
<button class="btn btn-outline" id="search_button">
<div><i class="fas fa-search align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Search</div>
</button>
5 years ago
<button class="btn btn-outline" id="manual_button">
<div><i class="fas fa-user align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Manual</div>
</button>
<button class="btn btn-outline" id="upload_button">
<div><i class=" fas fa-cloud-upload-alt align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Upload</div>
</button>
<button class="btn btn-outline" id="history_button">
<div><i class="fas fa-history align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">History</div>
</button>
<button class="btn btn-outline" id="tools_button">
<div><i class="fa fa-briefcase align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Tools</div>
</button>
5 years ago
</div>
{% endblock bcleft %}
{% block bcright %}
<div class="d-flex m-t-5 justify-content-end">
<button class="btn btn-outline" id="edit_button">
<div><i class="fas fa-wrench align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Edit Movie</div>
</button>
</div>
{% endblock bcright %}
{% block body %}
<div class="container-fluid" id="movieFanart">
<div class="row justify-content-md-center" id="movieDetails">
<div class="col-sm-auto" id="moviePosterColumn">
<img id="moviePoster" src="">
</div>
5 years ago
<div class="col" id="movieDetailsColumn">
5 years ago
<div class="container-fluid">
<div class="row">
<h1><span id="movieTitle"></span></h1>
<i class="far fa-clone" id="moviealternativeTitles" data-toggle="tooltip" data-placement="right" title="None" data-html="true"></i>
7 years ago
</div>
5 years ago
<div class="row">
<h5><span id="movieAudioLanguage" class="badge badge-secondary"></span></h5>
5 years ago
<h5><span id="movieMappedPath" data-toggle="tooltip" data-placement="right" title="None" class="badge badge-secondary"></span></h5>
5 years ago
</div>
<div class="row">
<h5><span id="movieSubtitlesLanguages"></span></h5>
</div>
<div class="row">
<h5><span id="movieHearingImpaired" class="badge badge-secondary"></span></h5>
<h5><span id="movieForced" class="badge badge-secondary"></span></h5>
</div>
<div class="row">
<span id="movieDescription"></span>
</div>
7 years ago
</div>
</div>
5 years ago
</div>
</div>
5 years ago
<!-- Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<table id="movieSubtitles" class="table table-striped" style="width:100%">
<thead>
<tr>
<th>Subtitles Path</th>
<th>Language(s)</th>
<th></th>
</tr>
</thead>
</table>
<br>
<h5 style="font-weight: 500;">Missing Subtitles</h5>
<span id="missingSubtitles"></span>
5 years ago
<div id="manualSearchModal" class="modal" tabindex="-1" role="dialog" data-backdrop="static">
<div class="modal-dialog modal-xl" role="document">
5 years ago
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><span id="movie_title_span"></span></h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
5 years ago
<div class="modal-body">
<h6>Movie path is: <span id="movie_path_span" class="badge badge-secondary"></span>
<br>Scenename is: <span id="movie_scenename_span" class="badge badge-secondary"></span></h6>
<div class="container-fluid" style="padding:0px;">
5 years ago
<table id="search_result" class="table table-striped" style="width:100%">
5 years ago
<thead>
<tr>
<th style="text-align: left;">Score:</th>
<th></th>
<th style="text-align: left;">Provider:</th>
<th style="text-align: left;">Matching:</th>
<th style="text-align: left;">Releases:</th>
<th style="text-align: left;">Uploader:</th>
5 years ago
<th></th>
</tr>
5 years ago
</thead>
</table>
</div>
</div>
5 years ago
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
5 years ago
</div>
</div>
<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">
<h5 class="modal-title"><span id="upload_movie_title_span"></span></h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
5 years ago
<form class="form" name="upload_form" id="upload_form">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-2 text-right">
Language
</div>
5 years ago
<div class="form-group col-sm-8 pl-sm-0">
<select class="selectpicker" id="manual_language_select" name="language"></select>
</div>
</div>
5 years ago
<div class="row">
<div class="col-sm-2 text-right">
Forced
</div>
5 years ago
<div class="form-group col-sm-1 pl-sm-0">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="forced_checkbox" name="forced">
<span class="custom-control-label" for="forced_checkbox"></span>
</label>
</div>
</div>
5 years ago
<div class="row">
<div class="col-sm-2 text-right">
File
</div>
5 years ago
<div class="form-group col-sm-7 pl-sm-0">
<div class="custom-file">
<input type="file" class="custom-file-input" id="upload" name="upload">
<label class="custom-file-label" for="upload">Choose file</label>
</div>
</div>
</div>
</div>
5 years ago
<input type="hidden" id="upload_moviePath" name="moviePath" value="" />
<input type="hidden" id="upload_sceneName" name="sceneName" value="" />
<input type="hidden" id="upload_radarrId" name="radarrId" value="" />
<input type="hidden" id="upload_title" name="title" value="" />
5 years ago
<input type="hidden" id="upload_audioLanguage" name="audioLanguage" value="" />
5 years ago
</div>
<div class="modal-footer">
5 years ago
<button type="submit" id="upload_save_button" class="btn btn-info">Save</button>
5 years ago
<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"><span id="edit_movie_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">
5 years ago
<button type="submit" id="edit_save_button" class="btn btn-info">Save</button>
5 years ago
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<div id="movieHistoryModal" class="modal" tabindex="-1" role="dialog">
5 years ago
<div class="modal-dialog modal-xl" role="document">
5 years ago
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><span id="movie_history_title_span"></span></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">
<div class="container-fluid">
5 years ago
<table id="movie_history_result" class="table table-striped" style="width:100%">
5 years ago
<thead>
<tr>
<th></th>
<th style="text-align: left;">Language.:</th>
<th style="text-align: left;">Provider:</th>
<th style="text-align: left;">Score:</th>
<th style="text-align: left;">Date:</th>
</tr>
</thead>
</table>
</div>
</div>
5 years ago
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
5 years ago
</div>
</div>
<div id="movieToolsModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><span id="movie_tools_title_span"></span></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">
<div class="container-fluid">
<table id="movie_tools_result" class="table table-striped" style="width:100%">
<thead>
<tr>
<th style="text-align: left;">Language:</th>
<th style="text-align: left;">Filename:</th>
<th style="text-align: left;">Sync:</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
5 years ago
{% endblock body %}
5 years ago
{% block tail %}
7 years ago
<script>
5 years ago
// 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){
var fileName = document.getElementById("upload").files[0].name;
var nextSibling = e.target.nextElementSibling;
nextSibling.innerText = fileName;
});
5 years ago
$('#movies_nav').addClass("active");
5 years ago
movieDetailsRefresh();
getLanguages();
getEnabledLanguages();
5 years ago
//test
5 years ago
$('#movieSubtitles').on('click', '.remove_subtitles', function(e){
5 years ago
$(this).tooltip('dispose');
e.preventDefault();
const values = {
5 years ago
moviePath: movieDetails['mapped_path'],
language: $(this).data("language"),
subtitlesPath: $(this).data("subtitlespath"),
5 years ago
radarrId: movieDetails['radarrId'],
tmdbid: movieDetails['tmdbId']
5 years ago
};
5 years ago
var cell = $(this).parent();
5 years ago
$.ajax({
5 years ago
url: "{{ url_for('api.moviesubtitlesdelete') }}",
5 years ago
type: "DELETE",
dataType: "json",
data: values,
beforeSend: function() {
cell.html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
}
});
});
5 years ago
5 years ago
$(document).on('click', '.get_subtitle', function(e){
5 years ago
$(this).tooltip('dispose');
e.preventDefault();
const values = {
5 years ago
moviePath: movieDetails['mapped_path'],
sceneName: movieDetails['sceneName'],
5 years ago
language: $(this).attr("data-language"),
5 years ago
hi: movieDetails['hearing_impaired'],
5 years ago
forced:$(this).attr("data-forced"),
5 years ago
radarrId: movieDetails['radarrId'],
title: movieDetails['title']
5 years ago
};
5 years ago
var button = $(this).closest('button' + '');
5 years ago
$.ajax({
5 years ago
url: "{{ url_for('api.moviesubtitlesdownload') }}",
5 years ago
type: "POST",
dataType: "json",
data: values,
beforeSend: function() {
5 years ago
button.html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
5 years ago
}
});
});
7 years ago
5 years ago
$('#manual_button').on('click', function(e){
5 years ago
e.preventDefault();
5 years ago
$("#movie_title_span").html(movieDetails['title']);
5 years ago
$("#movie_path_span").html(movieDetails['mapped_path']);
$("#movie_scenename_span").html(movieDetails['sceneName']);
5 years ago
5 years ago
moviePath = movieDetails['mapped_path'];
sceneName = movieDetails['sceneName'];
language = movieDetails['desired_languages'];
5 years ago
hi = movieDetails['hearing_impaired'];
forced = movieDetails['forced'];
radarrId = movieDetails['radarrId'];
var languages = Array.from(movieDetails['languages']);
5 years ago
var is_pb = languages.includes('pb');
var is_pt = languages.includes('pt');
const values = {
5 years ago
moviePath: moviePath,
5 years ago
sceneName: sceneName,
language: language,
hi: hi,
forced: forced,
5 years ago
radarrId: radarrId,
title: movieDetails['title']
5 years ago
};
$('#search_result').DataTable( {
destroy: true,
language: {
5 years ago
zeroRecords: 'No Subtitles Found For This Movie',
processing: "Searching{% if settings.general.anti_captcha_provider != 'None' %} (possibly solving captcha){% endif %}...",
search: "Filter:"
5 years ago
},
paging: true,
lengthChange: true,
pageLength: {{ settings.general.page_size_manual_search }},
lengthMenu: [ 5, 10, 15, 20, 25 ],
searching: true,
5 years ago
scrollX: true,
5 years ago
ordering: false,
processing: true,
serverSide: false,
ajax: {
5 years ago
url: '{{ url_for('api.moviesubtitlesmanualsearch') }}',
5 years ago
type: 'POST',
data: values
},
columns: [
{ data: 'score',
render: function ( data ) {
return data +'%';
}
},
{ data: null,
render: function ( data ) {
let lng = data.language;
5 years ago
if ( data.language === "pt" && is_pb === true && is_pt === false) {
lng = 'pb'
}
let text = '<div class="badge badge-secondary" style="margin:1px;">' + lng.toUpperCase() + '</div>';
if (data.hearing_impaired == "True") {
text += '<div class="badge badge-dark" style="margin:1px;">HI</div>';
5 years ago
}
return text;
5 years ago
}
},
{ data: null,
render: function ( data ) {
return '<a href="'+data.url+'" target="_blank">'+data.provider+'</a>';
}
},
{ data: null,
searchable: false,
5 years ago
render: function ( data ) {
const array_matches = data.matches;
const array_dont_matches = data.dont_matches;
let i;
let text = '<div class="dropdown"><div class="btn-group dropdown"><button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="margin:1px;"><i class="fas fa-check-circle" style="color: green;"></i> '+array_matches.length+'</button><div class="dropdown-menu" aria-labelledby="dropdownMenuButton">';
5 years ago
for (i = 0; i < array_matches.length; i++) {
text += '<a class="dropdown-item disabled" href="#">' + array_matches[i] + '</a>';
}
text += '</div>';
text += '<div class="dropdown"><button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="margin:1px;"><i class="fas fa-times-circle" style="color: red;"></i> '+array_dont_matches.length+'</button><div class="dropdown-menu" aria-labelledby="dropdownMenuButton">';
5 years ago
for (i = 0; i < array_dont_matches.length; i++) {
text += '<a class="dropdown-item disabled" href="#">' + array_dont_matches[i] + '</a>';
}
text += '</div></div></div>';
return text;
}
},
{ data: null,
render: function ( data ) {
const array_release_info = data.release_info;
let i;
let text;
if (array_release_info.length == 1) {
text = '<div style="font-size: 75%;font-weight: 400;">' + array_release_info[0] + '</div>';
}
else {
text = '<div class="dropdown"><button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="\tfas fa-comment-dots"></i> ' + array_release_info.length + '</button><div class="dropdown-menu" aria-labelledby="dropdownMenuButton">';
for (i = 0; i < array_release_info.length; i++) {
text += '<a class="dropdown-item" href="#">' + array_release_info[i] + '</a>';
}
text += '</div></div>';
}
5 years ago
return text;
}
},
{ data: 'uploader',
render: function ( data ) {
return '<div class="badge badge-secondary">' + data + '</div>';
}
},
5 years ago
{ data: null,
searchable: false,
5 years ago
render: function ( data ) {
5 years ago
return '<a href="" class="manual_download badge badge-secondary" data-moviePath="'+moviePath+'" data-sceneName="'+sceneName+'" data-subtitle="'+data.subtitle+'" data-provider="'+data.provider+'" data-language="'+data.language+'" data-forced="'+forced+'"><i class="fas fa-download" style="margin-right:0px" ></i></a>';
5 years ago
}
}
]
} );
5 years ago
$('#manualSearchModal')
.modal({
focus: false
});
});
5 years ago
$('#search_result').on('click', '.manual_download', function(e){
e.preventDefault();
const values = {
5 years ago
moviePath: $(this).attr("data-moviepath"),
5 years ago
sceneName: $(this).attr("data-scenename"),
language: $(this).attr("data-language"),
5 years ago
hi: movieDetails['hearing_impaired'],
5 years ago
forced: $(this).attr("data-forced"),
provider: $(this).attr("data-provider"),
subtitle: $(this).attr("data-subtitle"),
5 years ago
radarrId: movieDetails['radarrId'],
title: movieDetails['title']
5 years ago
};
5 years ago
var cell = $(this).parent();
5 years ago
$.ajax({
5 years ago
url: "{{ url_for('api.moviesubtitlesmanualdownload') }}",
5 years ago
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) {
$('#manualSearchModal').modal('hide');
}
});
});
5 years ago
5 years ago
$('#upload_button').on('click', function(e){
5 years ago
e.preventDefault();
5 years ago
$("#upload_movie_title_span").html(movieDetails['title']);
5 years ago
$('#upload_moviePath').val(movieDetails['mapped_path']);
$('#upload_sceneName').val(movieDetails['sceneName']);
$('#upload_radarrId').val(movieDetails['radarrId']);
$('#upload_title').val(movieDetails['title']);
$('#upload_audioLanguage').val(movieDetails['audio_language']['name']);
5 years ago
$('#manual_language_select').empty();
$.each(enabledLanguages, function (i, item) {
$('#manual_language_select').append('<option value="'+item.code2+'">'+item.name+'</option>');
});
$("#manual_language_select").selectpicker("refresh");
$('#uploadModal')
.modal({
focus: false
});
});
5 years ago
$('#upload_form').on('submit', function(e){
e.preventDefault();
var formdata = new FormData(document.getElementById("upload_form"));
$.ajax({
5 years ago
url: "{{ url_for('api.moviesubtitlesupload') }}",
5 years ago
data: formdata,
processData: false,
contentType: false,
type: 'POST',
beforeSend: function () {
$('#upload_save_button').html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
},
complete: function(){
5 years ago
$('#uploadModal').modal('hide');
}
});
});
7 years ago
5 years ago
$('#scan_button').on('click', function(e){
e.preventDefault();
$.ajax({
5 years ago
url: "{{ url_for('api.moviescandisk', radarrid=id) }}",
5 years ago
type: 'GET',
beforeSend: function() {
$('#scan_button').find("i").addClass('fa-spin');
},
complete: function() {
$('#scan_button').find("i").removeClass('fa-spin');
}
});
});
7 years ago
5 years ago
$('#search_button').on('click', function(e){
e.preventDefault();
$.ajax({
5 years ago
url: "{{ url_for('api.moviesearchmissing', radarrid=id) }}",
5 years ago
type: 'GET',
beforeSend: function() {
$('#search_button').find("i").addClass('fa-spin');
},
complete: function() {
$('#search_button').find("i").removeClass('fa-spin');
}
});
});
7 years ago
5 years ago
$('#edit_button').on('click', function(e){
e.preventDefault();
5 years ago
$("#edit_movie_title_span").html(movieDetails['title']);
$("#edit_audio_language_span").text(movieDetails['audio_language']['name']);
$('#edit_radarrId').val(movieDetails['radarrId']);
7 years ago
5 years ago
$('#edit_languages_select').empty();
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').selectpicker({maxOptions: 1});
$('#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();
5 years ago
$.each(Array.from(movieDetails['languages']), function (i, item) {
5 years ago
selected_languages.push(item.code2);
});
$('#edit_languages_select').selectpicker('val', selected_languages);
5 years ago
$('#hi_checkbox').prop('checked', (movieDetails['hearing_impaired'] === 'True'));
$('#edit_forced_select').val(movieDetails['forced']).change();
5 years ago
$('#editModal')
.modal({
focus: false
});
});
7 years ago
5 years ago
$('#edit_form').on('submit', function(e){
e.preventDefault();
var formdata = new FormData(document.getElementById("edit_form"));
5 years ago
$.ajax({
5 years ago
url: "{{ url_for('api.movies') }}?radarrid={{id}}",
5 years ago
data: formdata,
processData: false,
contentType: false,
type: 'POST',
success: function(){
5 years ago
movieDetailsRefresh();
5 years ago
$('#editModal').modal('hide');
}
});
});
7 years ago
5 years ago
$('#uploadModal').on('hidden.bs.modal', function () {
$(this).find('form')[0].reset();
});
5 years ago
events.on('event', function(event) {
var event_json = JSON.parse(event);
5 years ago
if (event_json.type === 'movie') {
if (event_json.movie === {{id}}) {
5 years ago
movieDetailsRefresh();
5 years ago
}
}
});
5 years ago
$('#history_button').on('click', function(e){
5 years ago
$(this).tooltip('dispose');
e.preventDefault();
5 years ago
$("#movie_history_title_span").html(movieDetails['title']);
5 years ago
5 years ago
radarrId = movieDetails['radarrId'];
5 years ago
5 years ago
$('#movie_history_result').DataTable( {
5 years ago
destroy: true,
language: {
5 years ago
zeroRecords: 'No History Records Found For This Movie'
},
5 years ago
paging: true,
lengthChange: false,
pageLength: 5,
searching: true,
ordering: false,
5 years ago
scrollX: true,
5 years ago
processing: false,
serverSide: false,
ajax: {
5 years ago
url: '{{ url_for( 'api.moviehistory' )}}?radarrid=' + radarrId
},
5 years ago
columns: [
{ data: 'action',
"render": function(data) {
if (data === 0) {return "<i class='fas fa-trash' title='Subtitle file has been erased.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 1) {return "<i class='fas fa-download' title='Subtitle file has been downloaded.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 2) {return "<i class='fas fa-user' title='Subtitle file has been manually downloaded.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 3) {return "<i class='fas fa-recycle' title='Subtitle file has been upgraded.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 4) {return "<i class='fas fa-cloud-upload-alt' title='Subtitle file has been manually uploaded.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 5) {return "<i class='fas fa-clock' title='Subtitle file has been synced.' data-toggle='tooltip' data-placement='right'></i>";}
5 years ago
}},
{ data: 'language' },
{ data: 'provider' },
{ data: 'score'},
{ data: 'timestamp' }
]
} );
5 years ago
$('#movieHistoryModal')
5 years ago
.modal({
focus: false
});
});
$('#tools_button').on('click', function (e) {
$(this).tooltip('dispose');
e.preventDefault();
$("#movie_tools_title_span").html(movieDetails['title']);
radarrId = movieDetails['radarrId'];
$('#movie_tools_result').DataTable({
destroy: true,
language: {
zeroRecords: 'No External Subtitles Found For This Movie'
},
paging: true,
lengthChange: false,
pageLength: 5,
searching: true,
ordering: false,
scrollX: true,
processing: false,
serverSide: false,
ajax: {
url: '{{ url_for( 'api.movietools' )}}?movieid=' + radarrId
},
columns: [
{data: 'language.name'},
{data: 'filename'},
{
data: null,
"render": function (data) {
return '<a href="" class="subtitles_sync badge badge-secondary" data-language="' + data.language.code3 + '" data-path="' + data.path + '" data-videopath="' + data.videopath + '"><i class="far fa-play-circle"></i></a>';
}
}
]
});
$('#movieToolsModal')
.modal({
focus: false
});
});
$('#movie_tools_result').on('click', '.subtitles_sync', function (e) {
e.preventDefault();
const values = {
language: $(this).attr("data-language"),
subtitlesPath: $(this).attr("data-path"),
videoPath: $(this).attr("data-videopath"),
mediaType: 'movies'
};
var cell = $(this).parent()
;
$.ajax({
url: "{{ url_for('api.syncsubtitles') }}",
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) {
$('#movieToolsModal').modal('hide');
}
});
});
});
5 years ago
function movieDetailsRefresh() {
$.ajax({
url: "{{ url_for('api.movies') }}?radarrid={{id}}"
}).done(function (data) {
movieDetails = data.data[0];
$(document).prop('title', movieDetails['title'] + ' - Bazarr');
$('#movieFanart').css('background-image', "url('{{ url_for('image_proxy_movies', url='MediaCover/'+id+'/fanart.jpg') }}')");
$('#moviePoster').attr("src", "{{ url_for('image_proxy_movies', url='MediaCover/'+id+'/poster-250.jpg') }}");
$('#movieTitle').text(movieDetails['title']);
if (movieDetails['alternativeTitles'].length > 0) {
$('#moviealternativeTitles').attr("data-original-title", "<b>Alternative Titles:</b><br>" + movieDetails['alternativeTitles']);
} else {
$('#moviealternativeTitles').hide();
}
5 years ago
$('#movieAudioLanguage').text(movieDetails['audio_language']['name']);
5 years ago
$('#movieMappedPath').text(movieDetails['mapped_path']);
5 years ago
$('#movieMappedPath').attr("data-original-title", movieDetails['mapped_path']);
5 years ago
var languages = '';
if (movieDetails['languages'] && movieDetails['languages'] !== 'None') {
5 years ago
movieDetails['languages'].forEach(appendFunc);
}
5 years ago
function appendFunc(value) {
5 years ago
languages += '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + '">' + value.code2 + '</span> ';
5 years ago
}
$('#movieSubtitlesLanguages').html(languages);
$('#movieHearingImpaired').text('Hearing-Impaired: ' + movieDetails['hearing_impaired']);
$('#movieForced').text('Forced: ' + movieDetails['forced']);
$('#movieDescription').text(movieDetails['overview']);
5 years ago
var missing_languages = '';
5 years ago
if (movieDetails['missing_subtitles'] !== 'None') {
movieDetails['missing_subtitles'].forEach(missingAppendFunc);
}
function missingAppendFunc(value) {
5 years ago
if (value.forced) {
missing_languages += '<button class="get_subtitle btn btn-secondary btn-sm" type="button" data-toggle="tooltip" data-placement="right" data-original-title="' + value.name + '" data-language="' + value.code3 + '" data-forced=' + value.forced + '>' + value.code2 + ':forced <i class="fas fa-search"></i></button> ';
} else {
missing_languages += '<button class="get_subtitle btn btn-secondary btn-sm" type="button" data-toggle="tooltip" data-placement="right" data-original-title="' + value.name + '" data-language="' + value.code3 + '" data-forced=' + value.forced + '>' + value.code2 + ' <i class="fas fa-search"></i></button> ';
}
5 years ago
}
$('#missingSubtitles').html(missing_languages);
5 years ago
$('[data-toggle="tooltip"]').tooltip({html: true});
5 years ago
5 years ago
if (movieDetails['desired_languages'] == '[]') {
$('#search_button').hide();
$('#manual_button').hide();
$('#upload_button').hide();
} else {
$('#search_button').show();
$('#manual_button').show();
$('#upload_button').show();
}
5 years ago
var table = $('#movieSubtitles').DataTable({
destroy: true,
language: {
zeroRecords: 'No Subtitles Found For This Movie'
},
"searching": false,
"ordering": false,
"paging": false,
"info": false,
"lengthChange": false,
5 years ago
"responsive": true,
5 years ago
"data" : movieDetails['subtitles'],
"columns" : [
{ "data" : null,
"render": function(data) {
if (data['path']) {
return data['path'];
} else {
return 'Video File Subtitles Track';
}
}
},
{ "data" : null,
"render": function(data) {
if (data['forced']) {
return '<span class="badge badge-secondary">' + data['name'] + ' forced</span>';
} else {
return '<span class="badge badge-secondary">' + data['name'] + '</span>';
}
}
5 years ago
},
{ "data" : null,
"render": function(data) {
if (data['path']) {
return '<button type="button" class="remove_subtitles close" aria-label="Close" data-toggle="tooltip" data-placement="right" title="Delete Subtitles File" data-language='+data['code3']+' data-subtitlesPath="'+data['path']+'"><span aria-hidden="true">&times;</span></button>';
} else {
return '';
}
}
5 years ago
}
]
});
5 years ago
});
}
5 years ago
function getLanguages() {
$.ajax({
5 years ago
url: "{{ url_for('api.languages') }}?enabled=false",
success:function(data) {
availableLanguages = data;
}
});
5 years ago
}
function getEnabledLanguages() {
$.ajax({
url: "{{ url_for('api.languages') }}?enabled=true",
success:function(data) {
enabledLanguages = data;
}
});
}
5 years ago
</script>
5 years ago
{% endblock tail %}