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.

pull/1414/head
morpheus65535 4 years ago
parent 70a0f6835e
commit 5f99836801

@ -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'])))

@ -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']))

@ -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.')

Loading…
Cancel
Save