Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore LRC file tags #51

Open
barraIhsan opened this issue Jul 11, 2024 · 2 comments
Open

Ignore LRC file tags #51

barraIhsan opened this issue Jul 11, 2024 · 2 comments

Comments

@barraIhsan
Copy link

An addition for #48, currently lrclib uses artist metadata to mark song as instrumental
[ar: instrumental]

But somehow, sptlrx fail? to parse the metadata, it will show up
umental]
image
I tried to set the .ignoreErrors to false hoping to see any error printed out, but there are no error

@raitonoberu
Copy link
Owner

raitonoberu commented Jul 23, 2024

Right now we are using a pretty naive algorithm to parse the .lrc file:

func parseLrcFile(reader io.Reader) []lyrics.Line {
result := []lyrics.Line{}
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
line := scanner.Text()
if !strings.HasPrefix(line, "[") || len(line) < 10 {
continue
}
result = append(result, parseLrcLine(line))
}
return result
}
func parseLrcLine(line string) lyrics.Line {
// [00:00.00]text -> {"time": 0, "words": "text"}
h, _ := strconv.Atoi(line[1:3])
m, _ := strconv.Atoi(line[4:6])
s, _ := strconv.Atoi(line[7:9])
return lyrics.Line{
Time: h*60*1000 + m*1000 + s*10,
Words: line[10:],
}
}

So, we assume that every line starting with [ is a lyrics line, but, according to the Wiki page, a file can also contain various metadata (tags).

@raitonoberu raitonoberu changed the title Instrumental Song Display Ignore LRC file tags Jul 23, 2024
@YanceyChiew
Copy link
Contributor

This design also results in lyrics files which accurate to milliseconds (the format may not comply with the specification, but if we want to support variable-length lrc tags, solving the problems they bring is just a dropping by) will be displayed with a ] symbol at the beginning of the line during rendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants