summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2021-05-17 23:56:55 -0400
committermorpheus65535 <[email protected]>2021-05-17 23:56:55 -0400
commit5f99836801e2b63438a5026135f738dbb9090414 (patch)
tree7e65224d517aae5f80ac0c1491d6ee3e374437eb
parent70a0f6835e68e72e70340d0153cd0f2bcd5a9b53 (diff)
downloadbazarr-5f99836801e2b63438a5026135f738dbb9090414.tar.gz
bazarr-5f99836801e2b63438a5026135f738dbb9090414.zip
Added argument to disable the socketio events emit process to avoid events storm rendering the UI unresponsive. I still need to use it when calling sync functions from signalr_client.py.
-rw-r--r--bazarr/get_episodes.py5
-rw-r--r--bazarr/get_movies.py4
-rw-r--r--bazarr/get_series.py11
3 files changed, 13 insertions, 7 deletions
diff --git a/bazarr/get_episodes.py b/bazarr/get_episodes.py
index 96fde111b..9acbd55e5 100644
--- a/bazarr/get_episodes.py
+++ b/bazarr/get_episodes.py
@@ -19,7 +19,7 @@ def update_all_episodes():
logging.info('BAZARR All existing episode subtitles indexed from disk.')
-def sync_episodes():
+def sync_episodes(send_event=True):
logging.debug('BAZARR Starting episodes sync from Sonarr.')
apikey_sonarr = settings.sonarr.apikey
@@ -110,7 +110,8 @@ def sync_episodes():
altered_episodes.append([added_episode['sonarrEpisodeId'],
added_episode['path'],
added_episode['monitored']])
- event_stream(type='episode', payload=added_episode['sonarrEpisodeId'])
+ if send_event:
+ event_stream(type='episode', payload=added_episode['sonarrEpisodeId'])
else:
logging.debug('BAZARR unable to insert this episode into the database:{}'.format(
path_mappings.path_replace(added_episode['path'])))
diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py
index df4d1b46d..c5f256c8c 100644
--- a/bazarr/get_movies.py
+++ b/bazarr/get_movies.py
@@ -22,7 +22,7 @@ def update_all_movies():
logging.info('BAZARR All existing movie subtitles indexed from disk.')
-def update_movies():
+def update_movies(send_event=True):
check_radarr_rootfolder()
logging.debug('BAZARR Starting movie sync from Radarr.')
apikey_radarr = settings.radarr.apikey
@@ -133,6 +133,8 @@ def update_movies():
added_movie['path'],
added_movie['radarrId'],
added_movie['monitored']])
+ if send_event:
+ event_stream(type='movie', action='update', payload=int(added_movie['radarrId']))
else:
logging.debug('BAZARR unable to insert this movie into the database:',
path_mappings.path_replace_movie(added_movie['path']))
diff --git a/bazarr/get_series.py b/bazarr/get_series.py
index ff0a39025..98257b8b5 100644
--- a/bazarr/get_series.py
+++ b/bazarr/get_series.py
@@ -15,7 +15,7 @@ from event_handler import event_stream, show_progress, hide_progress
headers = {"User-Agent": os.environ["SZ_USER_AGENT"]}
-def update_series():
+def update_series(send_event=True):
check_sonarr_rootfolder()
apikey_sonarr = settings.sonarr.apikey
if apikey_sonarr is None:
@@ -80,7 +80,8 @@ def update_series():
for series in removed_series:
database.execute("DELETE FROM table_shows WHERE sonarrSeriesId=?",(series,))
- event_stream(type='series', action='delete', payload=series)
+ if send_event:
+ event_stream(type='series', action='delete', payload=series)
# Update existing series in DB
series_in_db_list = []
@@ -97,7 +98,8 @@ def update_series():
query = dict_converter.convert(updated_series)
database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''',
query.values + (updated_series['sonarrSeriesId'],))
- event_stream(type='series', payload=updated_series['sonarrSeriesId'])
+ if send_event:
+ event_stream(type='series', payload=updated_series['sonarrSeriesId'])
# Insert new series in DB
for added_series in series_to_add:
@@ -111,7 +113,8 @@ def update_series():
logging.debug('BAZARR unable to insert this series into the database:',
path_mappings.path_replace(added_series['path']))
- event_stream(type='series', action='update', payload=added_series['sonarrSeriesId'])
+ if send_event:
+ event_stream(type='series', action='update', payload=added_series['sonarrSeriesId'])
logging.debug('BAZARR All series synced from Sonarr into database.')