diff options
Diffstat (limited to 'youtube/subscriptions.py')
-rw-r--r-- | youtube/subscriptions.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/youtube/subscriptions.py b/youtube/subscriptions.py index 503f3fa..afc3df9 100644 --- a/youtube/subscriptions.py +++ b/youtube/subscriptions.py @@ -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), |