From bec5ca31143c6c84213f9e3fde56e6eca46fbee1 Mon Sep 17 00:00:00 2001 From: msglm Date: Wed, 11 Jan 2023 20:51:07 -0600 Subject: NoneType error fixed --- comedyGenerator | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/comedyGenerator b/comedyGenerator index ac5b3da..894acc4 100755 --- a/comedyGenerator +++ b/comedyGenerator @@ -149,21 +149,27 @@ elif args.usingJavascript: print("Videos list truncated! Its now: " + str(len(videos)) + " units long") for video in videos: URL = video.get_attribute("data-src") - 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 + if isinstance(URL, str) and args.debug == True: + print("URL is a string!") + else: + print("URL is NOT a string, it is a " + str(type(URL))) + + 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 driver.quit() else: -- cgit v1.2.3