Files
navidrome-music-sync/app/core/lyrics.py
T

19 lines
600 B
Python

import os
import syncedlyrics
def fetch_and_save_lyrics(dest_audio_path: str, search_query: str) -> bool:
"""Download synchronized LRC lyrics and save beside audio file."""
lrc_path = os.path.splitext(dest_audio_path)[0] + ".lrc"
if os.path.exists(lrc_path):
return True
try:
lrc = syncedlyrics.search(search_query)
if lrc:
with open(lrc_path, "w", encoding="utf-8") as f:
f.write(lrc)
return True
except Exception as e:
print(f"Warning: Failed to fetch lyrics for '{search_query}': {e}")
return False