Skip to content

Commit

Permalink
Fixed history logging of downloaded and uploaded subtitles. #2261
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheus65535 committed Oct 8, 2023
1 parent 0f216ab commit 2972c38
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bazarr/api/episodes/episodes_subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def post(self):
if not result:
logging.debug(f"BAZARR unable to process subtitles for this episode: {episodePath}")
else:
if isinstance(result, tuple) and len(result):
result = result[0]
provider = "manual"
score = 360
history_log(4, sonarrSeriesId, sonarrEpisodeId, result, fake_provider=provider, fake_score=score)
Expand Down
2 changes: 2 additions & 0 deletions bazarr/api/movies/movies_subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ def post(self):
if not result:
logging.debug(f"BAZARR unable to process subtitles for this movie: {moviePath}")
else:
if isinstance(result, tuple) and len(result):
result = result[0]
provider = "manual"
score = 120
history_log_movie(4, radarrId, result, fake_provider=provider, fake_score=score)
Expand Down
2 changes: 2 additions & 0 deletions bazarr/api/providers/providers_episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def post(self):
except OSError:
return 'Unable to save subtitles file', 500
else:
if isinstance(result, tuple) and len(result):
result = result[0]
if isinstance(result, ProcessSubtitlesResult):
history_log(2, sonarrSeriesId, sonarrEpisodeId, result)
if not settings.general.getboolean('dont_notify_manual_actions'):
Expand Down
2 changes: 2 additions & 0 deletions bazarr/api/providers/providers_movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def post(self):
except OSError:
return 'Unable to save subtitles file', 500
else:
if isinstance(result, tuple) and len(result):
result = result[0]
if isinstance(result, ProcessSubtitlesResult):
history_log_movie(2, radarrId, result)
if not settings.general.getboolean('dont_notify_manual_actions'):
Expand Down
2 changes: 2 additions & 0 deletions bazarr/subtitles/mass_download/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def movies_download_subtitles(no):
check_if_still_required=True):

if result:
if isinstance(result, tuple) and len(result):
result = result[0]
store_subtitles_movie(movie.path, moviePath)
history_log_movie(1, no, result)
send_notifications_movie(no, result.message)
Expand Down
4 changes: 4 additions & 0 deletions bazarr/subtitles/mass_download/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def series_download_subtitles(no):
'series',
check_if_still_required=True):
if result:
if isinstance(result, tuple) and len(result):
result = result[0]
store_subtitles(episode.path, path_mappings.path_replace(episode.path))
history_log(1, no, episode.sonarrEpisodeId, result)
send_notifications(no, episode.sonarrEpisodeId, result.message)
Expand Down Expand Up @@ -165,6 +167,8 @@ def episode_download_subtitles(no, send_progress=False):
'series',
check_if_still_required=True):
if result:
if isinstance(result, tuple) and len(result):
result = result[0]
store_subtitles(episode.path, path_mappings.path_replace(episode.path))
history_log(1, episode.sonarrSeriesId, episode.sonarrEpisodeId, result)
send_notifications(episode.sonarrSeriesId, episode.sonarrEpisodeId, result.message)
Expand Down
10 changes: 8 additions & 2 deletions bazarr/subtitles/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ def upgrade_subtitles():
is_upgrade=True))

if result:
result = result[0]
if isinstance(result, list) and len(result):
result = result[0]
if isinstance(result, tuple) and len(result):
result = result[0]
store_subtitles(episode['video_path'], path_mappings.path_replace(episode['video_path']))
history_log(3, episode['sonarrSeriesId'], episode['sonarrEpisodeId'], result)
send_notifications(episode['sonarrSeriesId'], episode['sonarrEpisodeId'], result.message)
Expand Down Expand Up @@ -197,7 +200,10 @@ def upgrade_subtitles():
forced_minimum_score=int(movie['score']),
is_upgrade=True))
if result:
result = result[0]
if isinstance(result, list) and len(result):
result = result[0]
if isinstance(result, tuple) and len(result):
result = result[0]
store_subtitles_movie(movie['video_path'],
path_mappings.path_replace_movie(movie['video_path']))
history_log_movie(3, movie['radarrId'], result)
Expand Down
2 changes: 2 additions & 0 deletions bazarr/subtitles/wanted/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def _wanted_movie(movie):
check_if_still_required=True):

if result:
if isinstance(result, tuple) and len(result):
result = result[0]
store_subtitles_movie(movie.path, path_mappings.path_replace_movie(movie.path))
history_log_movie(1, movie.radarrId, result)
event_stream(type='movie-wanted', action='delete', payload=movie.radarrId)
Expand Down
2 changes: 2 additions & 0 deletions bazarr/subtitles/wanted/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def _wanted_episode(episode):
'series',
check_if_still_required=True):
if result:
if isinstance(result, tuple) and len(result):
result = result[0]
store_subtitles(episode.path, path_mappings.path_replace(episode.path))
history_log(1, episode.sonarrSeriesId, episode.sonarrEpisodeId, result)
event_stream(type='series', action='update', payload=episode.sonarrSeriesId)
Expand Down

0 comments on commit 2972c38

Please sign in to comment.