import os import time import re import fnmatch def check_download_exists_matching_url_version_one(url): print ("enter > downloads > exist check > version 1") match = re.search(r"https://sullygnome.com/channel/([^/]+)/(\d+)([a-z]+)/games", url.lower()) if not match: print(f"Invalid URL format. Could not extract channel name, year, or month.") return channel_name, year, month = match.groups() print("channel / ",channel_name) #print("year / ",year) #print("month / ",month) #file_pattern = f"{channel_name}*{month}*{year}*.csv" ## this is a problem. it works but if there 2 channels. ## redbull and redbull2 this is throw false positives. ugh file_pattern = f"*{channel_name} - game stats on Twitch in {month} {year} - SullyGnome.csv".lower() for filename in os.listdir("/home/yankee/Downloads/"): updated = filename.lower() #print("file in downloads / ",updated) if fnmatch.fnmatch(updated, file_pattern): print(f"Found matching file: {updated}") return True else: print(f"No matching CSV file found for channel '{channel_name}' in year '{year}' and month '{month}'. (version one)") return False def check_download_exists_matching_url_version_two(url): url="たいじ_たいちゃんねる (yaritaiji) - game stats on Twitch in October 2024 - SullyGnome(3).csv" print("url! -> ",url) match = re.search(r"\((.*?)\)", url) if match: print("yup!") extracted_text = match.group(1).lower() print("extracted: /",extracted_text) return False ## return extracted_text == target_string.lower() else: print("nope!") return False def check_download_exists_matching_url_version_two32(url): print ("enter > downloads > exist check > version 2") match = re.search(r"https://sullygnome.com/channel/([^/]+)/(\d+)([a-z]+)/games", url.lower()) if not match: print(f"Invalid URL format. Could not extract channel name, year, or month.") return channel_name, year, month = match.groups() print("channel / ",channel_name) print("year / ",year) print("month / ",month) file_pattern = f"^[^ ]* \({channel_name}\) - game stats on Twitch in {month} {year} - SullyGnome.csv".lower() print("regex :",file_pattern) for filename in os.listdir("/home/yankee/Downloads/"): updated = filename.lower() print("found file (v2) / ",updated) if fnmatch.fnmatch(updated, file_pattern): print(f"found match / {updated}") return True else: print(f"No matching CSV file found for channel '{channel_name}' in year '{year}' and month '{month}'. (version t55555wo)") return False