Skip to content

Commit

Permalink
feat: 优化批量下载工具命名和下载高码率音频
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Dec 11, 2024
1 parent 73df9de commit 23882cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions xiaomusic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,8 @@ async def download_playlist(config, url, dirname):
"-x",
"--audio-format",
"mp3",
"--audio-quality",
"0",
"--paths",
config.download_path,
"-o",
Expand Down Expand Up @@ -899,6 +901,8 @@ async def download_one_music(config, url, name=""):
"-x",
"--audio-format",
"mp3",
"--audio-quality",
"0",
"--paths",
config.download_path,
"-o",
Expand Down Expand Up @@ -947,13 +951,17 @@ def remove_common_prefix(directory):

log.info(f'Common prefix identified: "{common_prefix}"')

pattern = re.compile(r"(\d+)[\t  ]*\1")
for filename in files:
if filename == common_prefix:
continue
# 检查文件名是否以共同前缀开头
if filename.startswith(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)
new_file_path = os.path.join(directory, new_filename)
Expand Down
2 changes: 2 additions & 0 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,8 @@ async def download(self, search_key, name):
"-x",
"--audio-format",
"mp3",
"--audio-quality",
"0",
"--paths",
self.download_path,
"-o",
Expand Down

0 comments on commit 23882cf

Please sign in to comment.