fnmusic

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: AGPL-3.0 Imports: 28 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

飞牛音乐(FN Music)

肥牛音乐随 Wagyu Music 宿主 一同构建和发行。宿主通过 Go module 引用本仓库。

使用 插件 SDK 的 v1 通信协议。运行 go test ./... 可执行本仓库的测试。

Documentation

Index

Constants

View Source
const (
	PageSize  = 100
	PageAhead = 2
	CardsPage = 60
)

Variables

This section is empty.

Functions

func DeleteCredentials

func DeleteCredentials()

func LoadCredentials

func LoadCredentials(cfg *backend.Config)

func PlayList

func PlayList(p PlayerPort, l *List, index int)

func Registration

func Registration() pluginapi.Registration

func SaveCredentials

func SaveCredentials(cfg backend.Config) error

func ShuffleList

func ShuffleList(ctx context.Context, p PlayerPort, l *List, post func(func()))

ShuffleList starts immediately when the first page is available. The page already displayed is always part of the first batch, so pressing shuffle never discards the list the user is looking at.

func Start

func Start(start pluginapi.Startup) pluginapi.Adapter

Start creates the Feiniu instance and registers its native windows.

Types

type AccountAction

type AccountAction struct {
	Icon      *ui.SVG
	Label     string
	Shortcut  string
	Separator bool
	Danger    bool
	Action    func()
}

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter owns one complete Feiniu context. The root app stores only this interface, so provider state and UI do not leak into shared app files.

func NewAdapter

func NewAdapter(host Host, settings *platformPreferences, save ...func()) *Adapter

func (*Adapter) Configured

func (a *Adapter) Configured() bool

func (*Adapter) FetchArtwork

func (a *Adapter) FetchArtwork(ctx context.Context, ref string, size int) ([]byte, bool, error)

func (*Adapter) Home

func (a *Adapter) Home() *Home

func (*Adapter) OwnsTrack

func (a *Adapter) OwnsTrack(tr *pluginapi.Track) bool

func (*Adapter) PlaybackMedia

func (a *Adapter) PlaybackMedia() pluginapi.PlaybackMedia

type CardView

type CardView struct {
	Title          string
	Sub            string
	Count          int
	Header         func(*ui.Context)
	HeaderSkeleton func(*ui.Context)
	OnOpen         func(int64)
	OnPlay         func(int64)
	// Meta reserves the card's secondary line in its loading skeleton.
	Meta bool
	// Round draws an artist's round photo over the name, with no play.
	Round       bool
	Placeholder *ui.SVG
	Art         func(*ui.Painter, ui.Rect, *pluginapi.Playlist, float32)
}

type Catalog

type Catalog struct {
	Session *State

	Post     func(func())
	OnTracks func([]pluginapi.Track)

	Lists                       map[int64]*List
	Meta                        map[int64]pluginapi.Playlist
	SearchList                  *List
	SearchAlbums, SearchArtists *paging.Pager[pluginapi.Playlist]
	Albums, Artists, Genres     *paging.Pager[pluginapi.Playlist]
	ArtistAlbums                map[int64]*paging.Pager[pluginapi.Playlist]

	LibrarySort, FavoriteSort, AlbumSort, AlbumDetailSort string
	ArtistSort, ArtistTrackSort, ArtistAlbumSort          string
	GenreSort, GenreTrackSort                             string
	// contains filtered or unexported fields
}

Catalog owns list and card state for one Feiniu session.

func NewCatalog

func NewCatalog(session *State, post func(func())) *Catalog

NewCatalog creates empty platform catalog state.

func (*Catalog) AlbumsList

func (c *Catalog) AlbumsList() *paging.Pager[pluginapi.Playlist]

func (*Catalog) ArtistAlbumsList

func (c *Catalog) ArtistAlbumsList(id int64, ref string) *paging.Pager[pluginapi.Playlist]

ArtistAlbumsList is the albums of one artist, in the order of ArtistAlbumSort.

