pull/884/head
Louis Vézina 5 years ago
parent 0467be5ff0
commit c265cb9453

@ -106,17 +106,21 @@ class Episodes(Resource):
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 subs in item['subtitles']:
subs[0] = {"name": language_from_alpha2(subs[0]), subtitle = subs[0].split(':')
"code2": subs[0], subs[0] = {"name": language_from_alpha2(subtitle[0]),
"code3": alpha3_from_alpha2(subs[0])} "code2": subtitle[0],
"code3": alpha3_from_alpha2(subtitle[0]),
"forced": True if len(subtitle) > 1 else False}
# 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), subtitle = subs.split(':')
"code2": subs, item['missing_subtitles'][i] = {"name": language_from_alpha2(subtitle[0]),
"code3": alpha3_from_alpha2(subs)} "code2": subtitle[0],
"code3": alpha3_from_alpha2(subtitle[0]),
"forced": True if len(subtitle) > 1 else False}
# Provide mapped path # Provide mapped path
mapped_path = path_replace(item['path']) mapped_path = path_replace(item['path'])

@ -1473,7 +1473,6 @@ def execute_task(taskid):
@app.route('/remove_subtitles', methods=['POST']) @app.route('/remove_subtitles', methods=['POST'])
@login_required @login_required
def remove_subtitles(): def remove_subtitles():
authorize()
episodePath = request.forms.episodePath episodePath = request.forms.episodePath
language = request.forms.get('language') language = request.forms.get('language')
subtitlesPath = request.forms.subtitlesPath subtitlesPath = request.forms.subtitlesPath
@ -1516,9 +1515,11 @@ def get_subtitle():
episodePath = request.form.episodePath episodePath = request.form.episodePath
sceneName = request.form.sceneName sceneName = request.form.sceneName
if sceneName == "null":
sceneName = "None"
language = request.form.get('language') language = request.form.get('language')
hi = request.form.get('hi') hi = request.form.get('hi').capitalize()
forced = request.form.get('forced') forced = request.form.get('forced').capitalize()
sonarrSeriesId = request.form.get('sonarrSeriesId') sonarrSeriesId = request.form.get('sonarrSeriesId')
sonarrEpisodeId = request.form.get('sonarrEpisodeId') sonarrEpisodeId = request.form.get('sonarrEpisodeId')
title = request.form.title title = request.form.title
@ -1542,6 +1543,8 @@ def get_subtitle():
except OSError: except OSError:
pass pass
return ''
@app.route('/manual_search', methods=['POST']) @app.route('/manual_search', methods=['POST'])
@login_required @login_required
@ -1550,9 +1553,11 @@ def manual_search_json():
episodePath = request.form.episodePath episodePath = request.form.episodePath
sceneName = request.form.sceneName sceneName = request.form.sceneName
if sceneName == "null":
sceneName = "None"
language = request.form.get('language') language = request.form.get('language')
hi = request.form.get('hi') hi = request.form.get('hi').capitalize()
forced = request.form.get('forced') forced = request.form.get('forced').capitalize()
title = request.form.title title = request.form.title
providers_list = get_providers() providers_list = get_providers()
providers_auth = get_providers_auth() providers_auth = get_providers_auth()
@ -1569,9 +1574,11 @@ def manual_get_subtitle():
episodePath = request.form.episodePath episodePath = request.form.episodePath
sceneName = request.form.sceneName sceneName = request.form.sceneName
if sceneName == "null":
sceneName = "None"
language = request.form.get('language') language = request.form.get('language')
hi = request.form.get('hi') hi = request.form.get('hi').capitalize()
forced = request.form.get('forced') forced = request.form.get('forced').capitalize()
selected_provider = request.form.get('provider') selected_provider = request.form.get('provider')
subtitle = request.form.subtitle subtitle = request.form.subtitle
sonarrSeriesId = request.form.get('sonarrSeriesId') sonarrSeriesId = request.form.get('sonarrSeriesId')
@ -1606,6 +1613,8 @@ def perform_manual_upload_subtitle():
episodePath = request.form.episodePath episodePath = request.form.episodePath
sceneName = request.form.sceneName sceneName = request.form.sceneName
if sceneName == "null":
sceneName = "None"
language = request.form.get('language') language = request.form.get('language')
forced = True if request.form.get('forced') == '1' else False forced = True if request.form.get('forced') == '1' else False
upload = request.files.get('upload') upload = request.files.get('upload')
@ -1650,9 +1659,11 @@ def get_subtitle_movie():
moviePath = request.form.moviePath moviePath = request.form.moviePath
sceneName = request.form.sceneName sceneName = request.form.sceneName
if sceneName == "null":
sceneName = "None"
language = request.form.get('language') language = request.form.get('language')
hi = request.form.get('hi') hi = request.form.get('hi').capitalize()
forced = request.form.get('forced') forced = request.form.get('forced').capitalize()
radarrId = request.form.get('radarrId') radarrId = request.form.get('radarrId')
title = request.form.title title = request.form.title
providers_list = get_providers() providers_list = get_providers()
@ -1683,9 +1694,11 @@ def manual_search_movie_json():
moviePath = request.form.moviePath moviePath = request.form.moviePath
sceneName = request.form.sceneName sceneName = request.form.sceneName
if sceneName == "null":
sceneName = "None"
language = request.form.get('language') language = request.form.get('language')
hi = request.form.get('hi') hi = request.form.get('hi').capitalize()
forced = request.form.get('forced') forced = request.form.get('forced').capitalize()
title = request.form.title title = request.form.title
providers_list = get_providers() providers_list = get_providers()
providers_auth = get_providers_auth() providers_auth = get_providers_auth()
@ -1702,9 +1715,11 @@ def manual_get_subtitle_movie():
moviePath = request.form.moviePath moviePath = request.form.moviePath
sceneName = request.form.sceneName sceneName = request.form.sceneName
if sceneName == "null":
sceneName = "None"
language = request.form.get('language') language = request.form.get('language')
hi = request.form.get('hi') hi = request.form.get('hi').capitalize()
forced = request.form.get('forced') forced = request.form.get('forced').capitalize()
selected_provider = request.form.provider selected_provider = request.form.provider
subtitle = request.form.subtitle subtitle = request.form.subtitle
radarrId = request.form.get('radarrId') radarrId = request.form.get('radarrId')
@ -1737,6 +1752,8 @@ def perform_manual_upload_subtitle_movie():
moviePath = request.form.moviePath moviePath = request.form.moviePath
sceneName = request.form.sceneName sceneName = request.form.sceneName
if sceneName == "null":
sceneName = "None"
language = request.form.get('language') language = request.form.get('language')
forced = True if request.form.get('forced') == '1' else False forced = True if request.form.get('forced') == '1' else False
upload = request.files.get('upload') upload = request.files.get('upload')

