mirror of
https://github.com/morpheus65535/bazarr.git
synced 2024-11-10 17:13:35 +08:00
Fixed (sqlite3.OperationalError) too many SQL variables issue
while inserting too many episodes at the same time.
This commit is contained in:
parent
164d487f06
commit
a10e5dbf37
1 changed files with 14 additions and 12 deletions
|
@ -94,12 +94,14 @@ def sync_episodes(series_id, send_event=True):
|
|||
|
||||
# Update existing episodes in DB
|
||||
if len(episodes_to_update):
|
||||
try:
|
||||
database.execute(update(TableEpisodes), episodes_to_update)
|
||||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot update episodes because of {e}")
|
||||
else:
|
||||
for updated_episode in episodes_to_update:
|
||||
for updated_episode in episodes_to_update:
|
||||
try:
|
||||
database.execute(update(TableEpisodes)
|
||||
.values(updated_episode)
|
||||
.where(TableEpisodes.sonarrEpisodeId == updated_episode['sonarrEpisodeId']))
|
||||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot update episodes because of {e}")
|
||||
else:
|
||||
store_subtitles(updated_episode['path'], path_mappings.path_replace(updated_episode['path']))
|
||||
|
||||
if send_event:
|
||||
|
@ -107,12 +109,12 @@ def sync_episodes(series_id, send_event=True):
|
|||
|
||||
# Insert new episodes in DB
|
||||
if len(episodes_to_add):
|
||||
try:
|
||||
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 episodes_to_add:
|
||||
for added_episode in episodes_to_add:
|
||||
try:
|
||||
database.execute(insert(TableEpisodes).values(added_episode))
|
||||
except IntegrityError as e:
|
||||
logging.error(f"BAZARR cannot insert episodes because of {e}")
|
||||
else:
|
||||
store_subtitles(added_episode['path'], path_mappings.path_replace(added_episode['path']))
|
||||
|
||||
if send_event:
|
||||
|
|
Loading…
Reference in a new issue