mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-21 05:27:09 +00:00
WIP
This commit is contained in:
parent
80a740c5bd
commit
d738bab732
4 changed files with 330 additions and 128 deletions
219
bazarr/api.py
219
bazarr/api.py
|
@ -5,6 +5,7 @@ from datetime import timedelta
|
||||||
import datetime
|
import datetime
|
||||||
import pretty
|
import pretty
|
||||||
import time
|
import time
|
||||||
|
from operator import itemgetter
|
||||||
|
|
||||||
from get_args import args
|
from get_args import args
|
||||||
from config import settings, base_url
|
from config import settings, base_url
|
||||||
|
@ -476,18 +477,24 @@ class Movies(Resource):
|
||||||
# Parse subtitles
|
# Parse subtitles
|
||||||
if item['subtitles']:
|
if item['subtitles']:
|
||||||
item.update({"subtitles": ast.literal_eval(item['subtitles'])})
|
item.update({"subtitles": ast.literal_eval(item['subtitles'])})
|
||||||
for subs in item['subtitles']:
|
for i, subs in enumerate(item['subtitles']):
|
||||||
subs[0] = {"name": language_from_alpha2(subs[0]),
|
language = subs[0].split(':')
|
||||||
"code2": subs[0],
|
item['subtitles'][i] = {"path": subs[1],
|
||||||
"code3": alpha3_from_alpha2(subs[0])}
|
"name": language_from_alpha2(language[0]),
|
||||||
|
"code2": language[0],
|
||||||
|
"code3": alpha3_from_alpha2(language[0]),
|
||||||
|
"forced": True if len(language) > 1 else False}
|
||||||
|
item['subtitles'] = sorted(item['subtitles'], key=itemgetter('name', 'forced'))
|
||||||
|
|
||||||
# Parse missing subtitles
|
# Parse missing subtitles
|
||||||
if item['missing_subtitles']:
|
if item['missing_subtitles']:
|
||||||
item.update({"missing_subtitles": ast.literal_eval(item['missing_subtitles'])})
|
item.update({"missing_subtitles": ast.literal_eval(item['missing_subtitles'])})
|
||||||
for i, subs in enumerate(item['missing_subtitles']):
|
for i, subs in enumerate(item['missing_subtitles']):
|
||||||
item['missing_subtitles'][i] = {"name": language_from_alpha2(subs),
|
language = subs[0].split(':')
|
||||||
"code2": subs,
|
item['missing_subtitles'][i] = {"name": language_from_alpha2(language[0]),
|
||||||
"code3": alpha3_from_alpha2(subs)}
|
"code2": language[0],
|
||||||
|
"code3": alpha3_from_alpha2(language[0]),
|
||||||
|
"forced": True if len(language) > 1 else False}
|
||||||
|
|
||||||
# Provide mapped path
|
# Provide mapped path
|
||||||
mapped_path = path_replace_movie(item['path'])
|
mapped_path = path_replace_movie(item['path'])
|
||||||
|
@ -563,6 +570,196 @@ class MoviesEditSave(Resource):
|
||||||
|
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
|
class MovieSubtitlesDelete(Resource):
|
||||||
|
def delete(self):
|
||||||
|
moviePath = request.form.get('moviePath')
|
||||||
|
language = request.form.get('language')
|
||||||
|
subtitlesPath = request.form.get('subtitlesPath')
|
||||||
|
radarrId = request.form.get('radarrId')
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.remove(path_replace_movie(subtitlesPath))
|
||||||
|
result = language_from_alpha3(language) + " subtitles deleted from disk."
|
||||||
|
history_log_movie(0, radarrId, result, language=alpha2_from_alpha3(language))
|
||||||
|
store_subtitles_movie(path_replace_reverse_movie(moviePath), moviePath)
|
||||||
|
return result, 202
|
||||||
|
except OSError as e:
|
||||||
|
logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath)
|
||||||
|
|
||||||
|
store_subtitles_movie(path_replace_reverse_movie(moviePath), moviePath)
|
||||||
|
return '', 204
|
||||||
|
|
||||||
|
|
||||||
|
class MovieSubtitlesDownload(Resource):
|
||||||
|
def post(self):
|
||||||
|
moviePath = request.form.get('moviePath')
|
||||||
|
sceneName = request.form.get('sceneName')
|
||||||
|
if sceneName == "null":
|
||||||
|
sceneName = "None"
|
||||||
|
language = request.form.get('language')
|
||||||
|
hi = request.form.get('hi').capitalize()
|
||||||
|
forced = request.form.get('forced').capitalize()
|
||||||
|
radarrId = request.form.get('radarrId')
|
||||||
|
title = request.form.get('title')
|
||||||
|
providers_list = get_providers()
|
||||||
|
providers_auth = get_providers_auth()
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = download_subtitle(moviePath, language, hi, forced, providers_list, providers_auth, sceneName,
|
||||||
|
title, 'movie')
|
||||||
|
if result is not None:
|
||||||
|
message = result[0]
|
||||||
|
path = result[1]
|
||||||
|
forced = result[5]
|
||||||
|
language_code = result[2] + ":forced" if forced else result[2]
|
||||||
|
provider = result[3]
|
||||||
|
score = result[4]
|
||||||
|
history_log_movie(1, radarrId, message, path, language_code, provider, score)
|
||||||
|
send_notifications_movie(radarrId, message)
|
||||||
|
store_subtitles_movie(path, moviePath)
|
||||||
|
return result, 201
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return '', 204
|
||||||
|
|
||||||
|
|
||||||
|
class MovieSubtitlesManualSearch(Resource):
|
||||||
|
def post(self):
|
||||||
|
start = request.args.get('start') or 0
|
||||||
|
length = request.args.get('length') or -1
|
||||||
|
draw = request.args.get('draw')
|
||||||
|
|
||||||
|
moviePath = request.form.get('moviePath')
|
||||||
|
sceneName = request.form.get('sceneName')
|
||||||
|
if sceneName == "null":
|
||||||
|
sceneName = "None"
|
||||||
|
language = request.form.get('language')
|
||||||
|
hi = request.form.get('hi').capitalize()
|
||||||
|
forced = request.form.get('forced').capitalize()
|
||||||
|
title = request.form.get('title')
|
||||||
|
providers_list = get_providers()
|
||||||
|
providers_auth = get_providers_auth()
|
||||||
|
|
||||||
|
data = manual_search(moviePath, language, hi, forced, providers_list, providers_auth, sceneName, title,
|
||||||
|
'movie')
|
||||||
|
row_count = len(data)
|
||||||
|
return jsonify(draw=draw, recordsTotal=row_count, recordsFiltered=row_count, data=data)
|
||||||
|
|
||||||
|
|
||||||
|
class MovieSubtitlesManualDownload(Resource):
|
||||||
|
def post(self):
|
||||||
|
moviePath = request.form.get('moviePath')
|
||||||
|
sceneName = request.form.get('sceneName')
|
||||||
|
if sceneName == "null":
|
||||||
|
sceneName = "None"
|
||||||
|
language = request.form.get('language')
|
||||||
|
hi = request.form.get('hi').capitalize()
|
||||||
|
forced = request.form.get('forced').capitalize()
|
||||||
|
selected_provider = request.form.get('provider')
|
||||||
|
subtitle = request.form.get('subtitle')
|
||||||
|
radarrId = request.form.get('radarrId')
|
||||||
|
title = request.form.get('title')
|
||||||
|
providers_auth = get_providers_auth()
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = manual_download_subtitle(moviePath, language, hi, forced, subtitle, selected_provider,
|
||||||
|
providers_auth, sceneName, title, 'movie')
|
||||||
|
if result is not None:
|
||||||
|
message = result[0]
|
||||||
|
path = result[1]
|
||||||
|
forced = result[5]
|
||||||
|
language_code = result[2] + ":forced" if forced else result[2]
|
||||||
|
provider = result[3]
|
||||||
|
score = result[4]
|
||||||
|
history_log_movie(2, radarrId, message, path, language_code, provider, score)
|
||||||
|
send_notifications_movie(radarrId, message)
|
||||||
|
store_subtitles_movie(path, moviePath)
|
||||||
|
return result, 201
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return '', 204
|
||||||
|
|
||||||
|
|
||||||
|
class MovieSubtitlesUpload(Resource):
|
||||||
|
def post(self):
|
||||||
|
moviePath = request.form.get('moviePath')
|
||||||
|
sceneName = request.form.get('sceneName')
|
||||||
|
if sceneName == "null":
|
||||||
|
sceneName = "None"
|
||||||
|
language = request.form.get('language')
|
||||||
|
forced = True if request.form.get('forced') == 'on' else False
|
||||||
|
upload = request.files.get('upload')
|
||||||
|
radarrId = request.form.get('radarrId')
|
||||||
|
title = request.form.get('title')
|
||||||
|
|
||||||
|
_, ext = os.path.splitext(upload.filename)
|
||||||
|
|
||||||
|
if ext not in SUBTITLE_EXTENSIONS:
|
||||||
|
raise ValueError('A subtitle of an invalid format was uploaded.')
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = manual_upload_subtitle(path=moviePath,
|
||||||
|
language=language,
|
||||||
|
forced=forced,
|
||||||
|
title=title,
|
||||||
|
scene_name=sceneName,
|
||||||
|
media_type='movie',
|
||||||
|
subtitle=upload)
|
||||||
|
|
||||||
|
if result is not None:
|
||||||
|
message = result[0]
|
||||||
|
path = result[1]
|
||||||
|
language_code = language + ":forced" if forced else language
|
||||||
|
provider = "manual"
|
||||||
|
score = 120
|
||||||
|
history_log_movie(4, radarrId, message, path, language_code, provider, score)
|
||||||
|
send_notifications_movie(radarrId, message)
|
||||||
|
store_subtitles_movie(path, moviePath)
|
||||||
|
|
||||||
|
return result, 201
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return '', 204
|
||||||
|
|
||||||
|
|
||||||
|
class MovieScanDisk(Resource):
|
||||||
|
def get(self):
|
||||||
|
radarrid = request.args.get('radarrid')
|
||||||
|
movies_scan_subtitles(radarrid)
|
||||||
|
return '', 200
|
||||||
|
|
||||||
|
|
||||||
|
class MovieSearchMissing(Resource):
|
||||||
|
def get(self):
|
||||||
|
radarrid = request.args.get('radarrid')
|
||||||
|
movies_download_subtitles(radarrid)
|
||||||
|
return '', 200
|
||||||
|
|
||||||
|
|
||||||
|
class MovieHistory(Resource):
|
||||||
|
def get(self):
|
||||||
|
radarrid = request.args.get('radarrid')
|
||||||
|
|
||||||
|
movie_history = database.execute("SELECT action, timestamp, language, provider, score "
|
||||||
|
"FROM table_history_movie WHERE radarrId=? ORDER BY timestamp DESC",
|
||||||
|
(radarrid,))
|
||||||
|
for item in movie_history:
|
||||||
|
item['timestamp'] = "<div title='" + \
|
||||||
|
time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(item['timestamp'])) + \
|
||||||
|
"' data-toggle='tooltip' data-placement='left'>" + \
|
||||||
|
pretty.date(datetime.datetime.fromtimestamp(item['timestamp'])) + "</div>"
|
||||||
|
if item['language']:
|
||||||
|
item['language'] = language_from_alpha2(item['language'])
|
||||||
|
else:
|
||||||
|
item['language'] = "<i>undefined</i>"
|
||||||
|
if item['score']:
|
||||||
|
item['score'] = str(round((int(item['score']) * 100 / 120), 2)) + "%"
|
||||||
|
|
||||||
|
return jsonify(data=movie_history)
|
||||||
|
|
||||||
|
|
||||||
class HistorySeries(Resource):
|
class HistorySeries(Resource):
|
||||||
def get(self):
|
def get(self):
|
||||||
|
@ -823,6 +1020,14 @@ api.add_resource(EpisodesHistory, '/episodes_history')
|
||||||
|
|
||||||
api.add_resource(Movies, '/movies')
|
api.add_resource(Movies, '/movies')
|
||||||
api.add_resource(MoviesEditSave, '/movies_edit_save')
|
api.add_resource(MoviesEditSave, '/movies_edit_save')
|
||||||
|
api.add_resource(MovieSubtitlesDelete, '/movie_subtitles_delete')
|
||||||
|
api.add_resource(MovieSubtitlesDownload, '/movie_subtitles_download')
|
||||||
|
api.add_resource(MovieSubtitlesManualSearch, '/movie_subtitles_manual_search')
|
||||||
|
api.add_resource(MovieSubtitlesManualDownload, '/movie_subtitles_manual_download')
|
||||||
|
api.add_resource(MovieSubtitlesUpload, '/movie_subtitles_upload')
|
||||||
|
api.add_resource(MovieScanDisk, '/movie_scan_disk')
|
||||||
|
api.add_resource(MovieSearchMissing, '/movie_search_missing')
|
||||||
|
api.add_resource(MovieHistory, '/movie_history')
|
||||||
|
|
||||||
api.add_resource(HistorySeries, '/history_series')
|
api.add_resource(HistorySeries, '/history_series')
|
||||||
api.add_resource(HistoryMovies, '/history_movies')
|
api.add_resource(HistoryMovies, '/history_movies')
|
||||||
|
|
|
@ -92,6 +92,7 @@ def store_subtitles(original_path, reversed_path):
|
||||||
for episode in matching_episodes:
|
for episode in matching_episodes:
|
||||||
if episode:
|
if episode:
|
||||||
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
|
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
|
||||||
|
event_stream.write(type='episode', action='update', series=episode['sonarrSeriesId'], episode=episode['sonarrEpisodeId'])
|
||||||
list_missing_subtitles(epno=episode['sonarrEpisodeId'])
|
list_missing_subtitles(epno=episode['sonarrEpisodeId'])
|
||||||
else:
|
else:
|
||||||
logging.debug("BAZARR haven't been able to update existing subtitles to DB : " + str(actual_subtitles))
|
logging.debug("BAZARR haven't been able to update existing subtitles to DB : " + str(actual_subtitles))
|
||||||
|
@ -100,8 +101,6 @@ def store_subtitles(original_path, reversed_path):
|
||||||
|
|
||||||
logging.debug('BAZARR ended subtitles indexing for this file: ' + reversed_path)
|
logging.debug('BAZARR ended subtitles indexing for this file: ' + reversed_path)
|
||||||
|
|
||||||
event_stream.write(type='episode', action='update', series=episode['sonarrSeriesId'], episode=episode['sonarrEpisodeId'])
|
|
||||||
|
|
||||||
return actual_subtitles
|
return actual_subtitles
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,6 +164,7 @@ def store_subtitles_movie(original_path, reversed_path):
|
||||||
for movie in matching_movies:
|
for movie in matching_movies:
|
||||||
if movie:
|
if movie:
|
||||||
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
|
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
|
||||||
|
event_stream.write(type='movie', action='update', movie=movie['radarrId'])
|
||||||
list_missing_subtitles_movies(no=movie['radarrId'])
|
list_missing_subtitles_movies(no=movie['radarrId'])
|
||||||
else:
|
else:
|
||||||
logging.debug("BAZARR haven't been able to update existing subtitles to DB : " + str(actual_subtitles))
|
logging.debug("BAZARR haven't been able to update existing subtitles to DB : " + str(actual_subtitles))
|
||||||
|
@ -173,8 +173,6 @@ def store_subtitles_movie(original_path, reversed_path):
|
||||||
|
|
||||||
logging.debug('BAZARR ended subtitles indexing for this file: ' + reversed_path)
|
logging.debug('BAZARR ended subtitles indexing for this file: ' + reversed_path)
|
||||||
|
|
||||||
event_stream.write(type='movie', action='update', movie=movie['radarrId'])
|
|
||||||
|
|
||||||
return actual_subtitles
|
return actual_subtitles
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#seriesPoster {
|
#seriesPoster {
|
||||||
width: 250px;
|
max-height: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
@ -32,6 +32,15 @@
|
||||||
span {
|
span {
|
||||||
margin-right: 0.5em;
|
margin-right: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 500px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock head %}
|
{% endblock head %}
|
||||||
|
|
||||||
|
@ -816,6 +825,7 @@
|
||||||
|
|
||||||
$('#seriesAudioLanguage').text(seriesDetails['audio_language'].name);
|
$('#seriesAudioLanguage').text(seriesDetails['audio_language'].name);
|
||||||
$('#seriesMappedPath').text(seriesDetails['mapped_path']);
|
$('#seriesMappedPath').text(seriesDetails['mapped_path']);
|
||||||
|
$('#seriesMappedPath').attr("data-original-title", seriesDetails['mapped_path']);
|
||||||
$('#seriesFileCount').text(seriesDetails['episodeFileCount'] + ' files');
|
$('#seriesFileCount').text(seriesDetails['episodeFileCount'] + ' files');
|
||||||
|
|
||||||
var languages = '';
|
var languages = '';
|
||||||
|
|
221
views/movie.html
221
views/movie.html
|
@ -22,7 +22,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#moviePoster {
|
#moviePoster {
|
||||||
width: 250px;
|
max-height: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
@ -32,6 +32,15 @@
|
||||||
span {
|
span {
|
||||||
margin-right: 0.5em;
|
margin-right: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 500px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock head %}
|
{% endblock head %}
|
||||||
|
|
||||||
|
@ -63,7 +72,7 @@
|
||||||
<div class="col-sm-auto" id="moviePosterColumn">
|
<div class="col-sm-auto" id="moviePosterColumn">
|
||||||
<img id="moviePoster" src="">
|
<img id="moviePoster" src="">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" id="movieDetailsColumn">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1><span id="movieTitle"></span></h1>
|
<h1><span id="movieTitle"></span></h1>
|
||||||
|
@ -71,7 +80,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h5><span id="movieAudioLanguage" class="badge badge-secondary"></span></h5>
|
<h5><span id="movieAudioLanguage" class="badge badge-secondary"></span></h5>
|
||||||
<h5><span id="movieMappedPath" class="badge badge-secondary"></span></h5>
|
<h5><span id="movieMappedPath" data-toggle="tooltip" data-placement="right" title="None" class="badge badge-secondary"></span></h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h5><span id="movieSubtitlesLanguages"></span></h5>
|
<h5><span id="movieSubtitlesLanguages"></span></h5>
|
||||||
|
@ -304,37 +313,21 @@
|
||||||
movieDetailsRefresh();
|
movieDetailsRefresh();
|
||||||
getLanguages();
|
getLanguages();
|
||||||
getEnabledLanguages();
|
getEnabledLanguages();
|
||||||
console.log(movieDetails['subtitles']);
|
|
||||||
var table = $('#movieSubtitles').DataTable({
|
|
||||||
language: {
|
|
||||||
zeroRecords: 'No Subtitles Found For This Movie'
|
|
||||||
},
|
|
||||||
"searching": false,
|
|
||||||
"ordering": false,
|
|
||||||
"paging": false,
|
|
||||||
"info": false,
|
|
||||||
"lengthChange": false,
|
|
||||||
"data" : movieDetails['subtitles'],
|
|
||||||
"columns" : [
|
|
||||||
{ "data" : 1 },
|
|
||||||
{ "data" : 0 }
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#episodes').on('click', '.remove_subtitles', function(e){
|
|
||||||
|
$('#movieSubtitles').on('click', '.remove_subtitles', function(e){
|
||||||
$(this).tooltip('dispose');
|
$(this).tooltip('dispose');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const values = {
|
const values = {
|
||||||
episodePath: $(this).attr("data-episodePath"),
|
moviePath: $(this).attr("data-moviePath"),
|
||||||
language: $(this).attr("data-language"),
|
language: $(this).attr("data-language"),
|
||||||
subtitlesPath: $(this).attr("data-subtitlesPath"),
|
subtitlesPath: $(this).attr("data-subtitlesPath"),
|
||||||
sonarrSeriesId: seriesDetails['sonarrSeriesId'],
|
radarrId: movieDetails['radarrId'],
|
||||||
sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"),
|
tmdbid: movieDetails['tmdbId']
|
||||||
tvdbid: seriesDetails['tvdbId']
|
|
||||||
};
|
};
|
||||||
var cell = $(this).closest('td');
|
var cell = $(this).closest('td');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.episodessubtitlesdelete') }}",
|
url: "{{ url_for('api.moviesubtitlesdelete') }}",
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: values,
|
data: values,
|
||||||
|
@ -344,63 +337,60 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#episodes').on('click', '.get_subtitle', function(e){
|
$('.get_subtitle').on('click', function(e){
|
||||||
$(this).tooltip('dispose');
|
$(this).tooltip('dispose');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const values = {
|
const values = {
|
||||||
episodePath: $(this).attr("data-episodepath"),
|
moviePath: $(this).attr("data-moviepath"),
|
||||||
sceneName: $(this).attr("data-scenename"),
|
sceneName: $(this).attr("data-scenename"),
|
||||||
language: $(this).attr("data-language"),
|
language: $(this).attr("data-language"),
|
||||||
hi: $(this).attr("data-hi"),
|
hi: $(this).attr("data-hi"),
|
||||||
forced: $(this).attr("data-forced"),
|
forced: $(this).attr("data-forced"),
|
||||||
sonarrSeriesId: seriesDetails['sonarrSeriesId'],
|
radarrId: movieDetails['radarrId'],
|
||||||
sonarrEpisodeId: $(this).attr('data-sonarrepisodeid'),
|
title: movieDetails['title']
|
||||||
title: seriesDetails['title']
|
|
||||||
};
|
};
|
||||||
var cell = $(this).closest('td');
|
var button = $(this).closest('button');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.episodessubtitlesdownload') }}",
|
url: "{{ url_for('api.moviesubtitlesdownload') }}",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: values,
|
data: values,
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
cell.html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
|
button.html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#episodes').on('click', '.manual_search', function(e){
|
$('#manual_search').on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$("#series_title_span").html(seriesDetails['title'] + ' - ' + $(this).data("season") + 'x' + $(this).data("episode") + ' - ' + $(this).data("episode_title"));
|
$("#movie_title_span").html(movieDetails['title']);
|
||||||
$("#episode_path_span").html($(this).attr("data-episodePath"));
|
$("#movie_path_span").html($(this).attr("data-moviePath"));
|
||||||
$("#episode_scenename_span").html($(this).attr("data-sceneName"));
|
$("#movie_scenename_span").html($(this).attr("data-sceneName"));
|
||||||
|
|
||||||
episodePath = $(this).attr("data-episodePath");
|
moviePath = $(this).attr("data-moviePath");
|
||||||
sceneName = $(this).attr("data-sceneName");
|
sceneName = $(this).attr("data-sceneName");
|
||||||
language = $(this).attr("data-language");
|
language = $(this).attr("data-language");
|
||||||
hi = seriesDetails['hearing_impaired'];
|
hi = movieDetails['hearing_impaired'];
|
||||||
forced = seriesDetails['forced'];
|
forced = movieDetails['forced'];
|
||||||
sonarrSeriesId = seriesDetails['sonarrSeriesId'];
|
radarrId = movieDetails['radarrId'];
|
||||||
sonarrEpisodeId = $(this).attr("data-sonarrEpisodeId");
|
var languages = Array.from(movieDetails['languages']);
|
||||||
var languages = Array.from(seriesDetails['languages']);
|
|
||||||
var is_pb = languages.includes('pb');
|
var is_pb = languages.includes('pb');
|
||||||
var is_pt = languages.includes('pt');
|
var is_pt = languages.includes('pt');
|
||||||
|
|
||||||
const values = {
|
const values = {
|
||||||
episodePath: episodePath,
|
moviePath: moviePath,
|
||||||
sceneName: sceneName,
|
sceneName: sceneName,
|
||||||
language: language,
|
language: language,
|
||||||
hi: hi,
|
hi: hi,
|
||||||
forced: forced,
|
forced: forced,
|
||||||
sonarrSeriesId: sonarrSeriesId,
|
radarrId: radarrId,
|
||||||
sonarrEpisodeId: sonarrEpisodeId,
|
title: movieDetails['title']
|
||||||
title: seriesDetails['title']
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$('#search_result').DataTable( {
|
$('#search_result').DataTable( {
|
||||||
destroy: true,
|
destroy: true,
|
||||||
language: {
|
language: {
|
||||||
zeroRecords: 'No Subtitles Found For This Episode',
|
zeroRecords: 'No Subtitles Found For This Movie',
|
||||||
processing: "Searching (possibly solving captcha)..."
|
processing: "Searching (possibly solving captcha)..."
|
||||||
},
|
},
|
||||||
paging: true,
|
paging: true,
|
||||||
|
@ -411,7 +401,7 @@
|
||||||
processing: true,
|
processing: true,
|
||||||
serverSide: false,
|
serverSide: false,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: '{{ url_for('api.episodessubtitlesmanualsearch') }}',
|
url: '{{ url_for('api.moviesubtitlesmanualsearch') }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: values
|
data: values
|
||||||
},
|
},
|
||||||
|
@ -468,7 +458,7 @@
|
||||||
},
|
},
|
||||||
{ data: null,
|
{ data: null,
|
||||||
render: function ( data ) {
|
render: function ( data ) {
|
||||||
return '<a href="" class="manual_download badge badge-secondary" data-episodePath="'+episodePath+'" data-sceneName="'+sceneName+'" data-sonarrEpisodeId='+sonarrEpisodeId+' 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>';
|
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>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -483,20 +473,19 @@
|
||||||
$('#search_result').on('click', '.manual_download', function(e){
|
$('#search_result').on('click', '.manual_download', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const values = {
|
const values = {
|
||||||
episodePath: $(this).attr("data-episodepath"),
|
moviePath: $(this).attr("data-moviepath"),
|
||||||
sceneName: $(this).attr("data-scenename"),
|
sceneName: $(this).attr("data-scenename"),
|
||||||
language: $(this).attr("data-language"),
|
language: $(this).attr("data-language"),
|
||||||
hi: seriesDetails['hearing_impaired'],
|
hi: movieDetails['hearing_impaired'],
|
||||||
forced: $(this).attr("data-forced"),
|
forced: $(this).attr("data-forced"),
|
||||||
provider: $(this).attr("data-provider"),
|
provider: $(this).attr("data-provider"),
|
||||||
subtitle: $(this).attr("data-subtitle"),
|
subtitle: $(this).attr("data-subtitle"),
|
||||||
sonarrSeriesId: seriesDetails['sonarrSeriesId'],
|
radarrId: movieDetails['radarrId'],
|
||||||
sonarrEpisodeId: $(this).attr('data-sonarrepisodeid'),
|
title: movieDetails['title']
|
||||||
title: seriesDetails['title']
|
|
||||||
};
|
};
|
||||||
var cell = $(this).closest('td');
|
var cell = $(this).closest('td');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.episodessubtitlesmanualdownload') }}",
|
url: "{{ url_for('api.moviesubtitlesmanualdownload') }}",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: values,
|
data: values,
|
||||||
|
@ -509,14 +498,13 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#episodes').on('click', '.upload_subtitle', function(e){
|
$('#upload_subtitle').on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$("#upload_series_title_span").html(seriesDetails['title'] + ' - ' + $(this).data("season") + 'x' + $(this).data("episode") + ' - ' + $(this).data("episode_title"));
|
$("#upload_movie_title_span").html(movieDetails['title']);
|
||||||
$('#upload_episodePath').val($(this).data("episodepath"));
|
$('#upload_moviePath').val($(this).data("moviepath"));
|
||||||
$('#upload_sceneName').val($(this).data("scenename"));
|
$('#upload_sceneName').val($(this).data("scenename"));
|
||||||
$('#upload_sonarrSeriesId').val($(this).data("sonarrseriesid"));
|
$('#upload_radarrId').val($(this).data("radarrid"));
|
||||||
$('#upload_sonarrEpisodeId').val($(this).data("sonarrepisodeid"));
|
$('#upload_title').val($(this).data("movie_title"));
|
||||||
$('#upload_title').val($(this).data("episode_title"));
|
|
||||||
|
|
||||||
$('#manual_language_select').empty();
|
$('#manual_language_select').empty();
|
||||||
$.each(enabledLanguages, function (i, item) {
|
$.each(enabledLanguages, function (i, item) {
|
||||||
|
@ -535,7 +523,7 @@
|
||||||
var formdata = new FormData(document.getElementById("upload_form"));
|
var formdata = new FormData(document.getElementById("upload_form"));
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.episodessubtitlesupload') }}",
|
url: "{{ url_for('api.moviesubtitlesupload') }}",
|
||||||
data: formdata,
|
data: formdata,
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
|
@ -549,7 +537,7 @@
|
||||||
$('#scan_button').on('click', function(e){
|
$('#scan_button').on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.episodesscandisk', seriesid=id) }}",
|
url: "{{ url_for('api.moviescandisk', radarrid=id) }}",
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
$('#scan_button').find("i").addClass('fa-spin');
|
$('#scan_button').find("i").addClass('fa-spin');
|
||||||
|
@ -563,7 +551,7 @@
|
||||||
$('#search_button').on('click', function(e){
|
$('#search_button').on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.episodessearchmissing', seriesid=id) }}",
|
url: "{{ url_for('api.moviesearchmissing', radarrid=id) }}",
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
$('#search_button').find("i").addClass('fa-spin');
|
$('#search_button').find("i").addClass('fa-spin');
|
||||||
|
@ -576,9 +564,9 @@
|
||||||
|
|
||||||
$('#edit_button').on('click', function(e){
|
$('#edit_button').on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$("#edit_series_title_span").html(seriesDetails['title']);
|
$("#edit_movie_title_span").html(movieDetails['title']);
|
||||||
$("#edit_audio_language_span").text(seriesDetails['audio_language']['name']);
|
$("#edit_audio_language_span").text(movieDetails['audio_language']['name']);
|
||||||
$('#edit_sonarrSeriesId').val(seriesDetails['sonarrSeriesId']);
|
$('#edit_radarrId').val(movieDetails['radarrId']);
|
||||||
|
|
||||||
|
|
||||||
$('#edit_languages_select').empty();
|
$('#edit_languages_select').empty();
|
||||||
|
@ -591,12 +579,12 @@
|
||||||
});
|
});
|
||||||
$("#edit_languages_select").selectpicker("refresh");
|
$("#edit_languages_select").selectpicker("refresh");
|
||||||
var selected_languages = Array();
|
var selected_languages = Array();
|
||||||
$.each(Array.from(seriesDetails['languages']), function (i, item) {
|
$.each(Array.from(movieDetails['languages']), function (i, item) {
|
||||||
selected_languages.push(item.code2);
|
selected_languages.push(item.code2);
|
||||||
});
|
});
|
||||||
$('#edit_languages_select').selectpicker('val', selected_languages);
|
$('#edit_languages_select').selectpicker('val', selected_languages);
|
||||||
$('#hi_checkbox').prop('checked', (seriesDetails['hearing_impaired'] === 'True'));
|
$('#hi_checkbox').prop('checked', (movieDetails['hearing_impaired'] === 'True'));
|
||||||
$('#edit_forced_select').val(seriesDetails['forced']).change();
|
$('#edit_forced_select').val(movieDetails['forced']).change();
|
||||||
|
|
||||||
$('#editModal')
|
$('#editModal')
|
||||||
.modal({
|
.modal({
|
||||||
|
@ -609,13 +597,13 @@
|
||||||
var formdata = new FormData(document.getElementById("edit_form"));
|
var formdata = new FormData(document.getElementById("edit_form"));
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.series') }}?seriesid={{id}}",
|
url: "{{ url_for('api.movies') }}?radarrid={{id}}",
|
||||||
data: formdata,
|
data: formdata,
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
success: function(){
|
success: function(){
|
||||||
seriesDetailsRefresh();
|
movieDetailsRefresh();
|
||||||
$('#editModal').modal('hide');
|
$('#editModal').modal('hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -627,58 +615,25 @@
|
||||||
|
|
||||||
events.on('event', function(event) {
|
events.on('event', function(event) {
|
||||||
var event_json = JSON.parse(event);
|
var event_json = JSON.parse(event);
|
||||||
if (event_json.series === {{id}}) {
|
if (event_json.movie === {{id}}) {
|
||||||
if (event_json.type === 'series' && event_json.action === 'update' && event_json.episode == null) {
|
if (event_json.type === 'movie') {
|
||||||
seriesDetailsRefresh();
|
movieDetailsRefresh();
|
||||||
}
|
|
||||||
|
|
||||||
if (event_json.type === 'episode' && event_json.action === 'insert') {
|
|
||||||
$.ajax({
|
|
||||||
url: "{{ url_for('api.episodes') }}?seriesid=" + event_json.series + "&episodeid=" + event_json.episode,
|
|
||||||
success: function (data) {
|
|
||||||
if (data.data.length) {
|
|
||||||
$('#episodes').DataTable().rows.add(data.data);
|
|
||||||
$('#episodes').DataTable().columns.adjust().draw(false);
|
|
||||||
$('[data-toggle="tooltip"]').tooltip({html: true});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (event_json.type === 'episode' && event_json.action === 'update') {
|
|
||||||
var rowId = $('#episodes').DataTable().row('#row_' + event_json.episode);
|
|
||||||
if (rowId.length) {
|
|
||||||
$.ajax({
|
|
||||||
url: "{{ url_for('api.episodes') }}?seriesid=" + event_json.series + "&episodeid=" + event_json.episode,
|
|
||||||
success: function (data) {
|
|
||||||
if (data.data.length) {
|
|
||||||
$('#episodes').DataTable().row(rowId).data(data.data[0]);
|
|
||||||
$('[data-toggle="tooltip"]').tooltip({html: true});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (event_json.type === 'episode' && event_json.action === 'delete') {
|
|
||||||
var rowId = $('#episodes').DataTable().row('#row_' + event_json.episode);
|
|
||||||
if (rowId.length) {
|
|
||||||
$('#episodes').DataTable().row(rowId).remove();
|
|
||||||
$('#episodes').DataTable().columns.adjust().draw(false);
|
|
||||||
$('[data-toggle="tooltip"]').tooltip({html: true});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#episodes').on('click', '.episode_history', function(e){
|
$('#movie_history').on('click', function(e){
|
||||||
$(this).tooltip('dispose');
|
$(this).tooltip('dispose');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$("#episode_history_title_span").html(seriesDetails['title'] + ' - ' + $(this).data("season") + 'x' + $(this).data("episode") + ' - ' + $(this).data("episodetitle"));
|
$("#movie_history_title_span").html(movieDetails['title']);
|
||||||
|
|
||||||
sonarrEpisodeId = $(this).data("sonarrepisodeid");
|
radarrId = $(this).data("radarrid");
|
||||||
|
|
||||||
$('#episode_history_result').DataTable( {
|
$('#movie_history_result').DataTable( {
|
||||||
destroy: true,
|
destroy: true,
|
||||||
language: {
|
language: {
|
||||||
zeroRecords: 'No History Records Found For This Episode'
|
zeroRecords: 'No History Records Found For This Movie'
|
||||||
},
|
},
|
||||||
paging: true,
|
paging: true,
|
||||||
lengthChange: false,
|
lengthChange: false,
|
||||||
|
@ -688,7 +643,7 @@
|
||||||
processing: false,
|
processing: false,
|
||||||
serverSide: false,
|
serverSide: false,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: '{{ url_for( 'api.episodeshistory' )}}?episodeid=' + sonarrEpisodeId
|
url: '{{ url_for( 'api.moviehistory' )}}?radarrid=' + radarrId
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{ data: 'action',
|
{ data: 'action',
|
||||||
|
@ -706,7 +661,7 @@
|
||||||
]
|
]
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$('#episodeHistoryModal')
|
$('#movieHistoryModal')
|
||||||
.modal({
|
.modal({
|
||||||
focus: false
|
focus: false
|
||||||
});
|
});
|
||||||
|
@ -731,6 +686,7 @@
|
||||||
|
|
||||||
$('#movieAudioLanguage').text(movieDetails['audio_language'].name);
|
$('#movieAudioLanguage').text(movieDetails['audio_language'].name);
|
||||||
$('#movieMappedPath').text(movieDetails['mapped_path']);
|
$('#movieMappedPath').text(movieDetails['mapped_path']);
|
||||||
|
$('#movieMappedPath').attr("data-original-title", movieDetails['mapped_path']);
|
||||||
|
|
||||||
var languages = '';
|
var languages = '';
|
||||||
if (movieDetails['languages'] !== 'None') {
|
if (movieDetails['languages'] !== 'None') {
|
||||||
|
@ -747,6 +703,39 @@
|
||||||
$('#movieDescription').text(movieDetails['overview']);
|
$('#movieDescription').text(movieDetails['overview']);
|
||||||
|
|
||||||
$('[data-toggle="tooltip"]').tooltip({html: true});
|
$('[data-toggle="tooltip"]').tooltip({html: true});
|
||||||
|
|
||||||
|
var table = $('#movieSubtitles').DataTable({
|
||||||
|
destroy: true,
|
||||||
|
language: {
|
||||||
|
zeroRecords: 'No Subtitles Found For This Movie'
|
||||||
|
},
|
||||||
|
"searching": false,
|
||||||
|
"ordering": false,
|
||||||
|
"paging": false,
|
||||||
|
"info": false,
|
||||||
|
"lengthChange": false,
|
||||||
|
"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>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue