From 60646ce8eff73b47894bcfd4de8c864585634692 Mon Sep 17 00:00:00 2001 From: zlk-sys <18079031125@163.com> Date: Mon, 1 Jul 2024 18:31:24 +0800 Subject: [PATCH] Ver.2.6.103 --- .idea/.gitignore | 3 -- Interface/playlist.py | 10 +++-- Interface/plugin.py | 13 ++---- Interface/searchmusic.py | 59 +++++++++++---------------- README.md | 4 +- helper/SettingHelper.py | 5 +-- helper/downloadHelper.py | 11 +++-- helper/flyoutmsg.py | 18 +++++---- helper/getvalue.py | 80 +++++++++++++++++++------------------ helper/inital.py | 64 +++++++++++++++++------------ helper/localmusicsHelper.py | 11 ++--- helper/playlistHelper.py | 9 +++-- helper/pluginHelper.py | 34 +++++++++++----- helper/searchmusicHelper.py | 23 +++++++---- resource/hitokoto.json | 1 - window/main.py | 21 +++++----- 16 files changed, 193 insertions(+), 173 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 resource/hitokoto.json diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 359bb53..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml diff --git a/Interface/playlist.py b/Interface/playlist.py index 58f48b1..6aba314 100644 --- a/Interface/playlist.py +++ b/Interface/playlist.py @@ -1,11 +1,13 @@ -from PyQt5.QtWidgets import QWidget, QAbstractItemView, QStyleOptionViewItem, QHBoxLayout, QVBoxLayout, QLabel, QHeaderView -from qfluentwidgets import ComboBox, LineEdit, PushButton, SubtitleLabel, TableWidget, ProgressBar, PrimaryPushButton, MessageBoxBase, ProgressRing -from PyQt5 import QtCore from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QWidget, QAbstractItemView, QHBoxLayout, QVBoxLayout, QHeaderView +from qfluentwidgets import ComboBox, LineEdit, PushButton, SubtitleLabel, TableWidget, ProgressBar, PrimaryPushButton, \ + MessageBoxBase from qfluentwidgets import FluentIcon as FIF + from helper.downloadHelper import downloading, download -from helper.playlistHelper import getlist, FindLists, searchstart, music, search, rundownload from helper.flyoutmsg import setOK +from helper.playlistHelper import getlist, FindLists, searchstart, music, search, rundownload + class playlist(QWidget): def __init__(self): diff --git a/Interface/plugin.py b/Interface/plugin.py index ecc960a..1731976 100644 --- a/Interface/plugin.py +++ b/Interface/plugin.py @@ -2,18 +2,11 @@ import os import sys from helper.inital import setSettingsQss -from PyQt5.QtCore import Qt, QPoint, QSize, QUrl, QRect, QStandardPaths -from PyQt5.QtGui import QIcon, QFont, QColor, QPainter -from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QVBoxLayout, QSizePolicy +from PyQt5.QtCore import Qt, QStandardPaths +from PyQt5.QtWidgets import QWidget from helper.config import cfg -from qfluentwidgets import (SettingCardGroup, SwitchSettingCard, CustomColorSettingCard, - OptionsSettingCard, FolderListSettingCard, PushSettingCard, setTheme, isDarkTheme, - HyperlinkCard, PrimaryPushSettingCard, ScrollArea, PushButton, PrimaryPushButton, - ComboBoxSettingCard, ExpandLayout, Theme, InfoBar, FlyoutView, Flyout) -from qfluentwidgets import FluentIcon as FIF -from qfluentwidgets.components.widgets.acrylic_label import AcrylicBrush +from qfluentwidgets import SettingCardGroup, FolderListSettingCard, ScrollArea, ExpandLayout from helper.pluginHelper import run_plugins_plugin -import window.main class plugins(ScrollArea): diff --git a/Interface/searchmusic.py b/Interface/searchmusic.py index 004c95e..d0f6efb 100644 --- a/Interface/searchmusic.py +++ b/Interface/searchmusic.py @@ -11,24 +11,6 @@ from helper.downloadHelper import downloading, download from helper.searchmusicHelper import getlist, sethotlineEdit, search, searchstart, rundownload -# class Worker(QObject): -# finished = pyqtSignal() -# -# @pyqtSlot() -# def do_work(self, text): -# if helper.config.Config.twitcard.value == True and is_english_and_characters(text): -# try: -# self.key = AZMusicAPI.searchkey(text)mn -# except: -# self.key = [] -# return 0 -# if "Error" in self.key: -# self.key = [] -# return 0 -# else: -# self.key = [] -# -# self.finished.emit() class CustomTableItemDelegate(TableItemDelegate): """ Custom table item delegate """ @@ -45,6 +27,7 @@ def initStyleOption(self, option: QStyleOptionViewItem, index: QModelIndex): option.palette.setColor(QPalette.Text, Qt.red) option.palette.setColor(QPalette.HighlightedText, Qt.red) + class searchmusic(QWidget, QObject): def __init__(self): @@ -58,11 +41,13 @@ def __init__(self): self.lineEdit = SearchLineEdit(self) self.lineEdit.setPlaceholderText('搜索音乐') self.lineEdit.setFixedSize(200, 33) - + # self.lineEdit.textEdited.connect(self.keys) - self.lineEdit.returnPressed.connect(lambda: searchstart(lineEdit=self.lineEdit, parent=self, spinBox=self.spinBox, lworker=self.lworker)) - self.lineEdit.searchButton.released.connect(lambda: searchstart(lineEdit=self.lineEdit, parent=self, spinBox=self.spinBox, lworker=self.lworker)) - + self.lineEdit.returnPressed.connect( + lambda: searchstart(lineEdit=self.lineEdit, parent=self, spinBox=self.spinBox, lworker=self.lworker)) + self.lineEdit.searchButton.released.connect( + lambda: searchstart(lineEdit=self.lineEdit, parent=self, spinBox=self.spinBox, lworker=self.lworker)) + self.numLabel = QLabel('显示数量', self) self.spinBox = SpinBox(self) self.spinBox.setValue(15) @@ -70,27 +55,31 @@ def __init__(self): # self.worker_thread = QThread() # self.worker = Worker() # self.worker.moveToThread(self.worker_thread) - + self.lworker = getlist() - self.dworker = downloading(howto="search") + self.dworker = downloading(howto="search") self.upworker = get_update() self.lworker.finished.connect(lambda: search(lworker=self.lworker, parent=self, - tableView=self.tableView, spinBox=self.spinBox)) - self.dworker.finished.connect(lambda Progress: download(progress = Progress, table = self.tableView, progressbar=self.ProgressBar, - songdata=self.lworker.songInfos, dworker=self.dworker, button=self.primaryButton1, parent=self.window(), howto = "search")) - self.upworker.finished.connect(lambda updata: showup(parent = self.window(), updata = updata, upworker = self.upworker)) + tableView=self.tableView, spinBox=self.spinBox)) + self.dworker.finished.connect( + lambda Progress: download(progress=Progress, table=self.tableView, progressbar=self.ProgressBar, + songdata=self.lworker.songInfos, dworker=self.dworker, button=self.primaryButton1, + parent=self.window(), howto="search")) + self.upworker.finished.connect( + lambda updata: showup(parent=self.window(), updata=updata, upworker=self.upworker)) # self.worker.finished.connect(self.on_worker_finished) self.primaryButton1 = PrimaryPushButton('下载', self) self.primaryButton1.released.connect(lambda: rundownload(parent=self, primaryButton1=self.primaryButton1, - tableView=self.tableView, dworker=self.dworker, lworker=self.lworker, ProgressBar=self.ProgressBar)) + tableView=self.tableView, dworker=self.dworker, + lworker=self.lworker, ProgressBar=self.ProgressBar)) self.primaryButton1.setEnabled(False) - + self.ProgressBar = ProgressBar(self) self.ProgressBar.setHidden(True) self.ProgressBar.setMaximum(100) self.ProgressBar.setFixedWidth(200) - + self.layout1.addStretch(100) self.layout1.addWidget(self.SearchLabel) self.layout1.addSpacing(10) @@ -131,13 +120,13 @@ def __init__(self): self.hBoxLayout.addWidget(self.tableView) self.hBoxLayout.addSpacing(60) self.hBoxLayout.addLayout(self.layout1) - + self.resize(635, 700) - + sethotlineEdit(lineEdit=self.lineEdit) if helper.config.Config.update_card.value == False: self.upworker.start() - + def openbutton(self): self.primaryButton1.setEnabled(True) @@ -151,4 +140,4 @@ def openbutton(self): # self.completer = QCompleter(self.worker.key, self.lineEdit) # self.completer.setCaseSensitivity(Qt.CaseInsensitive) # self.lineEdit.setCompleter(self.completer) - # self.worker_thread.quit() \ No newline at end of file + # self.worker_thread.quit() diff --git a/README.md b/README.md index 98a16d7..3c131d9 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,6 @@ _✨ 优雅地下载音乐✨_ > 若您需要二次分发本程序,需经过开发者书面同意,并需在您的项目中注明该项目地址 -> -> 祝大家金榜题名,旗开得胜 ### 系统要求 @@ -46,7 +44,7 @@ _✨ 优雅地下载音乐✨_ ### 文档 -点我跳转 +点我跳转 ### 使用条款 diff --git a/helper/SettingHelper.py b/helper/SettingHelper.py index 62ef861..b36ac69 100644 --- a/helper/SettingHelper.py +++ b/helper/SettingHelper.py @@ -1,8 +1,7 @@ import json, os from helper.getvalue import apilists from qfluentwidgets import MessageBoxBase, SubtitleLabel, CheckBox, LineEdit, HyperlinkButton, TransparentPushButton, ToolTipFilter, ToolTipPosition -from PyQt5.QtWidgets import QLabel, QHBoxLayout, QVBoxLayout -from PyQt5.QtCore import QUrl +from PyQt5.QtWidgets import QLabel, QHBoxLayout from qfluentwidgets import FluentIcon as FIF from helper.getvalue import autoncmaapi, autoqqmaapi @@ -21,7 +20,7 @@ def get_all_api(folders_arg): data = json.loads(u.read()) u.close() if data["type"] == "api": - apilists.append(filename.replace(".py", "")) + apilists.append(data["name"]) return apilists class DeleteAllData(MessageBoxBase): diff --git a/helper/downloadHelper.py b/helper/downloadHelper.py index 4ebe9f1..62e326e 100644 --- a/helper/downloadHelper.py +++ b/helper/downloadHelper.py @@ -7,7 +7,9 @@ from helper.getvalue import download_log, playlist_download_log from helper.flyoutmsg import dlsuc, dlerr, dlwar from win11toast import toast -from helper.pluginHelper import plugins_items + +from helper.loggerHelper import logger +from helper.pluginHelper import plugins_api_items thread = None @@ -41,10 +43,11 @@ def run(self): url = AZMusicAPI.geturl(id=id, api=api) elif self.howto == "search": try: - api_plugin = plugins_items[pfg.apicard.value] + api_plugin = plugins_api_items[pfg.apicard.value] url = api_plugin.geturl(id=id) - except: + except Exception as e: url = "PluginAPIImportError" + error_msg = e else: url = AZMusicAPI.geturl(id=id, api=api) if url == "Error 3": @@ -58,6 +61,8 @@ def run(self): self.finished.emit("Error") elif url == "PluginAPIImportError": self.show_error = "PluginAPIImportError" + if cfg.debug_card.value: + logger.error(f"插件错误:{error_msg}") self.finished.emit("Error") if not "Error" in url: diff --git a/helper/flyoutmsg.py b/helper/flyoutmsg.py index 6b46246..52dfd43 100644 --- a/helper/flyoutmsg.py +++ b/helper/flyoutmsg.py @@ -1,11 +1,13 @@ -from PyQt5.QtCore import Qt -from qfluentwidgets import InfoBar, InfoBarPosition, PushButton, InfoBarIcon -from helper.getvalue import outputlist, verdetail, VERSION, RELEASE_URL, AZ_URL -from qfluentwidgets import PushButton, PrimaryPushButton, FlyoutView, Flyout +from sys import exit + from PyQt5.QtCore import Qt, QUrl -from qfluentwidgets import FluentIcon as FIF from PyQt5.QtGui import QDesktopServices -from sys import exit +from qfluentwidgets import FluentIcon as FIF +from qfluentwidgets import InfoBar, InfoBarPosition, InfoBarIcon +from qfluentwidgets import PushButton, PrimaryPushButton, FlyoutView, Flyout + +from helper.getvalue import outputlist, verdetail, VERSION, RELEASE_URL, AZ_URL + def getoutputvalue(outid): try: @@ -103,7 +105,7 @@ def restart(parent): content='设置需要重启程序后生效', orient=Qt.Vertical, position=InfoBarPosition.TOP_RIGHT, - duration=1000, + duration=3000, parent=parent ) s = PushButton("立即关闭应用程序") @@ -114,7 +116,7 @@ def restart(parent): def setOK(parent, howto="settings"): if howto == "settings": content = '设置已保存' - time = 1000 + time = 1500 elif howto == "playlists": content = "导入任务已提交!稍等片刻,歌单就会出现在列表中。" time = 2500 diff --git a/helper/getvalue.py b/helper/getvalue.py index a2f47cd..bb06fa8 100644 --- a/helper/getvalue.py +++ b/helper/getvalue.py @@ -25,69 +25,71 @@ apilists = ['NCMA', 'QQMA'] # 古诗 -poem = ["天阶夜色凉如水,卧看牵牛织女星。", -"唯有门前镜湖水,春风不改旧时波。", -"三更灯火五更鸡,正是男儿读书时。", -"但屈指西风几时来,又不道流年暗中偷换。", -"俱往矣,数风流人物,还看今朝。", -"水是眼波横,山是眉峰聚。", -"明年此日青云去,却笑人间举子忙。", -"衰兰送客咸阳道,天若有情天亦老。", -"昔去雪如花,今来花似雪。", -"青青子衿,悠悠我心。", -"执子之手,与子偕老。", -"老来情味减,对别酒、怯流年。", -"什么是时光?我们穿上的衣服,却再也脱不下来。", -"但行好事,莫问前程。", -"吾道本无我,未曾嫌世人。如今到尘世,弥觉此心真", -"去年今日此门中,人面桃花相映红。", -"似花还似非花,也无人惜从教坠。", -"墙外行人,墙里佳人笑。", -"海内存知己,天涯若比邻。", -"七八个星天外,两三点雨山前。"] +poem = ["天阶夜色凉如水,卧看牵牛织女星。", + "唯有门前镜湖水,春风不改旧时波。", + "三更灯火五更鸡,正是男儿读书时。", + "但屈指西风几时来,又不道流年暗中偷换。", + "俱往矣,数风流人物,还看今朝。", + "水是眼波横,山是眉峰聚。", + "明年此日青云去,却笑人间举子忙。", + "衰兰送客咸阳道,天若有情天亦老。", + "昔去雪如花,今来花似雪。", + "青青子衿,悠悠我心。", + "执子之手,与子偕老。", + "老来情味减,对别酒、怯流年。", + "什么是时光?我们穿上的衣服,却再也脱不下来。", + "但行好事,莫问前程。", + "吾道本无我,未曾嫌世人。如今到尘世,弥觉此心真", + "去年今日此门中,人面桃花相映红。", + "似花还似非花,也无人惜从教坠。", + "墙外行人,墙里佳人笑。", + "海内存知己,天涯若比邻。", + "七八个星天外,两三点雨山前。"] + + def outapoem(): outpoem = poem[randint(0, len(poem) - 1)] return outpoem + def GetDefaultThemeColor(): dwmapi = ctypes.windll.dwmapi color = ctypes.c_ulong() opaque = ctypes.c_bool() - + # Call DwmGetColorizationColor result = dwmapi.DwmGetColorizationColor(ctypes.byref(color), ctypes.byref(opaque)) - + if result == 0: # S_OK # Extract the color components (ARGB format) alpha = (color.value >> 24) & 0xFF red = (color.value >> 16) & 0xFF green = (color.value >> 8) & 0xFF blue = color.value & 0xFF - - return(f"#{red:02X}{green:02X}{blue:02X}") - else: - return("#0078D4") + return (f"#{red:02X}{green:02X}{blue:02X}") + else: + return ("#0078D4") # 错误内容列表 outputlist = ['未搜索到相关的歌曲,换个关键词试试吧', - '你还没有输入噢', - '您选中的行无数据', - '音乐下载路径无法读取\创建失败', - "未配置NeteaseCloudMusicApi地址", - "未配置QQMusicApi地址", - '您可能是遇到了以下其一问题:网络错误 / 服务器宕机 / IP被封禁', - '这首歌曲无版权,暂不支持下载', - '获取链接失败,建议检查API服务器是否配置了账号Cookie', - '插件未成功导入,请检查插件'] - -verdetail = ("1.优化项目结构,UI与逻辑分离\n2.支持Windows系统通知\n3.修复了部分歌单的已知Bug\n4.重构插件页,无需手动导入插件\n5.添加了插件的更多功能\n7.重构我的音乐库页,提升用户体验\n8" - ".重构歌单页,提升用户体验") + '你还没有输入噢', + '您选中的行无数据', + '音乐下载路径无法读取\创建失败', + "未配置NeteaseCloudMusicApi地址", + "未配置QQMusicApi地址", + '您可能是遇到了以下其一问题:网络错误 / 服务器宕机 / IP被封禁', + '这首歌曲无版权,暂不支持下载', + '获取链接失败,建议检查API服务器是否配置了账号Cookie', + '插件未成功导入,请检查插件'] + +verdetail = "1.修复导航栏插件禁用Bug\n2.优化更新检查\n3.优化部分代码\n热烈庆祝中国共产党建党103周年!" YEAR = int(date.today().year) AUTHOR = "AZ Studio" -VERSION = "2.6.0" +VERSION = "2.6.103" +UPDATE_ORDER = 13 HELP_URL = "https://md.azprod.cn/docs/" FEEDBACK_URL = "https://github.com/AZ-Studio-2023/AZMusicDownloader/issues" RELEASE_URL = "https://github.com/AZ-Studio-2023/AZMusicDownloader/releases/tag/v2.6.0" diff --git a/helper/inital.py b/helper/inital.py index 76d422a..4262d17 100644 --- a/helper/inital.py +++ b/helper/inital.py @@ -8,7 +8,7 @@ from helper.config import cfg from qfluentwidgets import isDarkTheme from helper.getvalue import (download_log, search_log, configpath, upurl, VERSION, - playlistpath, logpath, playlist_download_log, playlist_search_log) + playlistpath, logpath, playlist_download_log, playlist_search_log, UPDATE_ORDER) # 初始化创建文件 @@ -80,37 +80,49 @@ def run(self): def showup(parent, updata, upworker): up = updata if not VERSION == up["latest"] and up["latest"] != "0.0.0": - # 等级可为:normal(普通的),important(重要的),fix(修复版) - if up["level"] == "normal": - text = "我们检测到了新的版本,版本号:{}\n本次更新为日常版本迭代,更新了新功能,可选择性进行更新。".format( - str(up["latest"])) - dlwar("检测到有新版本 {} ,本次更新为日常版本迭代,可选择进行更新。".format(str(up["latest"])), - parent, title="更新提示", show_time=up["flag_time"]) - elif up["level"] == "important": - text = "我们检测到了新的版本,版本号:{}\n本次更新为重要版本迭代,修复了Bug,更新了新功能,强烈建议进行更新。".format( - str(up["latest"])) - dlwar("检测到有新版本 {} ,本次更新为重要版本迭代,强烈建议进行更新。".format(str(up["latest"])), - parent, title="更新提示", show_time=up["flag_time"]) - elif up["level"] == "fix": - text = "我们检测到了新的版本,版本号:{}\n本次更新为Bug修复版本,修复了重大Bug,强烈建议进行更新。".format( - str(up["latest"])) - dlwar("检测到有新版本 {} ,本次更新为Bug修复版本,强烈建议进行更新。".format(str(up["latest"])), - parent, title="更新提示", show_time=up["flag_time"]) + if UPDATE_ORDER < up["update_order"]: + # 等级可为:normal(普通的),important(重要的),fix(修复版),special(特殊意义版) + if up["level"] == "normal": + text = "我们检测到了新的版本,版本号:{}\n本次更新为日常版本迭代,更新了新功能,可选择性进行更新。".format( + str(up["latest"])) + dlwar("检测到有新版本 {} ,本次更新为日常版本迭代,可选择进行更新。".format(str(up["latest"])), + parent, title="更新提示", show_time=up["flag_time"]) + elif up["level"] == "important": + text = "我们检测到了新的版本,版本号:{}\n本次更新为重要版本迭代,修复了Bug,更新了新功能,强烈建议进行更新。".format( + str(up["latest"])) + dlwar("检测到有新版本 {} ,本次更新为重要版本迭代,强烈建议进行更新。".format(str(up["latest"])), + parent, title="更新提示", show_time=up["flag_time"]) + elif up["level"] == "fix": + text = "我们检测到了新的版本,版本号:{}\n本次更新为Bug修复版本,修复了重大Bug,强烈建议进行更新。".format( + str(up["latest"])) + dlwar("检测到有新版本 {} ,本次更新为Bug修复版本,强烈建议进行更新。".format(str(up["latest"])), + parent, title="更新提示", show_time=up["flag_time"]) + elif up["level"] == "special": + text = "我们检测到了新的版本,版本号:{}\n{}".format( + str(up["latest"]), up["special"]) + dlwar("检测到有新版本 {} \n{}".format(str(up["latest"]), up["special"]), + parent, title="更新提示", show_time=up["flag_time"]) + else: + text = "我们检测到了新的版本,版本号:{}\n本次更新类型未知,可能是后续版本的新更新类型。".format( + str(up["latest"])) + dlwar("检测到有新版本 {} ,本次更新类型未知,可能是后续版本的新更新类型。".format(str(up["latest"])), + parent, title="更新提示", show_time=up["flag_time"]) + flyout_bottom(parent=parent, title="有新版本可用", content=text, button_content=up["button"], + button_todo=lambda: webbrowser.open_new_tab(up["link"]), duration=up["time"]) + elif UPDATE_ORDER > up["update_order"]: + dlsuc(content="您正在使用测试版本", parent=parent, title="提示", show_time=5000) else: - text = "我们检测到了新的版本,版本号:{}\n本次更新类型未知,可能是后续版本的新更新类型。".format( - str(up["latest"])) - dlwar("检测到有新版本 {} ,本次更新类型未知,可能是后续版本的新更新类型。".format(str(up["latest"])), - parent, title="更新提示", show_time=up["flag_time"]) - flyout_bottom(parent=parent, title="有新版本可用", content=text, button_content=up["button"], button_todo=lambda: webbrowser.open_new_tab(up["link"]), duration=up["time"]) - + dlsuc(content="您使用的版本是最新版本", parent=parent, title="恭喜", show_time=5000) elif up["latest"] == "0.0.0": - flyout_bottom(parent=parent, title=up["title"], content=up["text"], button_content=up["button"], button_todo=lambda: webbrowser.open_new_tab(up["link"]), duration=up["time"]) + flyout_bottom(parent=parent, title=up["title"], content=up["text"], button_content=up["button"], + button_todo=lambda: webbrowser.open_new_tab(up["link"]), duration=up["time"]) else: - dlsuc(content = "您使用的版本是最新版本", parent=parent, title="恭喜", show_time=5000) + dlsuc(content="您使用的版本是最新版本", parent=parent, title="恭喜", show_time=5000) upworker.quit() + # qss设置 def setSettingsQss(parent, which="setting_interface"): theme = 'dark' if isDarkTheme() else 'light' with open(f'resource/qss/{theme}/{which}.qss', encoding='utf-8') as f: - parent.setStyleSheet(f.read()) \ No newline at end of file + parent.setStyleSheet(f.read()) diff --git a/helper/localmusicsHelper.py b/helper/localmusicsHelper.py index 59f5522..6882964 100644 --- a/helper/localmusicsHelper.py +++ b/helper/localmusicsHelper.py @@ -1,12 +1,13 @@ -from helper.inital import mkf -from helper.getvalue import localView -from mutagen.easyid3 import EasyID3 -from mutagen.id3 import ID3NoHeaderError -from PyQt5.QtWidgets import QTableWidgetItem import subprocess from os import listdir from os.path import join, isfile +from PyQt5.QtWidgets import QTableWidgetItem +from mutagen.easyid3 import EasyID3 +from mutagen.id3 import ID3NoHeaderError + +from helper.inital import mkf + mkf() diff --git a/helper/playlistHelper.py b/helper/playlistHelper.py index c2a289b..daa3be1 100644 --- a/helper/playlistHelper.py +++ b/helper/playlistHelper.py @@ -1,13 +1,14 @@ import json +import os + +import requests from PyQt5.QtCore import QThread +from PyQt5.QtCore import pyqtSignal, pyqtSlot from PyQt5.QtWidgets import QTableWidgetItem -from PyQt5.QtCore import pyqtSignal, pyqtSlot -import os -import requests from helper.config import cfg -from helper.getvalue import playlist_search_log, playlist_download_log, autoncmaapi, playlistpath from helper.flyoutmsg import dlerr, dlwar +from helper.getvalue import playlist_search_log, playlist_download_log, playlistpath api = cfg.ncma_api.value diff --git a/helper/pluginHelper.py b/helper/pluginHelper.py index 1356611..5cedce0 100644 --- a/helper/pluginHelper.py +++ b/helper/pluginHelper.py @@ -1,16 +1,16 @@ # coding:utf-8 import importlib, sys, json, os - -from qfluentwidgets import FluentIcon as FIF from qfluentwidgets import SwitchSettingCard, PushSettingCard from helper.config import cfg from helper.flyoutmsg import dlerr -from helper.getvalue import apilists from helper.loggerHelper import logger +from qfluentwidgets import FluentIcon as FIF plugins_items = {} +plugins_api_items = {} folders = cfg.PluginFolders.value + def get_folders(directory): folders = [] for item in os.listdir(directory): @@ -19,8 +19,10 @@ def get_folders(directory): folders.append(item) return folders + def load_plugins(parent): global plugins_items + global plugins_api_items # 遍历插件目录中的文件 num = 0 if cfg.debug_card.value: @@ -29,12 +31,19 @@ def load_plugins(parent): sys.path.append(dirname) for filename in os.listdir(dirname): last_path = os.path.basename(dirname) - if filename.endswith('.py') and os.path.exists(dirname) and os.path.exists(dirname + "/index.json") and filename.replace(".py", "") == last_path and not os.path.exists(dirname + "/plugin.lock"): + if filename.endswith('.py') and os.path.exists(dirname) and os.path.exists( + dirname + "/index.json") and filename.replace(".py", "") == last_path and not os.path.exists( + dirname + "/plugin.lock"): plugin_name = filename[:-3] module_name = f"{plugin_name}" try: module = importlib.import_module(module_name) plugin_class = getattr(module, plugin_name) + u = open(dirname + "/index.json", encoding='utf-8') + data = json.loads(u.read()) + u.close() + if data["type"] == "api": + plugins_api_items[data["name"]] = plugin_class() plugins_items[plugin_name] = plugin_class() if cfg.debug_card.value: logger.info(f"导入插件: {plugin_name}") @@ -73,6 +82,8 @@ def set_plugin_disable(folder, state): else: if os.path.exists(f"{folder}/plugin.lock"): os.remove(f"{folder}/plugin.lock") + + def run_plugins_plugin(parent, PluginsGroup): folders = cfg.PluginFolders.value for folder in folders: @@ -82,6 +93,7 @@ def run_plugins_plugin(parent, PluginsGroup): get_json.close() addCard(parent, PluginsGroup, data["icon"], data["name"], data["desc"], data["type"], folder) + def open_plugin_window(plugin, parent): try: plugin_name = os.path.basename(plugin) @@ -91,10 +103,10 @@ def open_plugin_window(plugin, parent): data = json.loads(get_json.read()) new.setWindowTitle(data["name"]) new.show() - except: + except Exception as e: dlerr(outid=9, parent=parent) - - + if cfg.debug_card.value: + logger.error(f"插件错误:{e}") def addCard(parent, PluginsGroup, icon, title, content, type, uuid): @@ -103,7 +115,7 @@ def addCard(parent, PluginsGroup, icon, title, content, type, uuid): icon, title, content, - cfg.micaEnabled, + None, PluginsGroup ) PluginCard_Bar.checkedChanged.connect(lambda: set_plugin_disable(uuid, PluginCard_Bar.isChecked())) @@ -111,7 +123,7 @@ def addCard(parent, PluginsGroup, icon, title, content, type, uuid): PluginCard_Bar.setValue(True) else: PluginCard_Bar.setValue(False) - PluginCard_Bar.setObjectName(uuid) + PluginCard_Bar.setObjectName(os.path.basename(uuid)) parent.PluginsGroup.addSettingCard(PluginCard_Bar) elif type == "api": PluginCard_api = SwitchSettingCard( @@ -126,7 +138,7 @@ def addCard(parent, PluginsGroup, icon, title, content, type, uuid): PluginCard_api.setValue(True) else: PluginCard_api.setValue(False) - PluginCard_api.setObjectName(uuid) + PluginCard_api.setObjectName(os.path.basename(uuid)) parent.PluginsGroup.addSettingCard(PluginCard_api) elif type == "Window": PluginCard_window = PushSettingCard( @@ -136,6 +148,6 @@ def addCard(parent, PluginsGroup, icon, title, content, type, uuid): content, PluginsGroup ) - PluginCard_window.setObjectName(uuid) + PluginCard_window.setObjectName(os.path.basename(uuid)) PluginCard_window.clicked.connect(lambda: open_plugin_window(uuid, parent=parent)) parent.PluginsGroup.addSettingCard(PluginCard_window) diff --git a/helper/searchmusicHelper.py b/helper/searchmusicHelper.py index 5e886cf..530aef5 100644 --- a/helper/searchmusicHelper.py +++ b/helper/searchmusicHelper.py @@ -1,15 +1,20 @@ # coding: utf-8 -import json, AZMusicAPI +import AZMusicAPI +import json + +import os +import requests from PyQt5.QtCore import Qt, QThread -from PyQt5.QtWidgets import QTableWidgetItem, QCompleter from PyQt5.QtCore import pyqtSignal, pyqtSlot +from PyQt5.QtWidgets import QTableWidgetItem, QCompleter + import helper.config -import requests, os from helper.config import cfg, pfg -from helper.getvalue import download_log, search_log, autoncmaapi -from helper.inital import mkf from helper.flyoutmsg import dlerr, dlwar -from helper.pluginHelper import plugins_items +from helper.getvalue import download_log, search_log +from helper.inital import mkf +from helper.loggerHelper import logger +from helper.pluginHelper import plugins_api_items api = cfg.ncma_api.value q_api = cfg.qqma_api.value @@ -39,9 +44,11 @@ def run(self): self.songInfos = AZMusicAPI.getmusic(keywords, number=value, api=api_value, server="qqma") else: try: - api_plugin = plugins_items[pfg.apicard.value] + api_plugin = plugins_api_items[pfg.apicard.value] self.songInfos = api_plugin.getmusic(keyword=keywords, number=value) - except: + except Exception as e: + if cfg.debug_card.value: + logger.error(f"插件错误:{e}") self.songInfos = "PluginAPIImportError" self.finished.emit() diff --git a/resource/hitokoto.json b/resource/hitokoto.json deleted file mode 100644 index 6bbe3f7..0000000 --- a/resource/hitokoto.json +++ /dev/null @@ -1 +0,0 @@ -{"hitokoto": ["\u5929\u9636\u591c\u8272\u51c9\u5982\u6c34\uff0c\u5367\u770b\u7275\u725b\u7ec7\u5973\u661f\u3002", "\u552f\u6709\u95e8\u524d\u955c\u6e56\u6c34\uff0c\u6625\u98ce\u4e0d\u6539\u65e7\u65f6\u6ce2\u3002", "\u4e09\u66f4\u706f\u706b\u4e94\u66f4\u9e21\uff0c\u6b63\u662f\u7537\u513f\u8bfb\u4e66\u65f6\u3002", "\u4f46\u5c48\u6307\u897f\u98ce\u51e0\u65f6\u6765\uff0c\u53c8\u4e0d\u9053\u6d41\u5e74\u6697\u4e2d\u5077\u6362\u3002", "\u4ff1\u5f80\u77e3\uff0c\u6570\u98ce\u6d41\u4eba\u7269\uff0c\u8fd8\u770b\u4eca\u671d\u3002", "\u6c34\u662f\u773c\u6ce2\u6a2a\uff0c\u5c71\u662f\u7709\u5cf0\u805a\u3002", "\u660e\u5e74\u6b64\u65e5\u9752\u4e91\u53bb\uff0c\u5374\u7b11\u4eba\u95f4\u4e3e\u5b50\u5fd9\u3002", "\u8870\u5170\u9001\u5ba2\u54b8\u9633\u9053\uff0c\u5929\u82e5\u6709\u60c5\u5929\u4ea6\u8001\u3002", "\u6614\u53bb\u96ea\u5982\u82b1\uff0c\u4eca\u6765\u82b1\u4f3c\u96ea\u3002", "\u9752\u9752\u5b50\u887f\uff0c\u60a0\u60a0\u6211\u5fc3\u3002", "\u6267\u5b50\u4e4b\u624b\uff0c\u4e0e\u5b50\u5055\u8001\u3002", "\u8001\u6765\u60c5\u5473\u51cf\uff0c\u5bf9\u522b\u9152\u3001\u602f\u6d41\u5e74\u3002", "\u4ec0\u4e48\u662f\u65f6\u5149\uff1f\u6211\u4eec\u7a7f\u4e0a\u7684\u8863\u670d\uff0c\u5374\u518d\u4e5f\u8131\u4e0d\u4e0b\u6765\u3002", "\u4f46\u884c\u597d\u4e8b\uff0c\u83ab\u95ee\u524d\u7a0b\u3002", "\u543e\u9053\u672c\u65e0\u6211\uff0c\u672a\u66fe\u5acc\u4e16\u4eba\u3002\u5982\u4eca\u5230\u5c18\u4e16\uff0c\u5f25\u89c9\u6b64\u5fc3\u771f", "\u53bb\u5e74\u4eca\u65e5\u6b64\u95e8\u4e2d\uff0c\u4eba\u9762\u6843\u82b1\u76f8\u6620\u7ea2\u3002", "\u4f3c\u82b1\u8fd8\u4f3c\u975e\u82b1\uff0c\u4e5f\u65e0\u4eba\u60dc\u4ece\u6559\u5760\u3002", "\u5899\u5916\u884c\u4eba\uff0c\u5899\u91cc\u4f73\u4eba\u7b11\u3002", "\u6d77\u5185\u5b58\u77e5\u5df1\uff0c\u5929\u6daf\u82e5\u6bd4\u90bb\u3002", "\u4e03\u516b\u4e2a\u661f\u5929\u5916\uff0c\u4e24\u4e09\u70b9\u96e8\u5c71\u524d\u3002"]} \ No newline at end of file diff --git a/window/main.py b/window/main.py index 2d6828f..1dfec14 100644 --- a/window/main.py +++ b/window/main.py @@ -1,27 +1,28 @@ # coding:utf-8 -import json, sys -import os - -from Interface.searchmusic import searchmusic -from Interface.settings import SettingInterface +import sys from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QMessageBox, QApplication - -from qfluentwidgets import NavigationItemPosition, MSFluentWindow, NavigationItemPosition +from PyQt5.QtWidgets import QApplication from qfluentwidgets import FluentIcon as FIF +from qfluentwidgets import MSFluentWindow, NavigationItemPosition + from Interface.localmusics import localmusics from Interface.playlist import playlist from Interface.plugin import plugins -from helper.config import cfg,pfg -from helper.pluginHelper import run_plugins, load_plugins +from Interface.searchmusic import searchmusic +from Interface.settings import SettingInterface +from helper.config import cfg, pfg from helper.loggerHelper import logger +from helper.pluginHelper import run_plugins, load_plugins +from helper.getvalue import VERSION, UPDATE_ORDER api = cfg.ncma_api.value q_api = cfg.qqma_api.value # Print logs | 日志输出 logger.info("欢迎使用AZMusicDownloader") +logger.info(f"程序版本:{VERSION}") +logger.info(f"更新编号:{UPDATE_ORDER}") if cfg.beta.value: logger.warning("Beta实验功能:启用") else: