mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-04-23 22:27:17 -04:00
Fixed issue with subtitles upgrade process on Windows
This commit is contained in:
parent
5139fca5b8
commit
de9ce4d13d
3 changed files with 14 additions and 5 deletions
|
@ -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()]
|
||||
|
|
|
@ -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()]
|
||||
|
|
|
@ -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']
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue