🏡 index : ironmagma/quintodrome.git

// Code generated by ndpgen. DO NOT EDIT.
//
// This file contains export wrappers for the Lyrics capability.
// It is intended for use in Navidrome plugins built with TinyGo.
//
//go:build wasip1

package lyrics

import (
	"github.com/navidrome/navidrome/plugins/pdk/go/pdk"
)

// ArtistRef is a reference to an artist with name and optional MBID.
type ArtistRef struct {
	// ID is the internal Navidrome artist ID (if known).
	ID string `json:"id,omitempty"`
	// Name is the artist name.
	Name string `json:"name"`
	// MBID is the MusicBrainz ID for the artist.
	MBID string `json:"mbid,omitempty"`
}

// GetLyricsRequest contains the track information for lyrics lookup.
type GetLyricsRequest struct {
	Track TrackInfo `json:"track"`
}

// GetLyricsResponse contains the lyrics returned by the plugin.
type GetLyricsResponse struct {
	Lyrics []LyricsText `json:"lyrics"`
}

// LyricsText represents a single set of lyrics in raw text format.
// Text can be plain text or LRC format — Navidrome will parse it.
type LyricsText struct {
	Lang string `json:"lang,omitempty"`
	Text string `json:"text"`
}

// TrackInfo contains track metadata.
type TrackInfo struct {
	// ID is the internal Navidrome track ID.
	ID string `json:"id"`
	// Title is the track title.
	Title string `json:"title"`
	// Album is the album name.
	Album string `json:"album"`
	// Artist is the formatted artist name for display (e.g., "Artist1 • Artist2").
	Artist string `json:"artist"`
	// AlbumArtist is the formatted album artist name for display.
	AlbumArtist string `json:"albumArtist"`
	// Artists is the list of track artists.
	Artists []ArtistRef `json:"artists"`
	// AlbumArtists is the list of album artists.
	AlbumArtists []ArtistRef `json:"albumArtists"`
	// Duration is the track duration in seconds.
	Duration float32 `json:"duration"`
	// TrackNumber is the track number on the album.
	TrackNumber int32 `json:"trackNumber"`
	// DiscNumber is the disc number.
	DiscNumber int32 `json:"discNumber"`
	// MBZRecordingID is the MusicBrainz recording ID.
	MBZRecordingID string `json:"mbzRecordingId,omitempty"`
	// MBZAlbumID is the MusicBrainz album/release ID.
	MBZAlbumID string `json:"mbzAlbumId,omitempty"`
	// MBZReleaseGroupID is the MusicBrainz release group ID.
	MBZReleaseGroupID string `json:"mbzReleaseGroupId,omitempty"`
	// MBZReleaseTrackID is the MusicBrainz release track ID.
	MBZReleaseTrackID string `json:"mbzReleaseTrackId,omitempty"`
	// LibraryID is the ID of the library the track belongs to.
	// Only included if the plugin has library permission with filesystem access for the track's library.
	LibraryID int32 `json:"libraryId,omitempty"`
	// Path is the full path to the track file, relative to the library root.
	// Only included if the plugin has library permission with filesystem access for the track's library.
	Path string `json:"path,omitempty"`
}

// Lyrics requires all methods to be implemented.
// Lyrics provides lyrics for a given track from external sources.
type Lyrics interface {
	// GetLyrics
	GetLyrics(GetLyricsRequest) (GetLyricsResponse, error)
} // Internal implementation holders
var (
	lyricsImpl func(GetLyricsRequest) (GetLyricsResponse, error)
)

// Register registers a lyrics implementation.
// All methods are required.
func Register(impl Lyrics) {
	lyricsImpl = impl.GetLyrics
}

// NotImplementedCode is the standard return code for unimplemented functions.
// The host recognizes this and skips the plugin gracefully.
const NotImplementedCode int32 = -2

//go:wasmexport nd_lyrics_get_lyrics
func _NdLyricsGetLyrics() int32 {
	if lyricsImpl == nil {
		// Return standard code - host will skip this plugin gracefully
		return NotImplementedCode
	}

	var input GetLyricsRequest
	if err := pdk.InputJSON(&input); err != nil {
		pdk.SetError(err)
		return -1
	}

	output, err := lyricsImpl(input)
	if err != nil {
		pdk.SetError(err)
		return -1
	}

	if err := pdk.OutputJSON(output); err != nil {
		pdk.SetError(err)
		return -1
	}

	return 0
}