Skip to content

Commit

Permalink
[sites:reddit] Retry when an invalid socket url is returned
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Jul 23, 2021
1 parent 71d70a7 commit cd0949e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions chat_downloader/sites/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,10 @@ def get_chat_by_post_id(self, post_id, params, attempt_number=0, initial_info=No

if is_live and socket_url: # live stream

if not socket_url.startswith('wss://'):
raise RedditError(
'Invalid websocket URL: {}'.format(socket_url))
if not socket_url.startswith('wss://') or 'wss.redditmedia.com' not in socket_url:
self.retry(attempt_number, text='Invalid websocket URL: {}'.format(socket_url), **params)
return self.get_chat_by_post_id(post_id, params, attempt_number + 1)


chat_item.chat = self._get_chat_messages_by_socket(
socket_url, params)
Expand Down

0 comments on commit cd0949e

Please sign in to comment.