diff --git a/bazarr/api.py b/bazarr/api.py index fb23a3c76..e8e9a22d7 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -378,11 +378,12 @@ class EpisodesSubtitlesDownload(Resource): title = request.form.get('title') providers_list = get_providers() providers_auth = get_providers_auth() + audio_language = database.execute("SELECT audio_language FROM table_shows WHERE sonarrSeriesId=?", + (sonarrSeriesId,), only_one=True)['audio_language'] try: - result = download_subtitle(episodePath, language, hi, forced, providers_list, providers_auth, sceneName, - title, - 'series') + result = download_subtitle(episodePath, language, audio_language, hi, forced, providers_list, providers_auth, sceneName, + title, 'series') if result is not None: message = result[0] path = result[1] @@ -440,11 +441,12 @@ class EpisodesSubtitlesManualDownload(Resource): sonarrEpisodeId = request.form.get('sonarrEpisodeId') title = request.form.get('title') providers_auth = get_providers_auth() + audio_language = database.execute("SELECT audio_language FROM table_shows WHERE sonarrSeriesId=?", + (sonarrSeriesId,), only_one=True)['audio_language'] try: - result = manual_download_subtitle(episodePath, language, hi, forced, subtitle, selected_provider, - providers_auth, - sceneName, title, 'series') + result = manual_download_subtitle(episodePath, language, audio_language, hi, forced, subtitle, + selected_provider, providers_auth, sceneName, title, 'series') if result is not None: message = result[0] path = result[1] @@ -719,10 +721,12 @@ class MovieSubtitlesDownload(Resource): title = request.form.get('title') providers_list = get_providers() providers_auth = get_providers_auth() + audio_language = database.execute("SELECT audio_language FROM table_movies WHERE radarrId=?", (radarrId,), + only_one=True)['audio_language'] try: - result = download_subtitle(moviePath, language, hi, forced, providers_list, providers_auth, sceneName, - title, 'movie') + result = download_subtitle(moviePath, language, audio_language, hi, forced, providers_list, + providers_auth, sceneName, title, 'movie') if result is not None: message = result[0] path = result[1] @@ -779,10 +783,12 @@ class MovieSubtitlesManualDownload(Resource): radarrId = request.form.get('radarrId') title = request.form.get('title') providers_auth = get_providers_auth() + audio_language = database.execute("SELECT audio_language FROM table_movies WHERE radarrId=?", (radarrId,), + only_one=True)['audio_language'] try: - result = manual_download_subtitle(moviePath, language, hi, forced, subtitle, selected_provider, - providers_auth, sceneName, title, 'movie') + result = manual_download_subtitle(moviePath, language, audio_language, hi, forced, subtitle, + selected_provider, providers_auth, sceneName, title, 'movie') if result is not None: message = result[0] path = result[1] diff --git a/bazarr/database.py b/bazarr/database.py index ceca85b77..c92bea97f 100644 --- a/bazarr/database.py +++ b/bazarr/database.py @@ -126,3 +126,11 @@ def db_upgrade(): database.execute('''ALTER TABLE {0} ADD COLUMN "{1}" "{2}" DEFAULT "{3}"'''.format(column[0], column[1], column[2], column[3])) except: pass + + # Fix null languages, hearing-impaired and forced for series and movies. + database.execute("UPDATE table_shows SET languages = '[]' WHERE languages is null") + database.execute("UPDATE table_shows SET hearing_impaired = 'False' WHERE hearing_impaired is null") + database.execute("UPDATE table_shows SET forced = 'False' WHERE forced is null") + database.execute("UPDATE table_movies SET languages = '[]' WHERE languages is null") + database.execute("UPDATE table_movies SET hearing_impaired = 'False' WHERE hearing_impaired is null") + database.execute("UPDATE table_movies SET forced = 'False' WHERE forced is null")