Skip to content

Commit

Permalink
Fix sometimes failing to skip pure music
Browse files Browse the repository at this point in the history
  • Loading branch information
chenmozhijin committed Mar 9, 2024
1 parent 956cf39 commit b1f8639
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ui/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<item>
<widget class="QCheckBox" name="skip_inst_lyrics_checkBox">
<property name="text">
<string>保存专辑/歌单歌词时跳过纯音乐</string>
<string>保存专辑/歌单歌词/本地匹配时跳过纯音乐</string>
</property>
</widget>
</item>
Expand Down
13 changes: 3 additions & 10 deletions ui/settings_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (
QCoreApplication,
QMetaObject,
QSize,
Qt,
)
from PySide6.QtGui import (
QFont,
)
from PySide6.QtCore import QCoreApplication, QMetaObject, QSize, Qt
from PySide6.QtGui import QFont
from PySide6.QtWidgets import (
QAbstractItemView,
QCheckBox,
Expand Down Expand Up @@ -279,7 +272,7 @@ def retranslateUi(self, settings):
___qlistwidgetitem2.setText(QCoreApplication.translate("settings", u"\u8bd1\u6587", None));
self.lyrics_order_listWidget.setSortingEnabled(__sortingEnabled)

self.skip_inst_lyrics_checkBox.setText(QCoreApplication.translate("settings", u"\u4fdd\u5b58\u4e13\u8f91/\u6b4c\u5355\u6b4c\u8bcd\u65f6\u8df3\u8fc7\u7eaf\u97f3\u4e50", None))
self.skip_inst_lyrics_checkBox.setText(QCoreApplication.translate("settings", u"\u4fdd\u5b58\u4e13\u8f91/\u6b4c\u5355\u6b4c\u8bcd/\u672c\u5730\u5339\u914d\u65f6\u8df3\u8fc7\u7eaf\u97f3\u4e50", None))
self.get_normal_lyrics_checkBox.setText(QCoreApplication.translate("settings", u"\u6ca1\u6709\u53ef\u7528\u7684\u52a0\u5bc6\u6b4c\u8bcd\u65f6\u5c1d\u8bd5\u83b7\u53d6\u666e\u901a\u6b4c\u8bcd", None))
self.auto_select_checkBox.setText(QCoreApplication.translate("settings", u"\u6b4c\u66f2\u641c\u7d22\u6b4c\u8bcd\u65f6\u81ea\u52a8\u9009\u62e9(\u9177\u72d7\u97f3\u4e50)", None))
self.groupBox.setTitle(QCoreApplication.translate("settings", u"\u4fdd\u5b58\u8bbe\u7f6e", None))
Expand Down
14 changes: 8 additions & 6 deletions utils/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,14 @@ def search_and_get(self, info: dict) -> list:
scores = sorted(scores, key=lambda x: x[1], reverse=True)
if len(scores) == 0:
return None, None
if (self.skip_inst_lyrics and
scores[0][0]['source'] == Source.KG and
if (self.skip_inst_lyrics and scores[0][0]['source'] == Source.KG and
scores[0][0]['language'] in ["纯音乐", '伴奏']):
if 'artist' in info:
msg = f"[{self.current_index}/{self.total_index}]本地: {info['artist']} - {info['title']} 搜索结果:{scores[0][0]['artist']} - {scores[0][0]['title']} 跳过纯音乐"
msg = (f"[{self.current_index}/{self.total_index}]本地: {info['artist']} - {info['title']} "
f"搜索结果:{scores[0][0]['artist']} - {scores[0][0]['title']} 跳过纯音乐")
else:
msg = f"[{self.current_index}/{self.total_index}]本地: {info['title']} 搜索结果:{scores[0][0]['artist']} - {scores[0][0]['title']} 跳过纯音乐"
msg = (f"[{self.current_index}/{self.total_index}]本地: {info['title']} "
f"搜索结果:{scores[0][0]['artist']} - {scores[0][0]['title']} 跳过纯音乐")
self.signals.massage.emit(msg)
return None, None

Expand Down Expand Up @@ -518,10 +519,11 @@ def search_and_get(self, info: dict) -> list:
lyric, from_cache = self.LyricProcessingWorker.get_lyrics(song_info)
if lyric is not None:
obtained_sources.append(song_info['source'])
logging.debug(f"lyric['orig']:{lyric['orig']}")
if (self.skip_inst_lyrics and len(lyric["orig"]) != 0 and
(lyric["orig"][0][2][0][2] == "此歌曲为没有填词的纯音乐,请您欣赏" or
lyric["orig"][0][2][0][2] == "纯音乐,请欣赏")):
lyric["orig"][0][2][0][2] == "纯音乐,请欣赏") or
(song_info['source'] == Source.KG and
song_info['language'] in ["纯音乐", '伴奏'])):
inst = True
inst_score = score
continue
Expand Down

0 comments on commit b1f8639

Please sign in to comment.