From 670479f28471d9ad782fdff81034f89ca02ab0d8 Mon Sep 17 00:00:00 2001 From: msglm Date: Wed, 11 Jan 2023 20:51:07 -0600 Subject: broke it again --- comedyGenerator | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/comedyGenerator b/comedyGenerator index bd015b7..7925367 100755 --- a/comedyGenerator +++ b/comedyGenerator @@ -1,7 +1,6 @@ #!/usr/bin/python3 import requests import urllib.request -import urllib3.exceptions import sys import os import argparse @@ -124,7 +123,7 @@ elif args.usingJavascript: except: if tries < 100 - 1: print("Rate Limited! Sleeping for " + str(tries*1.5) + " seconds!") - time.sleep(tries*1.5) + #time.sleep(tries*1.5) continue break @@ -137,35 +136,37 @@ elif args.usingJavascript: driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") isTimesScrolled = isTimesScrolled + 1 time.sleep(3) + if args.debug: + print("Need to scroll " + str(oughtTimeScrolled-isTimesScrolled) + " more times...") + videos = driver.find_elements(By.TAG_NAME,"video") if args.debug: - print("Need to scroll " + str(oughtTimeScrolled-isTimesScrolled) + " more times...") - videos = driver.find_elements(By.TAG_NAME,"video") - if args.debug: - print("Original Videos List: ") - print(videos) + print("Original Videos List: ") + print(videos) if args.amount > 0: videos = videos[:args.amount] if args.debug: print("Videos list truncated! Its now: " + str(len(videos)) + " units long") for video in videos: + print("Now running for " + str(video)) URL = video.get_attribute("data-src") if isinstance(URL, str): if args.debug: print("URL read as: " + URL) - name = tags + "-" + hashlib.md5(URL.encode('utf-8')).hexdigest() + ".mp4" - if args.debug: - print("name read as: " + name) - print("saving " + video.get_attribute("data-src") + " as " + name) - for tries in range(100): - try: - urllib.request.urlretrieve(video.get_attribute("data-src"), '/home/' + os.environ['USER'] + '/Videos/unsorted/' + name) - except: - if tries < 100 - 1: - print("Rate Limited! Sleeping for " + str(tries*1.5) + " seconds!") - time.sleep(tries*1.5) - continue - break + name = tags + "-" + hashlib.md5(URL.encode('utf-8')).hexdigest() + ".mp4" + if args.debug: + print("name read as: " + name) + print("saving " + video.get_attribute("data-src") + " as " + name) + for tries in range(100): + try: + urllib.request.urlretrieve(video.get_attribute("data-src"), '/home/' + os.environ['USER'] + '/Videos/unsorted/' + name) + except: + if tries < 100 - 1: + print("Rate Limited! Sleeping for " + str(tries*1.5) + " seconds!") + time.sleep(tries*1.5) + continue + break + elif args.debug: print("URL is NOT a string, it is a " + str(type(URL))) print("URL was " + URL) -- cgit v1.2.3