func (*Catalog) ArtistsList

func (c *Catalog) ArtistsList() *paging.Pager[pluginapi.Playlist]

func (*Catalog) FavoriteChanged

func (c *Catalog) FavoriteChanged(id int64, liked bool)

FavoriteChanged drops or updates the cached favorites list after a successful like change.

func (*Catalog) GenresList

func (c *Catalog) GenresList() *paging.Pager[pluginapi.Playlist]

GenresList is the style cards, in the order of GenreSort.

func (*Catalog) ListFor

func (c *Catalog) ListFor(id int64) *List

ListFor returns or constructs the list represented by id.

func (*Catalog) ListForRoute

func (c *Catalog) ListForRoute(id int64, kind, ref string) *List

ListForRoute resolves a card using the provider-neutral route metadata. Cards carry a stable app ID for rendering, while Ref preserves the service identifier needed when the card's metadata has not reached Catalog.Meta yet (for example immediately after a reconnect).

func (*Catalog) NewList

func (c *Catalog) NewList(spec Spec) *List

NewList builds a list from a service-neutral spec.

func (*Catalog) Refresh

func (c *Catalog) Refresh(id int64)

Refresh drops one list so the next view asks the service again.

func (*Catalog) RemoveFavorite

func (c *Catalog) RemoveFavorite(id int64) bool

RemoveFavorite takes a song out of the loaded favorites list without refetching every page.

func (*Catalog) Search

func (c *Catalog) Search(query string) error

Search creates the song, album and artist catalogs for one query.

type Home

type Home struct {
	// contains filtered or unexported fields
}

Home owns the Feiniu navigation and page selection. It deliberately does not know the root app's route type or render implementation.

func NewHome

func NewHome(state *State, host Host, runtimes ...*RuntimeAdapter) *Home

func (*Home) Back

func (h *Home) Back()

func (*Home) CanBack

func (h *Home) CanBack() bool

func (*Home) CanForward

func (h *Home) CanForward() bool

func (*Home) CloseTransient

func (h *Home) CloseTransient()

func (*Home) Content

func (h *Home) Content(c *ui.Context)

func (*Home) Forward

func (h *Home) Forward()

func (*Home) Open

func (h *Home) Open(route Route)

func (*Home) ReportStarted

func (h *Home) ReportStarted(tr *pluginapi.Track)

func (*Home) RequestAddList

func (h *Home) RequestAddList(pl pluginapi.Playlist, l *List)

func (*Home) RequestAddTracks

func (h *Home) RequestAddTracks(pl pluginapi.Playlist, tracks []pluginapi.Track)

func (*Home) RequestChangeCover

func (h *Home) RequestChangeCover(pl pluginapi.Playlist)

func (*Home) RequestDelete

func (h *Home) RequestDelete(pl pluginapi.Playlist)

func (*Home) RequestFavorite

func (h *Home) RequestFavorite(tr pluginapi.Track, liked bool)

func (*Home) RequestNewPlaylist

func (h *Home) RequestNewPlaylist(tracks []pluginapi.Track)

func (*Home) RequestNewPlaylistFrom

func (h *Home) RequestNewPlaylistFrom(l *List)

func (*Home) RequestRemoveTrack

func (h *Home) RequestRemoveTrack(pl pluginapi.Playlist, tr pluginapi.Track)

func (*Home) RequestRename

func (h *Home) RequestRename(pl pluginapi.Playlist)

func (*Home) ResetNavigation

func (h *Home) ResetNavigation(route Route)

ResetNavigation selects a platform page without carrying navigation from a previous connection or platform session.

func (*Home) Route

func (h *Home) Route() Route

func (*Home) SearchText

func (h *Home) SearchText() *string

func (*Home) Settings

func (h *Home) Settings(c *ui.Context)

func (*Home) State

func (h *Home) State() *State

type Host

type Host = appplatform.Services

Host provides the desktop and playback services used by the plugin.

type List

