个别foobar下载的lrc歌词识别异常
solitudechn opened this issue · comments
仅仅反馈你所遇到的一个使用问题,多个请重新提交另外的 issue。Only give feedback on one usage problem you encountered, please resubmit another issue.
在你反馈此问题前请注意:Please note before you respond to this question:
- 详细阅读椒盐音乐帮助内容(应用设置-帮助)。Read more about the SaltPlayer help content (app Settings - Help).
- 尝试在仓库 issue 搜索你要反馈的问题,避免重复反馈。Try to search for your feedback in the warehouse issue to avoid repeated feedback.
反馈时候请注意:When giving feedback, please note:
- 尽量详细的描述问题。Describe the problem as detailed as possible.
- 提供出现此问题的椒盐音乐版本号。Provide the version number of SaltPlayer where this problem occurred.
- 建议提供机型、系统版本。You are advised to provide the model and system version.
基本信息 The basic information
软件版本 Software version:8.17.0-beta02(2023103001
系统版本 System version:android 14
反馈内容 Content of the feedback
使用foobar2000下载的部分lrc歌词会出现
[00:23.48][01:40.18]只此刻都心慌
[00:25.28][01:42.09]像是小鹿撞
[00:27.20][01:44.35]来人来客匆忙
[00:29.19][01:45.91]也快忘礼让
[00:31.02][01:48.19]我才攥住一颗喜糖
[00:35.76][01:52.55]分些喜气给红娘
[00:38.34][01:55.10]金钗摇
[00:39.17][00:42.84][00:46.62][00:50.45][01:55.79][01:59.47][02:03.41][02:07.17][02:26.32][02:30.24][02:34.01][02:37.82]摆摆摆
[00:41.98][01:58.71]花轿摇
[00:45.86][02:02.82]招摇
[00:49.65][02:06.37]铃铛摇
这样的格式。当出现这样的格式的歌词时,椒盐音乐会仅显示第一段歌词,然后当音乐播放至第二段歌词时将不会显示任何歌词。
写了个脚本来处理这样的歌词,仅供参考
import os
import re
import shutil
def parse_lrc_file(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
parsed_lines = []
for line in lines:
matches = re.findall(r'\[\d{2}:\d{2}\.\d{2}\]', line)
if matches:
for match in matches:
line = line.replace(match, '')
for match in matches:
parsed_lines.append((match, line.strip()))
parsed_lines.sort()
return parsed_lines
def write_lrc_file(file_path, parsed_lines):
with open(file_path, 'w', encoding='utf-8') as file:
for time, line in parsed_lines:
file.write(f'{time}{line}\n')
def main():
lrc_dir = './lrc_files/' # .lrc文件的目录
old_lrc_dir = './old_lrc/' # 保存原始.lrc文件的目录
new_lrc_dir = './new_lrc/' # 保存修改后的.lrc文件的目录
# 创建目录,如果它们不存在
os.makedirs(old_lrc_dir, exist_ok=True)
os.makedirs(new_lrc_dir, exist_ok=True)
lrc_files = [file_name for file_name in os.listdir(lrc_dir) if file_name.endswith('.lrc')]
total_files = len(lrc_files)
print(f'Total .lrc files: {total_files}')
for i, file_name in enumerate(lrc_files, start=1):
file_path = os.path.join(lrc_dir, file_name)
parsed_lines = parse_lrc_file(file_path)
# 如果.lrc文件包含多个时间戳,就复制它到old_lrc_dir,并将修改后的文件保存到new_lrc_dir
if any(len(line) > 1 for line in parsed_lines):
shutil.copy(file_path, os.path.join(old_lrc_dir, file_name))
write_lrc_file(os.path.join(new_lrc_dir, file_name), parsed_lines)
print(f'Processed {file_name} ({i}/{total_files})')
if __name__ == '__main__':
main()