Temp Upload

This commit is contained in:
1826013250 2023-04-17 02:41:06 +08:00
parent bee7f106c5
commit 18de4e1cea
4 changed files with 45 additions and 0 deletions

View File

@ -78,6 +78,9 @@ def get_song_lyric(id: str | int | dict, path: str, allinfo: bool = False):
artists = artists[:-1] artists = artists[:-1]
name = sinfo["name"] name = sinfo["name"]
if not name:
print("歌曲错误!这是网易云的问题,请不要找作者")
return "song_err"
replaces = { # 处理非法字符所用的替换字典(根据网易云下载的文件分析得到) replaces = { # 处理非法字符所用的替换字典(根据网易云下载的文件分析得到)
"|": "", "|": "",
":": "", ":": "",

View File

@ -250,7 +250,9 @@ def get_lyric_from_folder(self):
q_err, q_err,
q_info)).start() q_info)).start()
allocated += 1 allocated += 1
current_process += 1
bar.suffix = f"已分配: {ncm_files[allocated-1]}" bar.suffix = f"已分配: {ncm_files[allocated-1]}"
print(len(bar.fill))
bar.update() bar.update()
while True: # 错误队列检测 while True: # 错误队列检测
try: try:

33
modules/utils/bar.py Normal file
View File

@ -0,0 +1,33 @@
"""一些有关调整进度条的设置"""
from os import get_terminal_size
from progress.bar import Bar
def suit_length(bar: Bar, original: Bar):
"""尽量调整进度条大小去匹配终端宽度"""
length = get_terminal_size().columns
original_length = original.width + len((original.message +
original.bar_suffix +
original.bar_prefix +
original.suffix) % bar)
if length >= original_length:
return
if length < len(str(bar.max) + "/" + str(bar.index)):
bar.bar_suffix = bar.suffix = bar.bar_prefix = ""
bar.width = 0
bar.suffix = Bar.suffix
elif length >= original_length - bar.width:
bar.width = length - len((bar.message + bar.bar_suffix + bar.bar_prefix + bar.suffix) % bar)
elif length >= original_length - (bar.width + len(bar.suffix % bar)) and "(index)" in bar.message:
bar.suffix = ""
bar.width = length - len((bar.message + bar.bar_suffix + bar.bar_prefix + bar.suffix) % bar)
elif length >= original_length - (bar.width + len(bar.message % bar)) and "(index)" in bar.suffix:
bar.message = ""
bar.width = length - len((bar.message + bar.bar_suffix + bar.bar_prefix + bar.suffix) % bar)
elif length >= original_length - (bar.width + len((bar.message + bar.suffix) % bar)) + Bar.suffix % bar:
bar.message = ""
bar.suffix = Bar.suffix
bar.width = length - len((bar.message + bar.bar_suffix + bar.bar_prefix + bar.suffix) % bar)
bar.update()
return

7
modules/utils/length.py Normal file
View File

@ -0,0 +1,7 @@
"""一些有关计算长度的工具"""
def len_abs(content):
"""针对中文将一个汉字识别为2个长度而不是1个"""
return len(content) + (len(content.encode("utf-8")) - len(content)) // 2