Currently the script just throws error "Sleeping for 10 seconds, server might be rate limiting!" on the following condition:
elif video_metadata.status_code == 401 or video_metadata.status_code == 403 or video_metadata.status_code == 502:
logger.warning("Sleeping for 10 seconds, server might be rate limiting!")
sleep(10)
refresh_token(video_metadata)
download_video(course_name, content_uuid, complete_path, index)
This is a bad implementation since these HTTP responses could be produced anywhere and aren't just limited to rate-limiting errors. Better way would be to parse the error body and based on that, determine if user is rate limited, session has expired, or something else needs to be done.
Currently the script just throws error "Sleeping for 10 seconds, server might be rate limiting!" on the following condition:
This is a bad implementation since these HTTP responses could be produced anywhere and aren't just limited to rate-limiting errors. Better way would be to parse the error body and based on that, determine if user is rate limited, session has expired, or something else needs to be done.