type List struct {
	ID         int64
	Spec       Spec
	Kind       string
	HeaderKind string
	Name       string
	Sub        string
	CoverURL   string
	Pages      *paging.Pager[pluginapi.Track]
	// contains filtered or unexported fields
}

List is a lazily loaded Feiniu catalog. Its pager is platform state, not UI state, so a view can be rebuilt without losing loaded pages.

func (*List) Cover

func (l *List) Cover() string

func (*List) Refresh

func (l *List) Refresh()

Refresh asks for the current list again instead of trusting its loaded pages. Retry alone only touches failed pages and leaves cached rows in place.

func (*List) SetSort

func (l *List) SetSort(sort string)

SetSort changes the order of a loaded list without dropping its geometry.

type ListKind

type ListKind string

ListKind describes a Feiniu catalog at the data layer. It does not select a UI; the platform home chooses how to present each list.

const (
	ListLibrary   ListKind = "library"
	ListFavorites ListKind = "favorites"
	ListRecent    ListKind = "recent"
	ListPlaylist  ListKind = "playlist"
	ListAlbum     ListKind = "album"
	ListArtist    ListKind = "artist"
	ListSearch    ListKind = "search"
	ListGenre     ListKind = "genre"
)

type Page

type Page = string

Page identifies a route owned by a platform UI. The root app translates it to its shared route type; the platform package never imports that type.

const (
	PageLibrary       Page = "library"
	PageSearch        Page = "search"
	PageSearchAlbums  Page = "search-albums"
	PageSearchArtists Page = "search-artists"
	PageAlbums        Page = "albums"
	PageArtists       Page = "artists"
	PageArtistAlbums  Page = "artist-albums"
	PagePlaylist      Page = "playlist"
	PageRoam          Page = "roam"
	PageFolders       Page = "folders"
	PageGenres        Page = "genres"
)

type PlayerPort

type PlayerPort = appplatform.PlayerPort

PlayerPort is the shared playback seam used by platform queue actions. The concrete player remains in the root app.

type Route

type Route struct {
	Page  Page
	ID    int64
	Query string
	Kind  string
}

Route is the small navigation value exchanged between a platform view and the root app. It deliberately contains no UI elements or app internals.

func ArtistSongsRoute

func ArtistSongsRoute(id int64, ref string) Route

func FavoritesRoute

func FavoritesRoute() Route

type RuntimeAdapter

type RuntimeAdapter struct {
	// contains filtered or unexported fields
}

RuntimeAdapter translates the generic application seam into Feiniu's protocol configuration and lifecycle. No Feiniu client type escapes this package.

func NewRuntime

func NewRuntime(state *State, settings *platformPreferences, save ...func()) *RuntimeAdapter

func (*RuntimeAdapter) Cancel

func (r *RuntimeAdapter) Cancel(context.Context) error

func (*RuntimeAdapter) Config

func (r *RuntimeAdapter) Config() connectionConfig

func (*RuntimeAdapter) Configured

func (r *RuntimeAdapter) Configured() bool

func (*RuntimeAdapter) Connect

func (r *RuntimeAdapter) Connect(ctx context.Context, cfg connectionConfig) error

func (*RuntimeAdapter) Connected

func (r *RuntimeAdapter) Connected() bool

func (*RuntimeAdapter) Disconnect

func (r *RuntimeAdapter) Disconnect(ctx context.Context) error

func (*RuntimeAdapter) Error

func (r *RuntimeAdapter) Error() error

func (*RuntimeAdapter) FetchArtwork

func (r *RuntimeAdapter) FetchArtwork(ctx context.Context, raw string, size int) ([]byte, bool, error)

func (*RuntimeAdapter) SetConfig

func (r *RuntimeAdapter) SetConfig(cfg connectionConfig)

func (*RuntimeAdapter) SetSort

func (r *RuntimeAdapter) SetSort(key, value string)

func (*RuntimeAdapter) SetTranscode

