mirror of https://github.com/morpheus65535/bazarr
Add subtitles id, provider, series and episode or movie id to the post-processing.
This commit is contained in:
parent
ef6f3d30f8
commit
ba4f79002b
|
@ -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':
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -582,6 +582,14 @@
|
|||
<p>The 3-letter ISO-639 language code of the episode audio language.</p>
|
||||
<b>{{score}}</b>
|
||||
<p>The score of the subtitles file.</p>
|
||||
<b>{{subtitle_id}}</b>
|
||||
<p>Provider ID of the subtitles file.</p>
|
||||
<b>{{provider}}</b>
|
||||
<p>Provider of the subtitles file.</p>
|
||||
<b>{{series_id}}</b>
|
||||
<p>Sonarr series ID. Empty if movie.</p>
|
||||
<b>{{episode_id}}</b>
|
||||
<p>Sonarr episode ID or Radarr movie ID.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue