From 27df94e578640d31768dd356c8ff046e89d10297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alban=20F=C3=A9ron?= Date: Sat, 18 Mar 2023 16:04:00 +0100 Subject: [PATCH] Setting to enable or disable ChartLyrics Will be disabled by default (cherry picked from commit b662162ca76874131e2ada469534eb69a834e4f6) --- config.sample | 3 +++ docs/setup/configuration.rst | 8 ++++++++ supysonic/api/media.py | 3 +++ supysonic/config.py | 1 + tests/net/test_lyrics.py | 2 ++ 5 files changed, 17 insertions(+) diff --git a/config.sample b/config.sample index b6f57ef..3daeddf 100644 --- a/config.sample +++ b/config.sample @@ -43,6 +43,9 @@ log_rotate = yes ; Default: 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] ; Socket file the daemon will listen on for incoming management commands ; Default: /tmp/supysonic/supysonic.sock diff --git a/docs/setup/configuration.rst b/docs/setup/configuration.rst index e4c22c0..01463bf 100644 --- a/docs/setup/configuration.rst +++ b/docs/setup/configuration.rst @@ -147,6 +147,11 @@ Configuration relative to the HTTP server. case insensitive. 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:: [webapp] @@ -180,6 +185,9 @@ Sample configuration:: ; Default: 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: ``[daemon]`` section diff --git a/supysonic/api/media.py b/supysonic/api/media.py index a5d3f0f..6864880 100644 --- a/supysonic/api/media.py +++ b/supysonic/api/media.py @@ -443,6 +443,9 @@ def 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 unique = hashlib.md5( json.dumps([x.lower() for x in (artist, title)]).encode("utf-8") diff --git a/supysonic/config.py b/supysonic/config.py index f9e126c..bff29c8 100644 --- a/supysonic/config.py +++ b/supysonic/config.py @@ -38,6 +38,7 @@ class DefaultConfig: "mount_webui": True, "mount_api": True, "index_ignored_prefixes": "El La Le Las Les Los The", + "online_lyrics": False, } DAEMON = { "socket": r"\\.\pipe\supysonic" diff --git a/tests/net/test_lyrics.py b/tests/net/test_lyrics.py index 18057d9..81c787d 100644 --- a/tests/net/test_lyrics.py +++ b/tests/net/test_lyrics.py @@ -19,6 +19,8 @@ class LyricsTestCase(ApiTestBase): def setUp(self): super().setUp() + self.config.WEBAPP["online_lyrics"] = True + folder = Folder.create( name="Root", path=os.path.abspath("tests/assets/lyrics"),