new
This commit is contained in:
parent
be789cb732
commit
c23eb924c3
85 changed files with 7090 additions and 253 deletions
26
utils.py
26
utils.py
|
|
@ -1,14 +1,22 @@
|
|||
import re, hashlib
|
||||
# utils.py
|
||||
import hashlib
|
||||
import re
|
||||
|
||||
def clean_artist_name(text):
|
||||
return re.sub(r'[⭐🤖🎭\u2B50\uFE0F]', '', text).strip()
|
||||
|
||||
def force_star_flag(starred=True):
|
||||
def clean_artist_name(text: str) -> str:
|
||||
return re.sub(r"[⭐🤖🎭\u2B50\uFE0F]", "", text).strip()
|
||||
|
||||
|
||||
def force_star_flag(starred: bool = True) -> str:
|
||||
return "Yes" if starred else "No"
|
||||
|
||||
def hash_file(filename):
|
||||
|
||||
def hash_file(filename: str, block_size: int = 65536) -> str:
|
||||
hasher = hashlib.sha256()
|
||||
with open(filename, "rb") as f:
|
||||
buf = f.read()
|
||||
hasher.update(buf)
|
||||
return hasher.hexdigest()
|
||||
try:
|
||||
with open(filename, "rb") as f:
|
||||
for block in iter(lambda: f.read(block_size), b""):
|
||||
hasher.update(block)
|
||||
except FileNotFoundError:
|
||||
return "file_not_found"
|
||||
return hasher.hexdigest()
|
||||
Loading…
Add table
Add a link
Reference in a new issue