Skip to content

Commit 5510bea

Browse files
authored
gui: add a switch to disable standby (#1028)
1 parent a661a12 commit 5510bea

9 files changed

Lines changed: 66 additions & 9 deletions

File tree

feeluown/app/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def create_config() -> Config:
119119
"PROVIDERS_STANDBY",
120120
type_=list,
121121
default=None,
122-
desc="",
122+
desc=t("providers-standby-desc"),
123123
)
124124

125125
# YTDL related fields are deprecated since v4.1.9. Disable them by default.

feeluown/gui/widgets/settings.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
QHBoxLayout,
88
QPlainTextEdit,
99
QPushButton,
10+
QLineEdit,
11+
QLabel,
1012
)
1113

1214
from feeluown.i18n import t
@@ -67,10 +69,47 @@ def __init__(self, app, *args, **kwargs):
6769
self._app = app
6870
self.lyric_btn = LyricButton(app, height=16)
6971
self.watch_btn = WatchButton(app, height=16)
70-
self._layout = QHBoxLayout(self)
71-
self._layout.addWidget(self.lyric_btn)
72-
self._layout.addWidget(self.watch_btn)
73-
self._layout.addStretch(0)
72+
73+
btn_layout = QHBoxLayout()
74+
btn_layout.addWidget(self.lyric_btn)
75+
btn_layout.addWidget(self.watch_btn)
76+
btn_layout.addStretch(0)
77+
78+
standby_label = QLabel(t("standby-providers-label"))
79+
self.standby_edit = QLineEdit(self)
80+
self.standby_edit.setPlaceholderText(t("standby-providers-placeholder"))
81+
self._refresh_standby_edit()
82+
self.standby_edit.editingFinished.connect(self._on_standby_editing_finished)
83+
84+
standby_layout = QHBoxLayout()
85+
standby_layout.addWidget(standby_label)
86+
standby_layout.addWidget(self.standby_edit)
87+
88+
self._layout = QVBoxLayout(self)
89+
self._layout.addLayout(btn_layout)
90+
self._layout.addLayout(standby_layout)
91+
self._layout.setSpacing(5)
92+
self._layout.setContentsMargins(0, 0, 0, 0)
93+
94+
def _refresh_standby_edit(self):
95+
val = self._app.config.PROVIDERS_STANDBY
96+
if val is None:
97+
self.standby_edit.setText("*")
98+
else:
99+
self.standby_edit.setText(",".join(val))
100+
101+
def _on_standby_editing_finished(self):
102+
text = self.standby_edit.text().strip()
103+
if not text:
104+
self._app.config.PROVIDERS_STANDBY = []
105+
self._app.library.set_providers_standby([])
106+
elif text == "*":
107+
self._app.config.PROVIDERS_STANDBY = None
108+
self._app.library.set_providers_standby(None)
109+
else:
110+
providers = [p.strip() for p in text.split(",") if p.strip()]
111+
self._app.config.PROVIDERS_STANDBY = providers
112+
self._app.library.set_providers_standby(providers)
74113

75114

76115
class NetworkSettings(QWidget):

feeluown/i18n/assets/en-US/app.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ lyric-button = LRC
136136
watch-mode-tooltip =
137137
When watch mode is enabled, the player will first try to find a suitable { video } to play for the { -track }.
138138
Best practice: when enabling watch, it’s recommended to also enable the { picture-in-picture } mode of the { video }.
139+
standby-providers-label = Standby providers:
140+
standby-providers-placeholder = * or netease,qqmusic (empty = disable)
139141
local-liked-tracks = the Local favorites
140142
local-liked-tracks-add = Add to { local-liked-tracks }
141143
local-liked-tracks-remove = Remove from { local-liked-tracks }

