mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-23 06:21:05 +00:00
Fixed issues with SQlite older than 3.35.
This commit is contained in:
parent
2ad7ddf5a6
commit
fe987babc5
2 changed files with 16 additions and 22 deletions
|
@ -40,8 +40,7 @@ def update_movie(updated_movie, send_event):
|
|||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot update movie {updated_movie['path']} because of {e}")
|
||||
else:
|
||||
store_subtitles_movie(updated_movie['path'],
|
||||
path_mappings.path_replace_movie(updated_movie['path']))
|
||||
store_subtitles_movie(updated_movie['path'], path_mappings.path_replace_movie(updated_movie['path']))
|
||||
|
||||
if send_event:
|
||||
event_stream(type='movie', action='update', payload=updated_movie['radarrId'])
|
||||
|
@ -56,8 +55,7 @@ def add_movie(added_movie, send_event):
|
|||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot insert movie {added_movie['path']} because of {e}")
|
||||
else:
|
||||
store_subtitles_movie(added_movie['path'],
|
||||
path_mappings.path_replace_movie(added_movie['path']))
|
||||
store_subtitles_movie(added_movie['path'], path_mappings.path_replace_movie(added_movie['path']))
|
||||
|
||||
if send_event:
|
||||
event_stream(type='movie', action='update', payload=int(added_movie['radarrId']))
|
||||
|
@ -109,15 +107,13 @@ def update_movies(send_event=True):
|
|||
|
||||
if len(movies_to_delete):
|
||||
try:
|
||||
removed_movies = database.execute(delete(TableMovies)
|
||||
.where(TableMovies.tmdbId.in_(movies_to_delete))
|
||||
.returning(TableMovies.radarrId))
|
||||
database.execute(delete(TableMovies).where(TableMovies.tmdbId.in_(movies_to_delete)))
|
||||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot delete movies because of {e}")
|
||||
else:
|
||||
for removed_movie in removed_movies:
|
||||
for removed_movie in movies_to_delete:
|
||||
if send_event:
|
||||
event_stream(type='movie', action='delete', payload=removed_movie.radarrId)
|
||||
event_stream(type='movie', action='delete', payload=removed_movie)
|
||||
|
||||
# Build new and updated movies
|
||||
movies_count = len(movies)
|
||||
|
@ -240,6 +236,7 @@ def update_one_movie(movie_id, action, defer_search=False):
|
|||
logging.error(f"BAZARR cannot update movie {path_mappings.path_replace_movie(movie['path'])} because "
|
||||
f"of {e}")
|
||||
else:
|
||||
store_subtitles_movie(movie['path'], path_mappings.path_replace_movie(movie['path']))
|
||||
event_stream(type='movie', action='update', payload=int(movie_id))
|
||||
logging.debug(
|
||||
f'BAZARR updated this movie into the database:{path_mappings.path_replace_movie(movie["path"])}')
|
||||
|
@ -254,6 +251,7 @@ def update_one_movie(movie_id, action, defer_search=False):
|
|||
logging.error(f"BAZARR cannot insert movie {path_mappings.path_replace_movie(movie['path'])} because "
|
||||
f"of {e}")
|
||||
else:
|
||||
store_subtitles_movie(movie['path'], path_mappings.path_replace_movie(movie['path']))
|
||||
event_stream(type='movie', action='update', payload=int(movie_id))
|
||||
logging.debug(
|
||||
f'BAZARR inserted this movie into the database:{path_mappings.path_replace_movie(movie["path"])}')
|
||||
|
|
|
@ -86,15 +86,13 @@ def sync_episodes(series_id, send_event=True):
|
|||
|
||||
if len(episodes_to_delete):
|
||||
try:
|
||||
removed_episodes = database.execute(delete(TableEpisodes)
|
||||
.where(TableEpisodes.sonarrEpisodeId.in_(episodes_to_delete))
|
||||
.returning(TableEpisodes.sonarrEpisodeId))
|
||||
database.execute(delete(TableEpisodes).where(TableEpisodes.sonarrEpisodeId.in_(episodes_to_delete)))
|
||||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot delete episodes because of {e}")
|
||||
else:
|
||||
for removed_episode in removed_episodes:
|
||||
for removed_episode in episodes_to_delete:
|
||||
if send_event:
|
||||
event_stream(type='episode', action='delete', payload=removed_episode.sonarrEpisodeId)
|
||||
event_stream(type='episode', action='delete', payload=removed_episode)
|
||||
|
||||
# Update existing episodes in DB
|
||||
if len(episodes_to_update):
|
||||
|
@ -104,7 +102,6 @@ def sync_episodes(series_id, send_event=True):
|
|||
logging.error(f"BAZARR cannot update episodes because of {e}")
|
||||
else:
|
||||
for updated_episode in episodes_to_update:
|
||||
# not using .returning() because it's not supported on executemany() with SQlite
|
||||
store_subtitles(updated_episode['path'], path_mappings.path_replace(updated_episode['path']))
|
||||
|
||||
if send_event:
|
||||
|
@ -113,18 +110,15 @@ def sync_episodes(series_id, send_event=True):
|
|||
# Insert new episodes in DB
|
||||
if len(episodes_to_add):
|
||||
try:
|
||||
added_episodes = database.execute(
|
||||
insert(TableEpisodes)
|
||||
.values(episodes_to_add)
|
||||
.returning(TableEpisodes.sonarrEpisodeId, TableEpisodes.path, TableEpisodes.sonarrSeriesId))
|
||||
database.execute(insert(TableEpisodes).values(episodes_to_add))
|
||||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot insert episodes because of {e}")
|
||||
else:
|
||||
for added_episode in added_episodes:
|
||||
store_subtitles(added_episode.path, path_mappings.path_replace(added_episode.path))
|
||||
for added_episode in episodes_to_add:
|
||||
store_subtitles(added_episode['path'], path_mappings.path_replace(added_episode['path']))
|
||||
|
||||
if send_event:
|
||||
event_stream(type='episode', payload=added_episode.sonarrEpisodeId)
|
||||
event_stream(type='episode', payload=added_episode['sonarrEpisodeId'])
|
||||
|
||||
logging.debug(f'BAZARR All episodes from series ID {series_id} synced from Sonarr into database.')
|
||||
|
||||
|
@ -187,6 +181,7 @@ def sync_one_episode(episode_id, defer_search=False):
|
|||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot update episode {episode['path']} because of {e}")
|
||||
else:
|
||||
store_subtitles(episode['path'], path_mappings.path_replace(episode['path']))
|
||||
event_stream(type='episode', action='update', payload=int(episode_id))
|
||||
logging.debug(
|
||||
f'BAZARR updated this episode into the database:{path_mappings.path_replace(episode["path"])}')
|
||||
|
@ -200,6 +195,7 @@ def sync_one_episode(episode_id, defer_search=False):
|
|||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot insert episode {episode['path']} because of {e}")
|
||||
else:
|
||||
store_subtitles(episode['path'], path_mappings.path_replace(episode['path']))
|
||||
event_stream(type='episode', action='update', payload=int(episode_id))
|
||||
logging.debug(
|
||||
f'BAZARR inserted this episode into the database:{path_mappings.path_replace(episode["path"])}')
|
||||
|
|
Loading…
Reference in a new issue