Switched to the actual episodes audio language instead of series audio profile language.

pull/1096/head
Louis Vézina 4 years ago
parent 88452468cf
commit ebde79a8cd

@ -462,6 +462,11 @@ class Episodes(Resource):
# Add Datatables rowId # Add Datatables rowId
item.update({"DT_RowId": 'row_' + str(item['sonarrEpisodeId'])}) item.update({"DT_RowId": 'row_' + str(item['sonarrEpisodeId'])})
# Parse audio language
item.update({"audio_language": {"name": item['audio_language'],
"code2": alpha2_from_language(item['audio_language']) or None,
"code3": alpha3_from_language(item['audio_language']) or None}})
# 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'])})
@ -540,8 +545,8 @@ class EpisodesSubtitlesDownload(Resource):
title = request.form.get('title') title = request.form.get('title')
providers_list = get_providers() providers_list = get_providers()
providers_auth = get_providers_auth() providers_auth = get_providers_auth()
audio_language = database.execute("SELECT audio_language FROM table_shows WHERE sonarrSeriesId=?", audio_language = database.execute("SELECT audio_language FROM table_episodes WHERE sonarrEpisodeId=?",
(sonarrSeriesId,), only_one=True)['audio_language'] (sonarrEpisodeId,), only_one=True)['audio_language']
try: try:
result = download_subtitle(episodePath, language, audio_language, hi, forced, providers_list, providers_auth, sceneName, result = download_subtitle(episodePath, language, audio_language, hi, forced, providers_list, providers_auth, sceneName,
@ -609,8 +614,8 @@ class EpisodesSubtitlesManualDownload(Resource):
sonarrEpisodeId = request.form.get('sonarrEpisodeId') sonarrEpisodeId = request.form.get('sonarrEpisodeId')
title = request.form.get('title') title = request.form.get('title')
providers_auth = get_providers_auth() providers_auth = get_providers_auth()
audio_language = database.execute("SELECT audio_language FROM table_shows WHERE sonarrSeriesId=?", audio_language = database.execute("SELECT audio_language FROM table_episodes WHERE sonarrEpisodeId=?",
(sonarrSeriesId,), only_one=True)['audio_language'] (sonarrEpisodeId,), only_one=True)['audio_language']
try: try:
result = manual_download_subtitle(episodePath, language, audio_language, hi, forced, subtitle, result = manual_download_subtitle(episodePath, language, audio_language, hi, forced, subtitle,

@ -99,6 +99,7 @@ def db_upgrade():
['table_episodes', 'video_codec', 'text'], ['table_episodes', 'video_codec', 'text'],
['table_episodes', 'audio_codec', 'text'], ['table_episodes', 'audio_codec', 'text'],
['table_episodes', 'episode_file_id', 'integer'], ['table_episodes', 'episode_file_id', 'integer'],
['table_episodes', 'audio_language', 'text'],
['table_movies', 'sortTitle', 'text'], ['table_movies', 'sortTitle', 'text'],
['table_movies', 'year', 'text'], ['table_movies', 'year', 'text'],
['table_movies', 'alternativeTitles', 'text'], ['table_movies', 'alternativeTitles', 'text'],

@ -85,6 +85,13 @@ def sync_episodes():
videoCodec = None videoCodec = None
audioCodec = None audioCodec = None
audio_language = None
if 'language' in episode['episodeFile'] and len(episode['episodeFile']['language']):
item = episode['episodeFile']['language']
if isinstance(item, dict):
if 'name' in item:
audio_language = item['name']
# Add episodes in sonarr to current episode list # Add episodes in sonarr to current episode list
current_episodes_sonarr.append(episode['id']) current_episodes_sonarr.append(episode['id'])
@ -101,7 +108,8 @@ def sync_episodes():
'resolution': resolution, 'resolution': resolution,
'video_codec': videoCodec, 'video_codec': videoCodec,
'audio_codec': audioCodec, 'audio_codec': audioCodec,
'episode_file_id': episode['episodeFile']['id']}) 'episode_file_id': episode['episodeFile']['id'],
'audio_language': audio_language})
else: else:
episodes_to_add.append({'sonarrSeriesId': episode['seriesId'], episodes_to_add.append({'sonarrSeriesId': episode['seriesId'],
'sonarrEpisodeId': episode['id'], 'sonarrEpisodeId': episode['id'],
@ -115,7 +123,8 @@ def sync_episodes():
'resolution': resolution, 'resolution': resolution,
'video_codec': videoCodec, 'video_codec': videoCodec,
'audio_codec': audioCodec, 'audio_codec': audioCodec,
'episode_file_id': episode['episodeFile']['id']}) 'episode_file_id': episode['episodeFile']['id'],
'audio_language': audio_language})
# Remove old episodes from DB # Remove old episodes from DB
removed_episodes = list(set(current_episodes_db_list) - set(current_episodes_sonarr)) removed_episodes = list(set(current_episodes_db_list) - set(current_episodes_sonarr))
@ -131,7 +140,7 @@ def sync_episodes():
episode_in_db_list = [] episode_in_db_list = []
episodes_in_db = database.execute("SELECT sonarrSeriesId, sonarrEpisodeId, title, path, season, episode, " episodes_in_db = database.execute("SELECT sonarrSeriesId, sonarrEpisodeId, title, path, season, episode, "
"scene_name, monitored, format, resolution, video_codec, audio_codec, " "scene_name, monitored, format, resolution, video_codec, audio_codec, "
"episode_file_id FROM table_episodes") "episode_file_id, audio_language FROM table_episodes")
for item in episodes_in_db: for item in episodes_in_db:
episode_in_db_list.append(item) episode_in_db_list.append(item)

