Add parameter skip_failures to refresh_all_channels.

This commit is contained in:
voussoir 2020-01-19 10:53:49 -08:00
parent 03b5e97d33
commit 6691c49481
2 changed files with 14 additions and 3 deletions

View file

@ -265,7 +265,8 @@ def refresher_thread():
while True: while True:
time.sleep(60 * 60 * 6) time.sleep(60 * 60 * 6)
print('Starting refresh job.') print('Starting refresh job.')
refresh_job = threading.Thread(target=youtube.refresh_all_channels, kwargs={'force': False}, daemon=True) thread_kwargs = {'force': False, 'skip_failures': True}
refresh_job = threading.Thread(target=youtube.refresh_all_channels, kwargs=thread_kwargs, daemon=True)
refresh_job.start() refresh_job.start()
refresher = threading.Thread(target=refresher_thread, daemon=True) refresher = threading.Thread(target=refresher_thread, daemon=True)

View file

@ -1,6 +1,7 @@
import logging import logging
import os import os
import sqlite3 import sqlite3
import traceback
from . import helpers from . import helpers
from . import ytapi from . import ytapi
@ -302,11 +303,20 @@ class YCDL:
if commit: if commit:
self.sql.commit() self.sql.commit()
def refresh_all_channels(self, force=False, commit=True): def refresh_all_channels(self, force=False, skip_failures=False, commit=True):
exceptions = []
for channel in self.get_channels(): for channel in self.get_channels():
self.refresh_channel(channel, force=force, commit=commit) try:
self.refresh_channel(channel, force=force, commit=commit)
except Exception as exc:
if skip_failures:
traceback.print_exc()
exceptions.append(exc)
else:
raise
if commit: if commit:
self.sql.commit() self.sql.commit()
return exceptions
def refresh_channel(self, channel, force=False, commit=True): def refresh_channel(self, channel, force=False, commit=True):
if isinstance(channel, str): if isinstance(channel, str):