feat: 优化批量下载工具命名和下载高码率音频

This commit is contained in:
涵曦 2024-12-12 00:43:30 +08:00
parent 73df9dec48
commit 23882cf85c
2 changed files with 10 additions and 0 deletions

View File

@ -866,6 +866,8 @@ async def download_playlist(config, url, dirname):
"-x", "-x",
"--audio-format", "--audio-format",
"mp3", "mp3",
"--audio-quality",
"0",
"--paths", "--paths",
config.download_path, config.download_path,
"-o", "-o",
@ -899,6 +901,8 @@ async def download_one_music(config, url, name=""):
"-x", "-x",
"--audio-format", "--audio-format",
"mp3", "mp3",
"--audio-quality",
"0",
"--paths", "--paths",
config.download_path, config.download_path,
"-o", "-o",
@ -947,6 +951,7 @@ def remove_common_prefix(directory):
log.info(f'Common prefix identified: "{common_prefix}"') log.info(f'Common prefix identified: "{common_prefix}"')
pattern = re.compile(r"(\d+)[\t  ]*\1")
for filename in files: for filename in files:
if filename == common_prefix: if filename == common_prefix:
continue continue
@ -954,6 +959,9 @@ def remove_common_prefix(directory):
if filename.startswith(common_prefix): if filename.startswith(common_prefix):
# 构造新的文件名 # 构造新的文件名
new_filename = filename[len(common_prefix) :] new_filename = filename[len(common_prefix) :]
match = pattern.match(new_filename)
if match:
new_filename = match.group(1) + new_filename[match.end() :]
# 生成完整的文件路径 # 生成完整的文件路径
old_file_path = os.path.join(directory, filename) old_file_path = os.path.join(directory, filename)
new_file_path = os.path.join(directory, new_filename) new_file_path = os.path.join(directory, new_filename)

View File

@ -1640,6 +1640,8 @@ class XiaoMusicDevice:
"-x", "-x",
"--audio-format", "--audio-format",
"mp3", "mp3",
"--audio-quality",
"0",
"--paths", "--paths",
self.download_path, self.download_path,
"-o", "-o",