serious progress
This commit is contained in:
87
DiskUtils.py
87
DiskUtils.py
@@ -49,30 +49,8 @@ def check_download_exists_matching_url_version_one(url):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def check_download_exists_matching_url_version_two(url):
|
def check_download_exists_matching_url_version_two(url):
|
||||||
|
|
||||||
url="たいじ_たいちゃんねる (yaritaiji) - game stats on Twitch in October 2024 - SullyGnome(3).csv"
|
|
||||||
|
|
||||||
print("url! -> ",url)
|
print ("enter > check_download_exists_matching_url_version_two")
|
||||||
|
|
||||||
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())
|
match = re.search(r"https://sullygnome.com/channel/([^/]+)/(\d+)([a-z]+)/games", url.lower())
|
||||||
|
|
||||||
@@ -90,24 +68,69 @@ def check_download_exists_matching_url_version_two32(url):
|
|||||||
|
|
||||||
print("month / ",month)
|
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/"):
|
for filename in os.listdir("/home/yankee/Downloads/"):
|
||||||
|
|
||||||
updated = filename.lower()
|
updated = filename.lower()
|
||||||
|
|
||||||
print("found file (v2) / ",updated)
|
print("found file (v2) / ",updated)
|
||||||
|
|
||||||
if fnmatch.fnmatch(updated, file_pattern):
|
##
|
||||||
|
|
||||||
print(f"found match / {updated}")
|
hasKeyDateParts = does_filename_contain_key_date_parts(updated, month, year)
|
||||||
|
|
||||||
return True
|
print("\thasKeyDateParts / ",hasKeyDateParts)
|
||||||
|
|
||||||
else:
|
##
|
||||||
|
|
||||||
print(f"No matching CSV file found for channel '{channel_name}' in year '{year}' and month '{month}'. (version t55555wo)")
|
hasTargetChannelName = does_filename_contain_target_channel_name(updated,channel_name)
|
||||||
|
|
||||||
|
print("\thasTargetChannelName / ",hasTargetChannelName)
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
print ("exit < check_download_exists_matching_url_version_two")
|
||||||
|
|
||||||
|
def does_filename_contain_target_channel_name(url,channel):
|
||||||
|
|
||||||
|
regex = rf"\({re.escape(channel)}\)"
|
||||||
|
|
||||||
|
match = re.search(regex, url)
|
||||||
|
|
||||||
|
results = bool(match)
|
||||||
|
|
||||||
|
print("results / ",results)
|
||||||
|
|
||||||
|
|
||||||
|
match = re.search("\({channel}\)", url)
|
||||||
|
|
||||||
|
if match:
|
||||||
|
print("yup!")
|
||||||
|
extracted_text = match.group(1).lower()
|
||||||
|
|
||||||
|
print("extracted: /",extracted_text)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
## return extracted_text == target_string.lower()
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("nope!")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def does_filename_contain_key_date_parts(filename, monthString, yearNumber):
|
||||||
|
|
||||||
|
print("enter -> does_filename_contain_key_date_parts()")
|
||||||
|
|
||||||
|
regex = rf"{re.escape(monthString)} {yearNumber}"
|
||||||
|
|
||||||
|
doesContain = bool(re.search(regex, filename, re.IGNORECASE))
|
||||||
|
|
||||||
|
print("doesContain / ",doesContain)
|
||||||
|
|
||||||
|
return doesContain
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user