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

Setting to enable or disable ChartLyrics

Will be disabled by default
(cherry picked from commit b662162ca7)
This commit is contained in:
Alban Féron 2023-03-18 16:04:00 +01:00
parent 03ac57ca26
commit 27df94e578
No known key found for this signature in database
GPG Key ID: 8CE0313646D16165
5 changed files with 17 additions and 0 deletions

View File

@ -43,6 +43,9 @@ log_rotate = yes
; 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

@ -147,6 +147,11 @@ Configuration relative to the HTTP server.
case insensitive. case insensitive.
Defaults to ``El La Le Las Les Los The``. Defaults to ``El La Le Las Les Los The``.
``online_lyrics``
If enabled, will fetch the lyrics (when requested) from ChartLyrics if they
aren't available locally (either from metadata or from text files).
Defaults to ``no``.
Sample configuration:: Sample configuration::
[webapp] [webapp]
@ -180,6 +185,9 @@ Sample configuration::
; 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
.. _conf-daemon: .. _conf-daemon:
``[daemon]`` section ``[daemon]`` section

View File

@ -443,6 +443,9 @@ def lyrics():
return lyrics_response_for_track(track, lyrics) return lyrics_response_for_track(track, lyrics)
if not current_app.config["WEBAPP"]["online_lyrics"]:
return request.formatter("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")

View File

@ -38,6 +38,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"

View File

@ -19,6 +19,8 @@ class LyricsTestCase(ApiTestBase):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.config.WEBAPP["online_lyrics"] = True
folder = Folder.create( folder = Folder.create(
name="Root", name="Root",
path=os.path.abspath("tests/assets/lyrics"), path=os.path.abspath("tests/assets/lyrics"),