From 5a9733d69c7de346c6f82c44e6a8dfb39495979d Mon Sep 17 00:00:00 2001 From: msglm Date: Wed, 11 Jan 2023 20:51:07 -0600 Subject: fixed rate limit issue due to closed webdriver --- comedyGenerator | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/comedyGenerator b/comedyGenerator index 01eb216..48ed69f 100755 --- a/comedyGenerator +++ b/comedyGenerator @@ -1,6 +1,7 @@ #!/usr/bin/python3 import requests import urllib.request +import urllib3.exceptions import sys import os import argparse @@ -79,7 +80,16 @@ elif args.usingJavascript: print("If you are using GNU/Linux, it is likely that you can install from your standard repos. Debian labels their chromium driver chromium-driver. If you wish to use an ungoogled version of chromium (as to reduce possiblity of spying), you can find a link to that here: https://github.com/Eloston/ungoogled-chromium#downloads. On Debian (or debian likes such as Ubuntu or Devuan), you may then run apt install ungoogled-chromium-driver and this will no longer fail.") sys.exit() for tags in args.tags: - driver.get('https://ifunny.co/tags/' + tags + '?filter=video') + for tries in range(100): + try: + 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) + continue + break + if args.amount > 0: isTimesScrolled = 0 oughtTimeScrolled = (args.amount/10) + 1 @@ -95,7 +105,7 @@ elif args.usingJavascript: 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') - driver.quit() + driver.close() else: -- cgit v1.2.3