Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lrclib-go

Go Reference License: MIT

Go client for the LRCLIB lyrics API and parser for synchronized LRC text files.

Features

  • Fast LRC parser that skips metadata tags and extracts timed lines without regular expressions
  • LRCLIB REST client to search tracks, look up by ID, and fetch synchronized or plain lyrics
  • Built-in request pacing and automatic backoff on HTTP 429 using Retry-After
  • Standard library only, no external dependencies

Installation

go get github.com/fumbledlol/lrclib-go

Usage

Parsing synchronized LRC

package main

import (
	"fmt"

	"github.com/fumbledlol/lrclib-go"
)

func main() {
	rawLRC := `[ti:Song Title]
[00:12.34]First lyric line
[00:15.50]Second lyric line`

	lines, err := lrclib.ParseLRC(rawLRC)
	if err != nil {
		panic(err)
	}

	for _, line := range lines {
		fmt.Printf("[%v] (%.2fs) %s\n", line.Timestamp, line.Seconds, line.Text)
	}
}

Fetching lyrics from LRCLIB

client := lrclib.NewClient()

lyrics, err := client.Get(ctx, "Track Name", "Artist Name", "Album Name", 210.0)
if err != nil {
	// Handle ErrNotFound or request error
}

// Access timed lines
lines, err := lyrics.Lines()

Benchmarks

BenchmarkParseLRC-12    4112946    306.9 ns/op    352 B/op    1 allocs/op

License

MIT

About

LRCLIB REST client and synchronized LRC lyric parser with rate limiting and backoff

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages