NFLmusic库文件

This commit is contained in:
2025-01-23 16:47:37 +08:00
parent 7516e1c95d
commit 9b3f1d1654
54 changed files with 3763 additions and 0 deletions

29
nflmusic/lyrics.py Normal file
View File

@ -0,0 +1,29 @@
import re
def load_lyrics(file):
with open(file, 'r', encoding='utf-8') as file:
lines = file.readlines()
lyrics = {}
for line in lines:
match = re.match(r'\[(\d+):(\d+\.\d+)\](.*)', line)
if match:
minutes = int(match.group(1))
seconds = int(float(match.group(2)))
timestamp = f'{minutes:02}:{seconds:02}'
text = match.group(3)
lyrics[timestamp] = text
return lyrics
def get_lyrics(lyrics, time):
try:
lyric = lyrics[time]
return lyric
except:
pass
if __name__ == '__main__':
print(load_lyrics("C:/Users/admin/Desktop/NFLmusic/3.8.8/music/王菲 - 匆匆那年.lrc"))