Bug fixing

master
MickSlash 2022-12-15 16:55:38 +00:00
parent 7c73ddaed7
commit f08875a9f0
1 changed files with 21 additions and 17 deletions

View File

@ -37,8 +37,7 @@ def replaceString(string):
def removeYearString(string):
pattern = r"\d{4}"
str_data = re.sub(pattern, "", string)
return str_data
return re.sub(pattern, "", string)
def findOneDriveLinks(str):
@ -46,25 +45,21 @@ def findOneDriveLinks(str):
str = removeYearString(str)
match_str = re.findall(
r"([a-zA-Z0-9]+)", str
) # In caso la stringa manipolata non dovesse dare risultati sul DB, viene suddiva in gruppi e testati fino a trovare un match
)
if len(match_str)>0:
title = separateUpperString(match_str[0])
del(match_str[0])
match_str = title + match_str
new_string = ""
for x in match_str:
new_string += x + " "
new_string = new_string.rstrip()
return new_string
new_string = "".join(f"{x} " for x in match_str)
return new_string.rstrip()
else:
print(match_str)
def separateUpperString(str):
title = re.findall('[a-zA-Z][^A-Z]*', str)
return title
return re.findall('[a-zA-Z][^A-Z]*', str)
def apiOneDrive(folderType=None,nameFile=None):
def apiOneDrive(folderType=None,nameFile=None,epstyle=True):
apiURL = f"{LC_URL}{folderType}"
rawURL = f"{LC_FILEURL}{folderType}"
counter = 1
@ -78,18 +73,23 @@ def apiOneDrive(folderType=None,nameFile=None):
r = session.get(f"{apiURL}&next={nextLink}").json()
data.extend(r["folder"]["value"])
fileCount = len(data)
fileFinderDB(nameFile, rawURL, data, counter)
print(f"Trovati {fileCount} file in totale!")
fileFinderDB(nameFile, rawURL, data, counter,epstyle)
print(f"Modifica provata su {fileCount} file in totale!")
mydb.close()
else:
print(r.status_code)
print(r.content)
def fileFinderDB(nameFile, rawURL, data, counter):
def fileFinderDB(nameFile, rawURL, data, counter,epstyle):
for file in data:
mp4File = file["name"]
if nameFile:
if counter<10:
if counter<10 and epstyle:
fileName = f"{nameFile}E0{counter}"
elif counter < 10:
fileName = f"{nameFile} Ep 0{counter}"
elif counter>10 and epstyle:
fileName = f"{nameFile}E{counter}"
else:
fileName = f"{nameFile} Ep {counter}"
else:
@ -101,3 +101,7 @@ def fileFinderDB(nameFile, rawURL, data, counter):
def writeToText(text):
with open('link_modificati.txt', 'a', encoding='utf-8') as f:
f.write(f"{text}\n")
if __name__ == "__main__":
apiOneDrive("MLIF/") # Esempio