Skip to content

Commit

Permalink
Handle 404 for mpd differently
Browse files Browse the repository at this point in the history
  • Loading branch information
ping committed Jun 9, 2017
1 parent 7f564fb commit 7b9f1ca
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions instagram_private_api_extensions/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,18 @@ def run(self):

except requests.HTTPError as e:
err_msg = 'HTTPError downloading {0!s}: {1!s}.'.format(self.mpd, e)
if e.response is not None and e.response.status_code >= 500:
logger.warning(err_msg)
time.sleep(5)
if e.response is not None and \
(e.response.status_code >= 500 or e.response.status_code == 404):
# 505 - temporal server problem
# 404 - seems to indicate that stream is starting but not ready
# 403 - stream is too long gone
connection_retries_count += 1
if connection_retries_count <= self.max_connection_error_retry:
logger.warning(err_msg)
time.sleep(5)
else:
logger.error(err_msg)
self.is_aborted = True
else:
logger.error(err_msg)
self.is_aborted = True
Expand Down

0 comments on commit 7b9f1ca

Please sign in to comment.