@ -641,7 +641,7 @@ def manual_upload_subtitle(path, language, forced, title, scene_name, media_type
def series_download_subtitles(no): def series_download_subtitles(no):
episodes_details = database.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, monitored, " episodes_details = database.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, monitored, "
"table_episodes.sonarrEpisodeId, table_episodes.scene_name, table_shows.tags, " "table_episodes.sonarrEpisodeId, table_episodes.scene_name, table_shows.tags, "
"table_shows.seriesType FROM table_episodes INNER JOIN table_shows on " "table_shows.seriesType, table_episodes.audio_language FROM table_episodes INNER JOIN table_shows on "
"table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE " "table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE "
"table_episodes.sonarrSeriesId=? and missing_subtitles!='[]'", (no,)) "table_episodes.sonarrSeriesId=? and missing_subtitles!='[]'", (no,))
episodes_details = filter_exclusions(episodes_details, 'series') episodes_details = filter_exclusions(episodes_details, 'series')
@ -650,7 +650,7 @@ def series_download_subtitles(no):
return return
series_details = database.execute( series_details = database.execute(
"SELECT hearing_impaired, audio_language, title, forced FROM table_shows WHERE sonarrSeriesId=?", "SELECT hearing_impaired, title, forced FROM table_shows WHERE sonarrSeriesId=?",
(no,), only_one=True) (no,), only_one=True)
if not series_details: if not series_details:
logging.debug("BAZARR no series with that sonarrSeriesId can be found in database:", str(no)) logging.debug("BAZARR no series with that sonarrSeriesId can be found in database:", str(no))
@ -667,7 +667,7 @@ def series_download_subtitles(no):
if language is not None: if language is not None:
result = download_subtitle(path_mappings.path_replace(episode['path']), result = download_subtitle(path_mappings.path_replace(episode['path']),
str(alpha3_from_alpha2(language.split(':')[0])), str(alpha3_from_alpha2(language.split(':')[0])),
series_details['audio_language'], episode['audio_language'],
series_details['hearing_impaired'], series_details['hearing_impaired'],
"True" if len(language.split(':')) > 1 else "False", "True" if len(language.split(':')) > 1 else "False",
providers_list, providers_list,
@ -697,7 +697,7 @@ def episode_download_subtitles(no):
episodes_details = database.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, monitored, " episodes_details = database.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, monitored, "
"table_episodes.sonarrEpisodeId, table_episodes.scene_name, table_shows.tags, " "table_episodes.sonarrEpisodeId, table_episodes.scene_name, table_shows.tags, "
"table_shows.hearing_impaired, table_shows.title, table_shows.sonarrSeriesId, " "table_shows.hearing_impaired, table_shows.title, table_shows.sonarrSeriesId, "
"table_shows.forced, table_shows.audio_language, table_shows.seriesType FROM " "table_shows.forced, table_episodes.audio_language, table_shows.seriesType FROM "
"table_episodes LEFT JOIN table_shows on table_episodes.sonarrSeriesId = " "table_episodes LEFT JOIN table_shows on table_episodes.sonarrSeriesId = "
"table_shows.sonarrSeriesId WHERE sonarrEpisodeId=?", (no,)) "table_shows.sonarrSeriesId WHERE sonarrEpisodeId=?", (no,))
episodes_details = filter_exclusions(episodes_details, 'series') episodes_details = filter_exclusions(episodes_details, 'series')
@ -792,7 +792,7 @@ def movies_download_subtitles(no):
def wanted_download_subtitles(path, l, count_episodes): def wanted_download_subtitles(path, l, count_episodes):
episodes_details = database.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, " episodes_details = database.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, "
"table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, " "table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, "
"table_shows.hearing_impaired, table_shows.audio_language, table_episodes.scene_name," "table_shows.hearing_impaired, table_episodes.audio_language, table_episodes.scene_name,"
"table_episodes.failedAttempts, table_shows.title, table_shows.forced " "table_episodes.failedAttempts, table_shows.title, table_shows.forced "
"FROM table_episodes LEFT JOIN table_shows on " "FROM table_episodes LEFT JOIN table_shows on "
"table_episodes.sonarrSeriesId = table_shows.sonarrSeriesId " "table_episodes.sonarrSeriesId = table_shows.sonarrSeriesId "
@ -1071,7 +1071,7 @@ def upgrade_subtitles():
if settings.general.getboolean('use_sonarr'): if settings.general.getboolean('use_sonarr'):
upgradable_episodes = database.execute("SELECT table_history.video_path, table_history.language, " upgradable_episodes = database.execute("SELECT table_history.video_path, table_history.language, "
"table_history.score, table_shows.hearing_impaired, " "table_history.score, table_shows.hearing_impaired, "
"table_shows.audio_language, table_episodes.scene_name, table_episodes.title," "table_episodes.audio_language, table_episodes.scene_name, table_episodes.title,"
"table_episodes.sonarrSeriesId, table_episodes.sonarrEpisodeId," "table_episodes.sonarrSeriesId, table_episodes.sonarrEpisodeId,"
"MAX(table_history.timestamp) as timestamp, table_episodes.monitored, " "MAX(table_history.timestamp) as timestamp, table_episodes.monitored, "
"table_shows.languages, table_shows.forced, table_shows.tags, " "table_shows.languages, table_shows.forced, table_shows.tags, "

@ -113,6 +113,7 @@
<th></th> <th></th>
<th>Episode</th> <th>Episode</th>
<th>Title</th> <th>Title</th>
<th>Audio Language</th>
<th>Existing Subtitles</th> <th>Existing Subtitles</th>
<th>Missing Subtitles</th> <th>Missing Subtitles</th>
<th>Manual Search</th> <th>Manual Search</th>
@ -232,7 +233,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-sm-3 text-right"> <div class="col-sm-3 text-right">
Audio Language Audio Profile
</div> </div>
<div class="form-group col-sm-8 pl-sm-0"> <div class="form-group col-sm-8 pl-sm-0">
<span id="edit_audio_language_span"></span> <span id="edit_audio_language_span"></span>
@ -579,6 +580,9 @@
} }
} }
}, },
{
data: 'audio_language.name'
},
{ {
data: null, data: null,
render: function (data) { render: function (data) {
@ -629,7 +633,7 @@
data: null, data: null,
render: function (data) { render: function (data) {
if (data.desired_languages !== '[]') { if (data.desired_languages !== '[]') {
return '<a href="" class="upload_subtitle badge badge-secondary" data-episodePath="' + data.mapped_path + '" data-sceneName"' + data.scene_name + '" data-sonarrSeriesId="' + seriesDetails['sonarrSeriesId'] + '" data-sonarrEpisodeId="' + data.sonarrEpisodeId + '" data-season="' + data.season + '" data-episode="' + data.episode + '" data-episode_title="' + data.title + '"><i class="fas fa-cloud-upload-alt"></i></a>'; return '<a href="" class="upload_subtitle badge badge-secondary" data-episodePath="' + data.mapped_path + '" data-sceneName"' + data.scene_name + '" data-sonarrSeriesId="' + seriesDetails['sonarrSeriesId'] + '" data-sonarrEpisodeId="' + data.sonarrEpisodeId + '" data-season="' + data.season + '" data-episode="' + data.episode + '" data-episode_title="' + data.title + '" data-audio_language="' + data.audio_language.name + '"><i class="fas fa-cloud-upload-alt"></i></a>';
} else { } else {
return '' return ''
} }
@ -876,7 +880,7 @@
$('#upload_sonarrSeriesId').val($(this).data("sonarrseriesid")); $('#upload_sonarrSeriesId').val($(this).data("sonarrseriesid"));
$('#upload_sonarrEpisodeId').val($(this).data("sonarrepisodeid")); $('#upload_sonarrEpisodeId').val($(this).data("sonarrepisodeid"));
$('#upload_title').val($(this).data("episode_title")); $('#upload_title').val($(this).data("episode_title"));
$('#upload_audioLanguage').val(seriesDetails['audio_language']['name']); $('#upload_audioLanguage').val($(this).data("audio_language"));
$('#manual_language_select').empty(); $('#manual_language_select').empty();
$.each(enabledLanguages, function (i, item) { $.each(enabledLanguages, function (i, item) {

@ -22,7 +22,7 @@
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Path Exist</th> <th>Path Exist</th>
<th>Audio Language</th> <th>Audio Profile</th>
<th>Subtitles Languages</th> <th>Subtitles Languages</th>
<th>Hearing-Impaired</th> <th>Hearing-Impaired</th>
<th>Forced</th> <th>Forced</th>
@ -46,7 +46,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-sm-3 text-right"> <div class="col-sm-3 text-right">
Audio Language Audio Profile
</div> </div>
<div class="form-group col-sm-8 pl-sm-0"> <div class="form-group col-sm-8 pl-sm-0">
<span id="edit_audio_language_span"></span> <span id="edit_audio_language_span"></span>

@ -16,7 +16,7 @@
<tr> <tr>
<th></th> <th></th>
<th>Name</th> <th>Name</th>
<th>Audio Language</th> <th>Audio Profile</th>
<th>Subtitles Languages</th> <th>Subtitles Languages</th>
<th>Hearing-Impaired</th> <th>Hearing-Impaired</th>
<th>Forced</th> <th>Forced</th>

Loading…
Cancel
Save