Cleaner channel-checking console error messages when Tor is closed
by James Taylor <user234683@users.noreply.github.com>
This commit is contained in:
parent
d0e3adab01
commit
f5f9b1c181
@ -432,9 +432,8 @@ def autocheck_setting_changed(old_value, new_value):
|
||||
stop_autocheck_system()
|
||||
|
||||
|
||||
settings.add_setting_changed_hook(
|
||||
'autocheck_subscriptions',
|
||||
autocheck_setting_changed)
|
||||
settings.add_setting_changed_hook('autocheck_subscriptions',
|
||||
autocheck_setting_changed)
|
||||
if settings.autocheck_subscriptions:
|
||||
start_autocheck_system()
|
||||
# ----------------------------
|
||||
@ -455,12 +454,14 @@ def _get_atoma_feed(channel_id):
|
||||
# 404 is expected for terminated channels
|
||||
if e.code in ('404', '429'):
|
||||
return ''
|
||||
if e.code == '502':
|
||||
return str(e)
|
||||
raise
|
||||
|
||||
|
||||
def _get_channel_tab(channel_id, channel_status_name):
|
||||
def _get_channel_videos_first_page(channel_id, channel_status_name):
|
||||
try:
|
||||
return channel.get_channel_tab(channel_id, print_status=False)
|
||||
return channel.get_channel_first_page(channel_id=channel_id)
|
||||
except util.FetchError as e:
|
||||
if e.code == '429' and settings.route_tor:
|
||||
error_message = ('Error checking channel ' + channel_status_name
|
||||
@ -471,6 +472,9 @@ def _get_channel_tab(channel_id, channel_status_name):
|
||||
error_message += ' Exit node IP address: ' + e.ip
|
||||
print(error_message)
|
||||
return None
|
||||
elif e.code == '502':
|
||||
print('Error checking channel', channel_status_name + ':', str(e))
|
||||
return None
|
||||
raise
|
||||
|
||||
|
||||
@ -484,7 +488,8 @@ def _get_upstream_videos(channel_id):
|
||||
|
||||
tasks = (
|
||||
# channel page, need for video duration
|
||||
gevent.spawn(channel.get_channel_first_page, channel_id=channel_id),
|
||||
gevent.spawn(_get_channel_videos_first_page, channel_id,
|
||||
channel_status_name),
|
||||
# need atoma feed for exact published time
|
||||
gevent.spawn(_get_atoma_feed, channel_id)
|
||||
)
|
||||
@ -900,8 +905,7 @@ def get_subscriptions_page():
|
||||
'muted': muted,
|
||||
})
|
||||
|
||||
return flask.render_template(
|
||||
'subscriptions.html',
|
||||
return flask.render_template('subscriptions.html',
|
||||
header_playlist_names=local_playlist.get_playlist_names(),
|
||||
videos=videos,
|
||||
num_pages=math.ceil(number_of_videos_in_db/60),
|
||||
|
@ -194,7 +194,11 @@ class HTTPAsymmetricCookieProcessor(urllib.request.BaseHandler):
|
||||
|
||||
class FetchError(Exception):
|
||||
def __init__(self, code, reason='', ip=None, error_message=None):
|
||||
Exception.__init__(self, 'HTTP error during request: ' + code + ' ' + reason)
|
||||
if error_message:
|
||||
string = code + ' ' + reason + ': ' + error_message
|
||||
else:
|
||||
string = 'HTTP error during request: ' + code + ' ' + reason
|
||||
Exception.__init__(self, string)
|
||||
self.code = code
|
||||
self.reason = reason
|
||||
self.ip = ip
|
||||
|
Loading…
x
Reference in New Issue
Block a user