diff options
author | msglm <msglm@techchud.xyz> | 2023-01-11 20:51:07 -0600 |
---|---|---|
committer | msglm <msglm@techchud.xyz> | 2023-01-11 20:51:07 -0600 |
commit | 5a9733d69c7de346c6f82c44e6a8dfb39495979d (patch) | |
tree | 1f85bcef2b6fb13e03346e0d76098dfdee6b70bf | |
parent | 1a0b15057b88bba4af0d0743ed17c24e738275f5 (diff) | |
download | comedyGenerator-5a9733d69c7de346c6f82c44e6a8dfb39495979d.tar.gz comedyGenerator-5a9733d69c7de346c6f82c44e6a8dfb39495979d.tar.bz2 comedyGenerator-5a9733d69c7de346c6f82c44e6a8dfb39495979d.zip |
fixed rate limit issue due to closed webdriver
-rwxr-xr-x | comedyGenerator | 14 |
1 files 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: |