From b3f9a2d5fb59b9ef45f9d94b16b816e56dcb7a7d Mon Sep 17 00:00:00 2001 From: msglm Date: Wed, 11 Jan 2023 20:51:07 -0600 Subject: added extra rate limiting --- comedyGenerator | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/comedyGenerator b/comedyGenerator index 1ba068e..c64044e 100755 --- a/comedyGenerator +++ b/comedyGenerator @@ -85,8 +85,8 @@ elif args.usingJavascript: driver.get('https://ifunny.co/tags/' + tags + '?filter=video') except: if tries < 100 - 1: - print("Rate Limited! Sleeping for " + str(tries*12) + " seconds!") - time.sleep(tries*12) + print("Rate Limited! Sleeping for " + str(tries*1.5) + " seconds!") + time.sleep(tries*1.5) continue break @@ -104,7 +104,16 @@ elif args.usingJavascript: for video in videos: epoch = epoch + 1 print("saving " + video.get_attribute("data-src") + " as " + str(epoch) + '.mp4') - urllib.request.urlretrieve(video.get_attribute("data-src"), '/home/' + os.environ['USER'] + '/Videos/unsorted/' + str(epoch) + '.mp4') + for tries in range(100): + try: + urllib.request.urlretrieve(video.get_attribute("data-src"), '/home/' + os.environ['USER'] + '/Videos/unsorted/' + str(epoch) + '.mp4') + except: + if tries < 100 - 1: + print("Rate Limited! Sleeping for " + str(tries*1.5) + " seconds!") + time.sleep(tries*1.5) + continue + break + driver.quit() else: print("Neither Javascript or HTML was given!") -- cgit v1.2.3