Anon-Exploiter / ine-dl

Python script to download INE courses including labs, exercises, quizzes, slides, and, videos!
MIT License
17 stars 8 forks source link

[Code Change] - Better Handling of rate limiting and other errors #10

Open Anon-Exploiter opened 8 months ago

Anon-Exploiter commented 8 months ago

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.