@ -171,25 +171,25 @@
function appendFunc(value) { function appendFunc(value) {
if (value[1] === null) { if (value[1] === null) {
languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value[0].name + '">' + value[0].code2 + '</span> '; languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value[0].name + ((value[0].forced) ? ' forced':'') + '">' + value[0].code2 + ((value[0].forced) ? ':forced':'') + '</span> ';
} else { } else {
languages = languages + '<a href="" class="remove_subtitles badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value[0].name + '" data-episodePath="'+data.path+'" data-language="'+value[0].code3+'" data-subtitlesPath="'+value[1]+'" data-sonarrEpisodeId='+data.sonarrEpisodeId+'>' + value[0].code2 + ' <i class="far fa-trash-alt"></i></a> '; languages = languages + '<a href="" class="remove_subtitles badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value[0].name + ((value[0].forced) ? ' forced':'') + '" data-episodePath="'+data.path+'" data-language="'+value[0].code3+'" data-subtitlesPath="'+value[1]+'" data-sonarrEpisodeId='+data.sonarrEpisodeId+'>' + value[0].code2 + ((value[0].forced) ? ':forced':'') + ' <i class="far fa-trash-alt"></i></a> ';
} }
} }
} }
}, },
{"data": "missing_subtitles", {"data": null,
"render": function (data) { "render": function (data) {
if (data !== 'None') { if (data.missing_subtitles !== 'None') {
var languages = ''; var languages = '';
data.forEach(appendFunc); data.missing_subtitles.forEach(appendFunc);
return languages; return languages;
} else { } else {
return null; return null;
} }
function appendFunc(value) { function appendFunc(value) {
languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + '">' + value.code2 + '</span> '; languages = languages + '<a href="" class="get_subtitle badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + ((value.forced) ? ' forced':'') + '" data-episodepath="'+data.path+'" data-scenename="'+data.scene_name+'" data-title="'+data.title+'" data-language="'+value.code3+'" data-hi="'+seriesDetails.hearing_impaired+'" data-forced="'+value.forced+'" data-sonarrepisodeid='+data.sonarrEpisodeId+'>' + value.code2 + ((value.forced) ? ':forced':'') + ' <i class="fas fa-search"></i></a> ';
} }
} }
}, },
@ -222,6 +222,33 @@
} }
}); });
}); });
$('#episodes').on('click', '.get_subtitle', function(e){
e.preventDefault()
const values = {
episodePath: $(this).attr("data-episodepath"),
sceneName: $(this).attr("data-scenename"),
language: $(this).attr("data-language"),
hi: $(this).attr("data-hi"),
forced: $(this).attr("data-forced"),
sonarrSeriesId: seriesDetails['sonarrSeriesId'],
sonarrEpisodeId: $(this).attr('data-sonarrepisodeid'),
title: seriesDetails['title']
};
var cell = $(this).closest('td');
$.ajax({
url: "{{ url_for('get_subtitle') }}",
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() {
$('#episodes').DataTable().ajax.reload(null, false);
}
});
});
}); });

Loading…
Cancel
Save