From 31c69b4ed0e0309944a0a2feff3e41f926585e33 Mon Sep 17 00:00:00 2001 From: Brosef Date: Wed, 17 Dec 2025 12:15:55 +0000 Subject: [PATCH] Added generateLRCLine() --- utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/utils.py b/utils.py index 48fb11b..6f06b5e 100644 --- a/utils.py +++ b/utils.py @@ -51,6 +51,21 @@ def parseLrcLine(lrcLine: str) -> [float, str]: return t, lrcLine +def generateLRCLine(time: float, text: str='') -> str: + """ + Turns a time (in seconds) and an optional lyrics into a valid LRC line. + If passed (62.1, 'Hello world'), this function will return '[01:02.10] Hello world' + + Args: + time (float): The lyrics time in seconds. + text (str, optional): The text for the lyric. + + Returns: + str: The LRC line. + """ + + return f'[{int(time//60):02d}:{time%60:05.2f}] {text}' + def getInfo(getType: str) -> dict: """ Runs the `GetInfo` command and automatically parses the JSON.