mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 03:05:35 +00:00
fix issue with Ed Sheeran albums
This commit is contained in:
parent
a629f12e39
commit
50ebead026
@ -1,5 +1,4 @@
|
||||
import hashlib
|
||||
import re
|
||||
|
||||
from unidecode import unidecode
|
||||
|
||||
@ -8,26 +7,21 @@ def create_hash(*args: str, decode=False, limit=10) -> str:
|
||||
"""
|
||||
Creates a simple hash for an album
|
||||
"""
|
||||
str_ = "".join(args)
|
||||
|
||||
def remove_non_alnum(token: str) -> str:
|
||||
token = token.lower().strip().replace(" ", "")
|
||||
t = "".join(t for t in token if t.isalnum())
|
||||
|
||||
if t == "":
|
||||
return token
|
||||
|
||||
return t
|
||||
|
||||
str_ = "".join(remove_non_alnum(t) for t in args)
|
||||
|
||||
if decode:
|
||||
str_ = unidecode(str_)
|
||||
|
||||
str_ = str_.lower().strip().replace(" ", "")
|
||||
str_ = "".join(t for t in str_ if t.isalnum())
|
||||
str_ = re.sub(r"[^a-zA-Z0-9\s]", "", str_)
|
||||
str_ = str_.encode("utf-8")
|
||||
str_ = hashlib.sha256(str_).hexdigest()
|
||||
return str_[-limit:]
|
||||
|
||||
|
||||
def create_folder_hash(*args: str, limit=10) -> str:
|
||||
"""
|
||||
Creates a simple hash for an album
|
||||
"""
|
||||
strings = [s.lower().strip().replace(" ", "") for s in args]
|
||||
|
||||
strings = ["".join([t for t in s if t.isalnum()]) for s in strings]
|
||||
strings = [s.encode("utf-8") for s in strings]
|
||||
strings = [hashlib.sha256(s).hexdigest()[-limit:] for s in strings]
|
||||
return "".join(strings)
|
||||
|
@ -78,7 +78,7 @@ def start_watchdog():
|
||||
WatchDog().run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def run_swingmusic():
|
||||
HandleArgs()
|
||||
log_startup_info()
|
||||
bg_run_setup()
|
||||
@ -88,6 +88,9 @@ if __name__ == "__main__":
|
||||
f"swingmusic - {FLASKVARS.FLASK_HOST}:{FLASKVARS.FLASK_PORT}"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_swingmusic()
|
||||
app.run(
|
||||
debug=False,
|
||||
threaded=True,
|
||||
|
Loading…
x
Reference in New Issue
Block a user