Files
pipu-music/services/api/cmd/genius/main.go
T
mrleo1nidandCursor 73ad61e7a5
ci / ts / ts (packages + web) (push) Canceled after 1m0s
ci / api / api (push) Successful in 46s
ci / contract / contract (сгенерированный код совпадает с openapi.yaml) (push) Successful in 56s
ci / db / db (push) Successful in 1m32s
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m27s
ci / docker / docker (образы собираются — их сервер собирает сам при обновлении) (push) Successful in 1m31s
feat(genius): load song metadata, lyrics, and artwork
Search hits omit album covers and artist images. The worker now reads the full song and artist, stores the description, and leaves Genius image URLs unchanged on mobile.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-22 08:23:54 +03:00

40 lines
1009 B
Go

// Command genius searches metadata or retrieves lyrics from an explicitly selected Genius URL.
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"os"
"pipu/api/internal/genius"
)
func main() {
query := flag.String("search", "", "search candidates by artist and title (requires GENIUS_ACCESS_TOKEN)")
page := flag.String("url", "", "retrieve lyrics from a selected https://genius.com/...-lyrics URL")
flag.Parse()
if (*query == "") == (*page == "") || flag.NArg() != 0 {
fmt.Fprintln(os.Stderr, "provide exactly one of -search or -url")
os.Exit(2)
}
client := genius.New(os.Getenv("GENIUS_ACCESS_TOKEN"))
var result any
var err error
if *query != "" {
result, err = client.Search(context.Background(), *query)
} else {
result, err = client.FetchLyrics(context.Background(), *page)
}
if err == nil {
encoder := json.NewEncoder(os.Stdout)
encoder.SetIndent("", " ")
err = encoder.Encode(result)
}
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}