func (r *RuntimeAdapter) SetTranscode(v transcodeSettings)

func (*RuntimeAdapter) Sorts

func (r *RuntimeAdapter) Sorts() map[string]string

func (*RuntimeAdapter) Transcode

func (r *RuntimeAdapter) Transcode() transcodeSettings

func (*RuntimeAdapter) TranscodeBitrates

func (r *RuntimeAdapter) TranscodeBitrates() []int

type SearchResults

type SearchResults struct {
	Query   string
	Songs   *paging.Pager[pluginapi.Track]
	Albums  *paging.Pager[pluginapi.Playlist]
	Artists *paging.Pager[pluginapi.Playlist]
}

type SearchView

type SearchView struct {
	Play      func(int)
	PlayCard  func(int64)
	TrackMenu func(*ui.Menu, *pluginapi.Track, int64)
	Liked     func(int64) bool
	Favorite  func(pluginapi.Track, bool)
	OpenList  func(int64)
	OpenCards func(string)
}

type Spec

type Spec struct {
	Kind  ListKind
	Ref   string
	Query string
	Sort  string
}

Spec identifies a service list without referring to a root app route.

type State

type State struct {
	// contains filtered or unexported fields
}

State is the part of a Feiniu session that belongs to the platform. It is deliberately independent of windows, routes, MyGo UI elements and the shared player; the root app supplies those through a Host when rendering.

func NewState

func NewState() *State

NewState returns an empty disconnected platform session.

func (*State) AddToPlaylist

func (s *State) AddToPlaylist(ctx context.Context, pl pluginapi.Playlist, tracks []pluginapi.Track) error

func (*State) Attach

func (s *State) Attach(client *backend.Client) error

Attach makes client the active session. It does not connect or log in; the caller controls that lifecycle and can publish the result through Host.

func (*State) Cancel

func (s *State) Cancel()

Cancel invalidates in-flight platform work without logging out the active client. The owner uses it when switching away from this platform.

func (*State) Catalog

func (s *State) Catalog() *Catalog

Catalog returns the platform-owned lazy catalog state.

func (*State) ChangePlaylistCover

func (s *State) ChangePlaylistCover(ctx context.Context, pl pluginapi.Playlist, picture []byte) (string, error)

func (*State) CheckContext

func (s *State) CheckContext(ctx context.Context) error

CheckContext lets asynchronous platform jobs reject stale or canceled work before invoking a backend operation.

func (*State) Client

func (s *State) Client() *backend.Client

Client returns the current backend client, if connected.

func (*State) Config

func (s *State) Config() backend.Config

Config returns the non-secret connection settings for this platform.

func (*State) Connected

func (s *State) Connected() bool

Connected reports whether a client is attached.

func (*State) Connecting

func (s *State) Connecting() bool

Connecting reports an automatic or manual login that has not published its final catalog state yet. The home uses this to keep a loading surface up instead of flashing the connection form.

func (*State) CreatePlaylist

func (s *State) CreatePlaylist(ctx context.Context, name string) (pluginapi.Playlist, error)

CreatePlaylist creates a playlist and publishes it in account state.

func (*State) DeletePlaylist

func (s *State) DeletePlaylist(ctx context.Context, pl pluginapi.Playlist) error

func (*State) Detach

func (s *State) Detach() *backend.Client

Detach clears the active session and returns its client for logout. The platform state is reset together, so a later login cannot see stale lists.

func (*State) Error

func (s *State) Error() error

Error returns the latest connection or account error.

func (*State) FetchArtwork

func (s *State) FetchArtwork(ctx context.Context, raw string, size int) (data []byte, handled bool, err error)

FetchArtwork handles only resources owned by this platform. Returning handled=false lets the shared app keep its normal NetEase fetch path without knowing platform URL schemes.

func (*State) FolderViewEnabled

func (s *State) FolderViewEnabled() bool

FolderViewEnabled reports the server capability after a successful connection. Unknown capabilities are treated as unavailable so older Feiniu Music versions do not expose a broken route.

