From 9b031c9ac394637a4a1d122f1a9a05c3484e964e Mon Sep 17 00:00:00 2001 From: MickSlash Date: Sat, 17 Dec 2022 10:11:15 +0000 Subject: [PATCH] #Added Emoji plus some minors bugfix --- onedriveLinks.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/onedriveLinks.py b/onedriveLinks.py index c5c1c07..fbca5d8 100644 --- a/onedriveLinks.py +++ b/onedriveLinks.py @@ -2,6 +2,7 @@ import re from functools import reduce import mysql.connector import requests +import emoji LC_URL = "https://onedrive-vercel-index-3lgqsp5f2-tartamafajak22.vercel.app/api/?path=/" LC_FILEURL = "https://onedrive-vercel-index-3lgqsp5f2-tartamafajak22.vercel.app/api/raw/?path=/" @@ -9,10 +10,10 @@ session = requests.Session() # CONNESSIONE AL DB mydb = mysql.connector.connect( - host="localhost", - user="root", - password="Lost66tmv", - database="lordb" + host="lordns.ddns.net", + user="onedrivelink", + password="Dinosauroincatenato98", + database="lordb_backup" ) def DBSearchAndUpdate(link,value): @@ -20,7 +21,12 @@ def DBSearchAndUpdate(link,value): sql = "UPDATE tbl_episode SET `link embedded` = %s WHERE `titolo` LIKE %s LIMIT 1" val = (f'{link}',f'%{value}%') mycursor.execute(sql,val) - print(f"{mycursor.rowcount} - {value} - {link}") + emojitype = "" + if mycursor.rowcount == 1: + emojitype = emoji.emojize(":check_mark_button:") + else: + emojitype = emoji.emojize(":cross_mark:") + print(f"{emojitype} - {value} - {link}\n") if mycursor.rowcount == 1: text = f"Modificato : {value}" writeToText(text) @@ -31,7 +37,7 @@ def DBSearchAndUpdate(link,value): def replaceString(string): - repls = (".", " "), ("mp4", ""), ("_", " "),("SUB"," "),("ITA"," "),("XX","xx") + repls = (".", " "), ("mp4", ""), ("_", " "),("SUB"," "),("ITA"," "),("XX","xx"),("Full HD","") return reduce(lambda a, kv: a.replace(*kv), repls, string) @@ -88,7 +94,7 @@ def fileFinderDB(nameFile, rawURL, data, counter,epstyle): fileName = f"{nameFile}E0{counter}" elif counter < 10: fileName = f"{nameFile} Ep 0{counter}" - elif counter>10 and epstyle: + elif counter>=10 and epstyle: fileName = f"{nameFile}E{counter}" else: fileName = f"{nameFile} Ep {counter}" @@ -99,7 +105,7 @@ def fileFinderDB(nameFile, rawURL, data, counter,epstyle): DBSearchAndUpdate(link,fileName) def writeToText(text): - with open('link_modificati.txt', 'a', encoding='utf-8') as f: + with open('link_modificati.txt', 'a', encoding='utf-8', errors="ignore") as f: f.write(f"{text}\n")