aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2024-10-16 21:53:38 -0400
committermorpheus65535 <[email protected]>2024-10-16 21:53:38 -0400
commitde9ce4d13dc0fc2fa25597d9d3eb13bf025dc22a (patch)
treeef1899e95f1d33be69989df2dc37b6b4e577c0a2
parent5139fca5b8f60dd05be76c59296c3388d62d8199 (diff)
downloadbazarr-de9ce4d13dc0fc2fa25597d9d3eb13bf025dc22a.tar.gz
bazarr-de9ce4d13dc0fc2fa25597d9d3eb13bf025dc22a.zip
Fixed issue with subtitles upgrade process on Windows
-rw-r--r--bazarr/api/episodes/history.py2
-rw-r--r--bazarr/api/movies/history.py2
-rw-r--r--bazarr/subtitles/upgrade.py15
3 files changed, 14 insertions, 5 deletions
diff --git a/bazarr/api/episodes/history.py b/bazarr/api/episodes/history.py
index 026397363..6ea13fb48 100644
--- a/bazarr/api/episodes/history.py
+++ b/bazarr/api/episodes/history.py
@@ -129,7 +129,7 @@ class EpisodesHistory(Resource):
'provider': x.provider,
'matches': x.matched,
'dont_matches': x.not_matched,
- 'external_subtitles': [y[1] for y in ast.literal_eval(x.external_subtitles) if y[1]],
+ 'external_subtitles': [ast.literal_eval(f'"{y[1]}"') for y in ast.literal_eval(x.external_subtitles) if y[1]],
'upgradable': bool(x.upgradable) if _language_still_desired(x.language, x.profileId) else False,
'blacklisted': bool(x.blacklisted),
} for x in database.execute(stmt).all()]
diff --git a/bazarr/api/movies/history.py b/bazarr/api/movies/history.py
index d7e7d6783..a5c4a802c 100644
--- a/bazarr/api/movies/history.py
+++ b/bazarr/api/movies/history.py
@@ -120,7 +120,7 @@ class MoviesHistory(Resource):
'video_path': x.video_path,
'matches': x.matched,
'dont_matches': x.not_matched,
- 'external_subtitles': [y[1] for y in ast.literal_eval(x.external_subtitles) if y[1]],
+ 'external_subtitles': [ast.literal_eval(f'"{y[1]}"') for y in ast.literal_eval(x.external_subtitles) if y[1]],
'upgradable': bool(x.upgradable) if _language_still_desired(x.language, x.profileId) else False,
'blacklisted': bool(x.blacklisted),
} for x in database.execute(stmt).all()]
diff --git a/bazarr/subtitles/upgrade.py b/bazarr/subtitles/upgrade.py
index d094d7caa..8c2f3f5b6 100644
--- a/bazarr/subtitles/upgrade.py
+++ b/bazarr/subtitles/upgrade.py
@@ -45,7 +45,7 @@ def upgrade_subtitles():
'subtitles_path': x.subtitles_path,
'path': x.path,
'profileId': x.profileId,
- 'external_subtitles': [y[1] for y in ast.literal_eval(x.external_subtitles) if y[1]],
+ 'external_subtitles': [ast.literal_eval(f'"{y[1]}"') for y in ast.literal_eval(x.external_subtitles) if y[1]],
'upgradable': bool(x.upgradable),
} for x in database.execute(
select(TableHistory.id,
@@ -76,6 +76,11 @@ def upgrade_subtitles():
]
for item in episodes_data:
+ # do not consider subtitles that do not exist on disk anymore
+ if item['subtitles_path'] not in item['external_subtitles']:
+ episodes_data.remove(item)
+
+ # cleanup the unused attributes
del item['path']
del item['external_subtitles']
@@ -138,7 +143,7 @@ def upgrade_subtitles():
'path': x.path,
'profileId': x.profileId,
'subtitles_path': x.subtitles_path,
- 'external_subtitles': [y[1] for y in ast.literal_eval(x.external_subtitles) if y[1]],
+ 'external_subtitles': [ast.literal_eval(f'"{y[1]}"') for y in ast.literal_eval(x.external_subtitles) if y[1]],
'upgradable': bool(x.upgradable),
} for x in database.execute(
select(TableMovies.title,
@@ -158,11 +163,15 @@ def upgrade_subtitles():
.join(movies_to_upgrade, onclause=TableHistoryMovie.id == movies_to_upgrade.c.id, isouter=True)
.where(movies_to_upgrade.c.id.is_not(None)))
.all() if _language_still_desired(x.language, x.profileId) and
- x.subtitles_path in x.external_subtitles and
x.video_path == x.path
]
for item in movies_data:
+ # do not consider subtitles that do not exist on disk anymore
+ if item['subtitles_path'] not in item['external_subtitles']:
+ movies_data.remove(item)
+
+ # cleanup the unused attributes
del item['path']
del item['external_subtitles']