diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 7ef841614..5f5e5bb7b 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -215,6 +215,7 @@ def download_subtitle(path, language, audio_language, hi, forced, providers, pro audio_language_code2 = alpha2_from_language(audio_language) audio_language_code3 = alpha3_from_language(audio_language) downloaded_path = subtitle.storage_path + subtitle_id = subtitle.id is_forced_string = " forced" if subtitle.language.forced else "" logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path) if is_upgrade: @@ -230,6 +231,8 @@ def download_subtitle(path, language, audio_language, hi, forced, providers, pro "table_episodes WHERE path = ?", (path_mappings.path_replace_reverse(path),), only_one=True) + series_id = episode_metadata['sonarrSeriesId'] + episode_id = episode_metadata['sonarrEpisodeId'] sync_subtitles(video_path=path, srt_path=downloaded_path, srt_lang=downloaded_language_code3, media_type=media_type, percent_score=percent_score, @@ -239,6 +242,8 @@ def download_subtitle(path, language, audio_language, hi, forced, providers, pro movie_metadata = database.execute("SELECT radarrId FROM table_movies WHERE path = ?", (path_mappings.path_replace_reverse_movie(path),), only_one=True) + series_id = "" + episode_id = movie_metadata['radarrId'] sync_subtitles(video_path=path, srt_path=downloaded_path, srt_lang=downloaded_language_code3, media_type=media_type, percent_score=percent_score, @@ -248,7 +253,7 @@ def download_subtitle(path, language, audio_language, hi, forced, providers, pro command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2, downloaded_language_code3, audio_language, audio_language_code2, audio_language_code3, subtitle.language.forced, - percent_score) + percent_score, subtitle_id, downloaded_provider, series_id, episode_id) if media_type == 'series': use_pp_threshold = settings.general.getboolean('use_postprocessing_threshold') @@ -476,6 +481,7 @@ def manual_download_subtitle(path, language, audio_language, hi, forced, subtitl audio_language_code2 = alpha2_from_language(audio_language) audio_language_code3 = alpha3_from_language(audio_language) downloaded_path = saved_subtitle.storage_path + subtitle_id = subtitle.id logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path) is_forced_string = " forced" if subtitle.language.forced else "" message = downloaded_language + is_forced_string + " subtitles downloaded from " + \ @@ -486,6 +492,8 @@ def manual_download_subtitle(path, language, audio_language, hi, forced, subtitl "table_episodes WHERE path = ?", (path_mappings.path_replace_reverse(path),), only_one=True) + series_id = episode_metadata['sonarrSeriesId'] + episode_id = episode_metadata['sonarrEpisodeId'] sync_subtitles(video_path=path, srt_path=downloaded_path, srt_lang=downloaded_language_code3, media_type=media_type, percent_score=score, @@ -495,6 +503,8 @@ def manual_download_subtitle(path, language, audio_language, hi, forced, subtitl movie_metadata = database.execute("SELECT radarrId FROM table_movies WHERE path = ?", (path_mappings.path_replace_reverse_movie(path),), only_one=True) + series_id = "" + episode_id = movie_metadata['radarrId'] sync_subtitles(video_path=path, srt_path=downloaded_path, srt_lang=downloaded_language_code3, media_type=media_type, percent_score=score, radarr_id=movie_metadata['radarrId']) @@ -504,7 +514,7 @@ def manual_download_subtitle(path, language, audio_language, hi, forced, subtitl command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2, downloaded_language_code3, audio_language, audio_language_code2, audio_language_code3, subtitle.language.forced, - percent_score) + percent_score, subtitle_id, downloaded_provider, series_id, episode_id) if media_type == 'series': use_pp_threshold = settings.general.getboolean('use_postprocessing_threshold') @@ -609,6 +619,8 @@ def manual_upload_subtitle(path, language, forced, title, scene_name, media_type episode_metadata = database.execute("SELECT sonarrSeriesId, sonarrEpisodeId FROM table_episodes WHERE path = ?", (path_mappings.path_replace_reverse(path),), only_one=True) + series_id = episode_metadata['sonarrSeriesId'] + episode_id = episode_metadata['sonarrEpisodeId'] sync_subtitles(video_path=path, srt_path=subtitle_path, srt_lang=uploaded_language_code3, media_type=media_type, percent_score=100, sonarr_series_id=episode_metadata['sonarrSeriesId'], sonarr_episode_id=episode_metadata['sonarrEpisodeId']) @@ -616,13 +628,15 @@ def manual_upload_subtitle(path, language, forced, title, scene_name, media_type movie_metadata = database.execute("SELECT radarrId FROM table_movies WHERE path = ?", (path_mappings.path_replace_reverse_movie(path),), only_one=True) + series_id = "" + episode_id = movie_metadata['radarrId'] sync_subtitles(video_path=path, srt_path=subtitle_path, srt_lang=uploaded_language_code3, media_type=media_type, percent_score=100, radarr_id=movie_metadata['radarrId']) if use_postprocessing : command = pp_replace(postprocessing_cmd, path, subtitle_path, uploaded_language, uploaded_language_code2, uploaded_language_code3, audio_language, - audio_language_code2, audio_language_code3, forced, 100) + audio_language_code2, audio_language_code3, forced, 100, "1", "manual", series_id, episode_id) postprocessing(command, path) if media_type == 'series': diff --git a/bazarr/helper.py b/bazarr/helper.py index 4307affde..4b8f77e44 100644 --- a/bazarr/helper.py +++ b/bazarr/helper.py @@ -95,7 +95,7 @@ class PathMappings: path_mappings = PathMappings() -def pp_replace(pp_command, episode, subtitles, language, language_code2, language_code3, episode_language, episode_language_code2, episode_language_code3, forced, score): +def pp_replace(pp_command, episode, subtitles, language, language_code2, language_code3, episode_language, episode_language_code2, episode_language_code3, forced, score, subtitle_id, provider, series_id, episode_id): is_forced = ":forced" if forced else "" is_forced_string = " forced" if forced else "" pp_command = pp_command.replace('{{directory}}', os.path.dirname(episode)) @@ -109,6 +109,10 @@ def pp_replace(pp_command, episode, subtitles, language, language_code2, languag pp_command = pp_command.replace('{{episode_language_code2}}', episode_language_code2) pp_command = pp_command.replace('{{episode_language_code3}}', episode_language_code3) pp_command = pp_command.replace('{{score}}', str(score)) + pp_command = pp_command.replace('{{subtitle_id}}', str(subtitle_id)) + pp_command = pp_command.replace('{{provider}}', str(provider)) + pp_command = pp_command.replace('{{series_id}}', str(series_id)) + pp_command = pp_command.replace('{{episode_id}}', str(episode_id)) return pp_command diff --git a/views/settingssubtitles.html b/views/settingssubtitles.html index e01012f93..02a3d2dec 100644 --- a/views/settingssubtitles.html +++ b/views/settingssubtitles.html @@ -582,6 +582,14 @@

The 3-letter ISO-639 language code of the episode audio language.

{{score}}

The score of the subtitles file.

+ {{subtitle_id}} +

Provider ID of the subtitles file.

+ {{provider}} +

Provider of the subtitles file.

+ {{series_id}} +

Sonarr series ID. Empty if movie.

+ {{episode_id}} +

Sonarr episode ID or Radarr movie ID.