Files
yankee-gnome-fire-consumer/DiskUtils.py

70 lines
1.7 KiB
Python
Raw Permalink Normal View History

2025-02-06 22:21:31 -05:00
import os
import time
import re
import fnmatch
def dowork():
################################################################################################
url = "https://sullygnome.com/channel/kaicenat/2023january/streams"
print("checking disk for the stuff...")
print("url", url)
fileExists = check_download_exists_matching_url(url)
print("file already exists / ",fileExists)
################################################################################################
def check_download_exists_matching_url(url):
print ("hello?")
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()
2025-02-09 20:13:48 -05:00
for filename in os.listdir("/root/Downloads/"):
2025-02-06 22:21:31 -05:00
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}'.")
return False
def shutDownRobot():
print("shutting down the robot now")