func (*State) Generation

func (s *State) Generation() uint64

Generation identifies the current connection session. UI actions capture it before starting asynchronous work and ignore completions after a reconnect, disconnect or platform switch.

func (*State) LikeBusy

func (s *State) LikeBusy(id int64) bool

LikeBusy reports whether a like operation is in flight for id.

func (*State) Liked

func (s *State) Liked(id int64) bool

Liked reports the optimistic liked state of a track.

func (*State) LikedTrack

func (s *State) LikedTrack(tr *pluginapi.Track) bool

LikedTrack reports the optimistic liked state for a provider track.

func (*State) LoadPlaylists

func (s *State) LoadPlaylists(ctx context.Context) ([]pluginapi.Playlist, error)

LoadPlaylists reads the account playlists through the platform provider and stores a private copy in the session.

func (*State) NextRoam

func (s *State) NextRoam(ctx context.Context) (pluginapi.Track, error)

NextRoam advances the service roaming cursor.

func (*State) Playlist

func (s *State) Playlist(id int64) (pluginapi.Playlist, bool)

Playlist returns a copy of an account playlist. Copies keep callers from mutating session state while a request is in flight.

func (*State) Playlists

func (s *State) Playlists() []pluginapi.Playlist

Playlists returns a copy of the account playlists held by this session.

func (*State) Provider

func (s *State) Provider() *backend.Provider

Provider returns the shared platform adapter for the current session.

func (*State) RemoveFromHistory

func (s *State) RemoveFromHistory(ctx context.Context, tr pluginapi.Track) error

RemoveFromHistory removes one entry from the server play history and keeps the operation tied to the session that issued it.

func (*State) RemoveFromPlaylist

func (s *State) RemoveFromPlaylist(ctx context.Context, pl pluginapi.Playlist, tr pluginapi.Track) error

func (*State) RenamePlaylist

func (s *State) RenamePlaylist(ctx context.Context, pl pluginapi.Playlist, name string) error

func (*State) ReportPlay

func (s *State) ReportPlay(ctx context.Context, tr *pluginapi.Track) error

ReportPlay records a started track in the service's play history.

func (*State) RoamID

func (s *State) RoamID() string

func (*State) SetConfig

func (s *State) SetConfig(cfg backend.Config)

SetConfig stores non-secret connection settings without connecting.

func (*State) SetError

func (s *State) SetError(err error)

SetError records an account or connection error without coupling the platform package to the root app's toast and error presentation.

func (*State) SetFavorite

func (s *State) SetFavorite(ctx context.Context, tr *pluginapi.Track, liked bool) error

SetFavorite updates the optimistic state and persists the change through the platform backend. A failed request rolls the optimistic state back.

func (*State) SetLiked

func (s *State) SetLiked(id int64, liked bool)

SetLiked updates the optimistic liked state.

func (*State) SetPlaylists

func (s *State) SetPlaylists(lists []pluginapi.Playlist)

SetPlaylists replaces the account playlists with a copy owned by State.

func (*State) SetPost

func (s *State) SetPost(post func(func()))

SetPost supplies the owner goroutine used by catalog page completions.

func (*State) SetRoamID

func (s *State) SetRoamID(id string)

SetRoamID and RoamID keep the service's roaming cursor in platform state.

func (*State) StartRoam

func (s *State) StartRoam(ctx context.Context) (pluginapi.Track, error)

StartRoam asks the service for the first roaming track and records its cursor in the platform session.

type TrackView

type TrackView struct {
	Title          string
	Sub            string
	Cover          string
	OnPlay         func(int)
	Header         func(*ui.Context)
	HeaderSkeleton func(*ui.Context)
	Menu           func(*ui.Menu, *pluginapi.Track, int64)
	Liked          func(int64) bool
	Favorite       func(pluginapi.Track, bool)
	ShowAlbum      bool
}

Directories

Path Synopsis
internal
scripts
hls-probe command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL