// Code generated by ndpgen. DO NOT EDIT. // // This file contains export wrappers for the PlaylistProvider capability. // It is intended for use in Navidrome plugins built with TinyGo. // //go:build wasip1 package playlistprovider import ( "github.com/navidrome/navidrome/plugins/pdk/go/pdk" ) // PlaylistProviderError represents an error type for playlist provider operations. type PlaylistProviderError string const ( // PlaylistProviderErrorNotFound indicates a playlist is currently unavailable. PlaylistProviderErrorNotFound PlaylistProviderError = "playlist_provider(not_found)" ) // Error implements the error interface for PlaylistProviderError. func (e PlaylistProviderError) Error() string { return string(e) } // GetAvailablePlaylistsRequest is the request for GetAvailablePlaylists. type GetAvailablePlaylistsRequest struct { } // GetAvailablePlaylistsResponse is the response for GetAvailablePlaylists. type GetAvailablePlaylistsResponse struct { // Playlists is the list of playlists provided by this plugin. Playlists []PlaylistInfo `json:"playlists"` // RefreshInterval is the number of seconds until the next GetAvailablePlaylists call. // 0 means never re-discover. RefreshInterval int64 `json:"refreshInterval"` // RetryInterval is the number of seconds before retrying a failed GetPlaylist call. // 0 means no automatic retry for transient errors. RetryInterval int64 `json:"retryInterval"` } // GetPlaylistRequest is the request for GetPlaylist. type GetPlaylistRequest struct { // ID is the plugin-scoped playlist ID. ID string `json:"id"` } // GetPlaylistResponse is the response for GetPlaylist. type GetPlaylistResponse struct { // Name is the display name of the playlist. Name string `json:"name"` // Description is an optional description for the playlist. Description string `json:"description,omitempty"` // CoverArtURL is an optional external URL for the playlist cover art. CoverArtURL string `json:"coverArtUrl,omitempty"` // Tracks is the list of songs in the playlist, using SongRef for matching. Tracks []SongRef `json:"tracks"` // ValidUntil is a unix timestamp indicating when this playlist data expires. // 0 means static (never refresh). ValidUntil int64 `json:"validUntil"` } // PlaylistInfo identifies a plugin playlist and its target user. type PlaylistInfo struct { // ID is the plugin-scoped unique identifier for this playlist. ID string `json:"id"` // OwnerUsername is the Navidrome username that owns this playlist. OwnerUsername string `json:"ownerUsername"` } // SongRef is a reference to a song with metadata for matching. type SongRef struct { // ID is the internal Navidrome mediafile ID (if known). ID string `json:"id,omitempty"` // Name is the song name. Name string `json:"name"` // MBID is the MusicBrainz ID for the song. MBID string `json:"mbid,omitempty"` // ISRC is the International Standard Recording Code for the song. ISRC string `json:"isrc,omitempty"` // Artist is the artist name. Artist string `json:"artist,omitempty"` // ArtistMBID is the MusicBrainz artist ID. ArtistMBID string `json:"artistMbid,omitempty"` // Album is the album name. Album string `json:"album,omitempty"` // AlbumMBID is the MusicBrainz release ID. AlbumMBID string `json:"albumMbid,omitempty"` // Duration is the song duration in seconds. Duration float32 `json:"duration,omitempty"` } // PlaylistProvider requires all methods to be implemented. // PlaylistProvider provides dynamically-generated playlists (e.g., "Daily Mix", // personalized recommendations). Plugins implementing this capability expose two // functions: GetAvailablePlaylists for lightweight discovery and GetPlaylist for // fetching the heavy payload (tracks, metadata). type PlaylistProvider interface { // GetAvailablePlaylists - GetAvailablePlaylists returns the list of playlists this plugin provides. GetAvailablePlaylists(GetAvailablePlaylistsRequest) (GetAvailablePlaylistsResponse, error) // GetPlaylist - GetPlaylist returns the full data for a single playlist (tracks, metadata). GetPlaylist(GetPlaylistRequest) (GetPlaylistResponse, error) } // Internal implementation holders var ( availablePlaylistsImpl func(GetAvailablePlaylistsRequest) (GetAvailablePlaylistsResponse, error) playlistImpl func(GetPlaylistRequest) (GetPlaylistResponse, error) ) // Register registers a playlistprovider implementation. // All methods are required. func Register(impl PlaylistProvider) { availablePlaylistsImpl = impl.GetAvailablePlaylists playlistImpl = impl.GetPlaylist } // 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_playlist_provider_get_available_playlists func _NdPlaylistProviderGetAvailablePlaylists() int32 { if availablePlaylistsImpl == nil { // Return standard code - host will skip this plugin gracefully return NotImplementedCode } var input GetAvailablePlaylistsRequest if err := pdk.InputJSON(&input); err != nil { pdk.SetError(err) return -1 } output, err := availablePlaylistsImpl(input) if err != nil { pdk.SetError(err) return -1 } if err := pdk.OutputJSON(output); err != nil { pdk.SetError(err) return -1 } return 0 } //go:wasmexport nd_playlist_provider_get_playlist func _NdPlaylistProviderGetPlaylist() int32 { if playlistImpl == nil { // Return standard code - host will skip this plugin gracefully return NotImplementedCode } var input GetPlaylistRequest if err := pdk.InputJSON(&input); err != nil { pdk.SetError(err) return -1 } output, err := playlistImpl(input) if err != nil { pdk.SetError(err) return -1 } if err := pdk.OutputJSON(output); err != nil { pdk.SetError(err) return -1 } return 0 }