feeluown/i18n/assets/en-US/config.ftl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ openai-api-baseurl-desc = OpenAI API base URL
2525
openai-api-key-desc = OpenAI API key
2626
openai-model-desc = OpenAI model name
2727
ai-radio-prompt-desc = Prompt template for AI radio feature
28-
enable-replace-playlist-on-dblclick-desc = On double-clicking a { -track }, replace the current { playlist } with the { -track }’s source
28+
enable-replace-playlist-on-dblclick-desc = On double-clicking a { -track }, replace the current { playlist } with the { -track }’s source
29+
providers-standby-desc = Standby provider list (empty list disables fallback)

feeluown/i18n/assets/ja-JP/app.ftl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ lyric-button = 歌詞
123123
watch-mode-tooltip =
124124
ウォッチモードを有効にすると、プレイヤーはまず { -track } に合う { video } を探します。
125125
ベストプラクティス:ウォッチと同時に { video }{ picture-in-picture } モードもオンにしましょう。
126-
126+
standby-providers-label = 代替ソース:
127+
standby-providers-placeholder = * または netease,qqmusic(空 = 無効)
127128
local-liked-tracks = “ローカルお気に入り”
128129
local-liked-tracks-add = { local-liked-tracks } に追加
129130
local-liked-tracks-remove = { local-liked-tracks } から削除

feeluown/i18n/assets/ja-JP/config.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ openai-api-key-desc = OpenAI APIキー
2626
openai-model-desc = OpenAIモデル名
2727
ai-radio-prompt-desc = AI ラジオ機能のプロンプト
2828
enable-replace-playlist-on-dblclick-desc = { -track }をダブルクリックしたときに、{ -track }が属するリストで現在の{ playlist }を置き換える
29+
providers-standby-desc = 代替曲提供元リスト(空リストはフォールバックを無効化)

feeluown/i18n/assets/zh-CN/app.ftl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ lyric-button = 词
123123
watch-mode-tooltip =
124124
开启 watch 模式时,播放器会优先尝试为{ -track }找一个合适的{ video }来播放。
125125
最佳实践:开启 watch 的同时建议开启{ video }{ picture-in-picture }模式。
126-
126+
standby-providers-label = 备选来源:
127+
standby-providers-placeholder = * 或 netease,qqmusic(空 = 禁用)
127128
local-liked-tracks = “本地收藏”
128129
local-liked-tracks-add = 添加到{ local-liked-tracks }
129130
local-liked-tracks-remove = { local-liked-tracks }中移除

feeluown/i18n/assets/zh-CN/config.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ openai-api-key-desc = OpenAI API 密钥
2626
openai-model-desc = OpenAI 模型名称
2727
ai-radio-prompt-desc = AI 电台功能的提示词
2828
enable-replace-playlist-on-dblclick-desc = 双击{ -track }时,用{ -track }所在列表替换当前{ playlist }
29+
providers-standby-desc = 备选歌曲来源列表(空列表表示禁用 fallback)

feeluown/library/library.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ def __init__(self, providers_standby=None, enable_ai_standby_matcher=True):
104104
# TODO: implement this feature
105105
self.enable_ai_standby_matcher = enable_ai_standby_matcher
106106

107+
def set_providers_standby(self, providers_standby):
108+
"""Set the standby provider list at runtime.
109+
110+
:param providers_standby: ``None`` means all providers,
111+
``[]`` means disabled, and a list means specific providers.
112+
"""
113+
self._providers_standby = providers_standby
114+
107115
def setup_ytdl(self, *args, **kwargs):
108116
from .ytdl import Ytdl
109117

@@ -356,7 +364,10 @@ async def a_list_song_standby_v2(
356364
.. versionadded:: 3.7.8
357365
"""
358366
if source_in is None:
359-
pvd_ids = self._providers_standby or [pvd.identifier for pvd in self.list()]
367+
if self._providers_standby is None:
368+
pvd_ids = [pvd.identifier for pvd in self.list()]
369+
else:
370+
pvd_ids = self._providers_standby
360371
else:
361372
pvd_ids = [pvd.identifier for pvd in self._filter(identifier_in=source_in)]
362373
if score_fn is None:

0 commit comments

Comments
 (0)