diff options
author | msglm <msglm@techchud.xyz> | 2025-08-17 19:53:50 -0500 |
---|---|---|
committer | msglm <msglm@techchud.xyz> | 2025-08-17 19:53:50 -0500 |
commit | 93249a8b74e2d66720cce65172d0a4d585152d69 (patch) | |
tree | 1f85bcef2b6fb13e03346e0d76098dfdee6b70bf | |
parent | 943a9140f6a6e00d2f718aefba171349830be997 (diff) | |
download | comedyGenerator-93249a8b74e2d66720cce65172d0a4d585152d69.tar.gz comedyGenerator-93249a8b74e2d66720cce65172d0a4d585152d69.tar.bz2 comedyGenerator-93249a8b74e2d66720cce65172d0a4d585152d69.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: |