summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2022-03-15 16:14:38 -0400
committermorpheus65535 <[email protected]>2022-03-15 16:14:38 -0400
commitf81972b291b73f5771c40359f18d6470b23e2650 (patch)
treee8d4a44f8b9bfa4d8844e820a50361b7b60a4099
parent6fc4f135ba54e57b89a073a1c6506ab42ad46e4f (diff)
downloadbazarr-f81972b291b73f5771c40359f18d6470b23e2650.tar.gz
bazarr-f81972b291b73f5771c40359f18d6470b23e2650.zip
Fixed upgrade subtitles function that was trying to upgrade deleted episode/movie subtitles. #1759v1.0.4-beta.8
-rw-r--r--bazarr/api/episodes/history.py4
-rw-r--r--bazarr/api/movies/history.py6
-rw-r--r--bazarr/get_subtitle/upgrade.py8
3 files changed, 13 insertions, 5 deletions
diff --git a/bazarr/api/episodes/history.py b/bazarr/api/episodes/history.py
index d6b77bb81..f0a83d397 100644
--- a/bazarr/api/episodes/history.py
+++ b/bazarr/api/episodes/history.py
@@ -79,6 +79,7 @@ class EpisodesHistory(Resource):
TableHistory.score,
TableShows.tags,
TableHistory.action,
+ TableHistory.video_path,
TableHistory.subtitles_path,
TableHistory.sonarrEpisodeId,
TableHistory.provider,
@@ -101,7 +102,8 @@ class EpisodesHistory(Resource):
if {"video_path": str(item['path']), "timestamp": float(item['timestamp']), "score": str(item['score']),
"tags": str(item['tags']), "monitored": str(item['monitored']),
"seriesType": str(item['seriesType'])} in upgradable_episodes_not_perfect: # noqa: E129
- if os.path.isfile(path_mappings.path_replace(item['subtitles_path'])):
+ if os.path.exists(path_mappings.path_replace(item['subtitles_path'])) and \
+ os.path.exists(path_mappings.path_replace(item['video_path'])):
item.update({"upgradable": True})
del item['path']
diff --git a/bazarr/api/movies/history.py b/bazarr/api/movies/history.py
index 9f50d335e..8700b2e8e 100644
--- a/bazarr/api/movies/history.py
+++ b/bazarr/api/movies/history.py
@@ -79,7 +79,8 @@ class MoviesHistory(Resource):
TableHistoryMovie.score,
TableHistoryMovie.subs_id,
TableHistoryMovie.provider,
- TableHistoryMovie.subtitles_path)\
+ TableHistoryMovie.subtitles_path,
+ TableHistoryMovie.video_path)\
.join(TableMovies, on=(TableHistoryMovie.radarrId == TableMovies.radarrId))\
.where(query_condition)\
.order_by(TableHistoryMovie.timestamp.desc())\
@@ -96,7 +97,8 @@ class MoviesHistory(Resource):
item.update({"upgradable": False})
if {"video_path": str(item['path']), "timestamp": float(item['timestamp']), "score": str(item['score']),
"tags": str(item['tags']), "monitored": str(item['monitored'])} in upgradable_movies_not_perfect: # noqa: E129
- if os.path.isfile(path_mappings.path_replace_movie(item['subtitles_path'])):
+ if os.path.exists(path_mappings.path_replace_movie(item['subtitles_path'])) and \
+ os.path.exists(path_mappings.path_replace_movie(item['video_path'])):
item.update({"upgradable": True})
del item['path']
diff --git a/bazarr/get_subtitle/upgrade.py b/bazarr/get_subtitle/upgrade.py
index c1df93a8d..f6d3da6ab 100644
--- a/bazarr/get_subtitle/upgrade.py
+++ b/bazarr/get_subtitle/upgrade.py
@@ -73,7 +73,9 @@ def upgrade_subtitles():
episodes_to_upgrade = []
for episode in upgradable_episodes_not_perfect:
- if os.path.exists(path_mappings.path_replace(episode['subtitles_path'])) and int(episode['score']) < 357:
+ if os.path.exists(path_mappings.path_replace(episode['subtitles_path'])) and \
+ os.path.exists(path_mappings.path_replace(episode['video_path'])) and \
+ int(episode['score']) < 357:
episodes_to_upgrade.append(episode)
count_episode_to_upgrade = len(episodes_to_upgrade)
@@ -114,7 +116,9 @@ def upgrade_subtitles():
movies_to_upgrade = []
for movie in upgradable_movies_not_perfect:
- if os.path.exists(path_mappings.path_replace_movie(movie['subtitles_path'])) and int(movie['score']) < 117:
+ if os.path.exists(path_mappings.path_replace_movie(movie['subtitles_path'])) and \
+ os.path.exists(path_mappings.path_replace_movie(movie['video_path'])) and \
+ int(movie['score']) < 117:
movies_to_upgrade.append(movie)
count_movie_to_upgrade = len(movies_to_upgrade)