1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 08:56:17 +00:00

Apply changes

This commit is contained in:
vithyze 2023-03-05 12:06:51 +00:00
parent 8e2adf8fc8
commit b662162ca7
3 changed files with 33 additions and 27 deletions

View File

@ -40,6 +40,9 @@ log_level = WARNING
; Default: El La Le Las Les Los The ; Default: El La Le Las Les Los The
index_ignored_prefixes = El La Le Las Les Los The index_ignored_prefixes = El La Le Las Les Los The
; Enable the ChartLyrics API. Default: off
online_lyrics = off
[daemon] [daemon]
; Socket file the daemon will listen on for incoming management commands ; Socket file the daemon will listen on for incoming management commands
; Default: /tmp/supysonic/supysonic.sock ; Default: /tmp/supysonic/supysonic.sock

View File

@ -443,13 +443,15 @@ def lyrics():
return lyrics_response_for_track(track, lyrics) return lyrics_response_for_track(track, lyrics)
lyrics = {}
if current_app.config["WEBAPP"]["online_lyrics"]:
# Create a stable, unique, filesystem-compatible identifier for the artist+title # Create a stable, unique, filesystem-compatible identifier for the artist+title
unique = hashlib.md5( unique = hashlib.md5(
json.dumps([x.lower() for x in (artist, title)]).encode("utf-8") json.dumps([x.lower() for x in (artist, title)]).encode("utf-8")
).hexdigest() ).hexdigest()
cache_key = f"lyrics-{unique}" cache_key = f"lyrics-{unique}"
lyrics = {}
try: try:
lyrics = json.loads( lyrics = json.loads(
zlib.decompress(current_app.cache.get_value(cache_key)).decode("utf-8") zlib.decompress(current_app.cache.get_value(cache_key)).decode("utf-8")

View File

@ -37,6 +37,7 @@ class DefaultConfig:
"mount_webui": True, "mount_webui": True,
"mount_api": True, "mount_api": True,
"index_ignored_prefixes": "El La Le Las Les Los The", "index_ignored_prefixes": "El La Le Las Les Los The",
"online_lyrics": False,
} }
DAEMON = { DAEMON = {
"socket": r"\\.\pipe\supysonic" "socket": r"\\.\pipe\supysonic"