From 466e4a761efc8bc2d6d7db08e39bfc374c95d500 Mon Sep 17 00:00:00 2001 From: aynakeya Date: Thu, 31 Jul 2025 00:32:22 +0800 Subject: [PATCH] add nosource --- .github/workflows/build.yml | 12 ++++++ README.md | 22 +++++++++++ gui/gui.go | 2 +- internal/controller/controller.go | 4 +- internal/player/mpv/mpv.go | 4 ++ internal/player/vlc/vlc.go | 4 ++ internal/source/dummy.go | 61 +++++++++++++++++++++++++++++++ internal/source/nosource.go | 37 +++++++++++++++++++ internal/source/source.go | 5 +-- pkg/config/config.go | 2 +- pkg/config/config_general.go | 46 +++++++++++------------ plugin/diange/diange.go | 4 ++ 12 files changed, 172 insertions(+), 31 deletions(-) create mode 100644 internal/source/dummy.go create mode 100644 internal/source/nosource.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 162b274..22c8b6d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,10 +63,22 @@ jobs: - name: Build application run: | + go build -tags=mpvOnly,nosource -v -o ./AynaLivePlayerMpvNoSource.exe -ldflags -H=windowsgui app/main.go + go build -tags=vlcOnly,nosource -v -o ./AynaLivePlayerVlcNoSource.exe -ldflags -H=windowsgui app/main.go + go build -tags=nosource -v -o ./AynaLivePlayerAllPlayerNoSource.exe -ldflags -H=windowsgui app/main.go go build -tags=mpvOnly -v -o ./AynaLivePlayerMpv.exe -ldflags -H=windowsgui app/main.go go build -tags=vlcOnly -v -o ./AynaLivePlayerVlc.exe -ldflags -H=windowsgui app/main.go go build -v -o ./AynaLivePlayerAllPlayer.exe -ldflags -H=windowsgui app/main.go + - name: Upload artifact (NoSource) + uses: actions/upload-artifact@v4 + with: + name: windows-build-nosource + path: | + ./AynaLivePlayerMpvNoSource.exe + ./AynaLivePlayerVlcNoSource.exe + ./AynaLivePlayerAllPlayerNoSource.exe + - name: Upload artifact uses: actions/upload-artifact@v4 with: diff --git a/README.md b/README.md index 32bd52f..a1c3fc4 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,28 @@ Provider By Aynakeya QQ group: 621035845 +## Disclaimer + +All APIs used in this project are **publicly available** on the internet and not obtained through illegal means such as +reverse engineering. + +The use of this project may involve access to copyrighted content. This project does **not** own or claim any rights to +such content. **To avoid potential infringement**, all users are **required to delete any copyrighted data obtained +through this project within 24 hours.** + +Any direct, indirect, special, incidental, or consequential damages (including but not limited to loss of goodwill, work +stoppage, computer failure or malfunction, or any and all other commercial damages or losses) that arise from the use or +inability to use this project are **solely the responsibility of the user**. + +This project is completely free and open-source, published on GitHub for global users for **technical learning and +research purposes only**. This project does **not** guarantee compliance with local laws or regulations in all +jurisdictions. + +**Using this project in violation of local laws is strictly prohibited.** Any legal consequences arising from +intentional or unintentional violations are the user's responsibility. The project maintainers accept **no liability** +for such outcomes. + + ## build diff --git a/gui/gui.go b/gui/gui.go index e14ffb4..c027acf 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -40,7 +40,7 @@ func Initialize() { } App = app.NewWithID(config.ProgramName) //App.Settings().SetTheme(&myTheme{}) - MainWindow = App.NewWindow(fmt.Sprintf("%s Ver %s-%s", config.ProgramName, model.Version(config.Version), config.General.DistributionChannel)) + MainWindow = App.NewWindow(fmt.Sprintf("%s Ver %s", config.ProgramName, model.Version(config.Version))) tabs := container.NewAppTabs( container.NewTabItem(i18n.T("gui.tab.player"), diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 334c7b8..9fc9ec5 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -39,7 +39,7 @@ func handlePlayNext() { events.PlaylistInsertUpdate(model.PlaylistIDPlayer), "internal.controller.playcontrol.playnext_when_insert.player", func(event *event.Event) { - if isIdle { + if isIdle && config.General.PlayNextOnFail { global.EventManager.CallA(events.PlayerPlayNextCmd, events.PlayerPlayNextCmdEvent{}) } @@ -49,7 +49,7 @@ func handlePlayNext() { events.PlaylistInsertUpdate(model.PlaylistIDSystem), "internal.controller.playcontrol.playnext_when_insert.system", func(event *event.Event) { - if isIdle { + if isIdle && config.General.PlayNextOnFail { global.EventManager.CallA(events.PlayerPlayNextCmd, events.PlayerPlayNextCmdEvent{}) } diff --git a/internal/player/mpv/mpv.go b/internal/player/mpv/mpv.go index e0b0db0..9cbeeda 100644 --- a/internal/player/mpv/mpv.go +++ b/internal/player/mpv/mpv.go @@ -195,6 +195,10 @@ func registerCmdHandler() { mediaUrls, err := miaosic.GetMediaUrl(mediaInfo.Meta, miaosic.QualityAny) if err != nil || len(mediaUrls) == 0 { log.Warn("[MPV PlayControl] get media url failed ", mediaInfo.Meta.ID(), err) + global.EventManager.CallA(events.PlayerPlayingUpdate, events.PlayerPlayingUpdateEvent{ + Media: evnt.Data.(events.PlayerPlayCmdEvent).Media, + Removed: false, + }) global.EventManager.CallA( events.PlayerPlayErrorUpdate, events.PlayerPlayErrorUpdateEvent{ diff --git a/internal/player/vlc/vlc.go b/internal/player/vlc/vlc.go index 59b28ef..38dc921 100644 --- a/internal/player/vlc/vlc.go +++ b/internal/player/vlc/vlc.go @@ -223,6 +223,10 @@ func registerCmdHandler() { mediaUrls, err := miaosic.GetMediaUrl(mediaInfo.Meta, miaosic.QualityAny) if err != nil || len(mediaUrls) == 0 { log.Warn("[VLC PlayControl] get media url failed ", mediaInfo.Meta.ID(), err) + global.EventManager.CallA(events.PlayerPlayingUpdate, events.PlayerPlayingUpdateEvent{ + Media: evnt.Data.(events.PlayerPlayCmdEvent).Media, + Removed: false, + }) global.EventManager.CallA( events.PlayerPlayErrorUpdate, events.PlayerPlayErrorUpdateEvent{ diff --git a/internal/source/dummy.go b/internal/source/dummy.go new file mode 100644 index 0000000..51411bb --- /dev/null +++ b/internal/source/dummy.go @@ -0,0 +1,61 @@ +package source + +import ( + "github.com/AynaLivePlayer/miaosic" +) + +type dummySource struct{} + +func (d *dummySource) GetName() string { + return "dummy" +} + +func (d *dummySource) Qualities() []miaosic.Quality { + return []miaosic.Quality{} +} + +func (d *dummySource) Search(keyword string, page, size int) ([]miaosic.MediaInfo, error) { + return []miaosic.MediaInfo{ + miaosic.MediaInfo{ + Title: keyword, + Artist: "Unknown", + Album: "Unknown", + Meta: miaosic.MetaData{ + Provider: "dummy", + Identifier: keyword, + }, + }, + }, nil +} + +func (d *dummySource) MatchMedia(uri string) (miaosic.MetaData, bool) { + return miaosic.MetaData{}, false +} + +func (d *dummySource) GetMediaInfo(meta miaosic.MetaData) (miaosic.MediaInfo, error) { + return miaosic.MediaInfo{ + Title: meta.Identifier, + Artist: "Unknown", + Album: "Unknown", + Meta: miaosic.MetaData{ + Provider: "dummy", + Identifier: meta.Identifier, + }, + }, nil +} + +func (d *dummySource) GetMediaUrl(meta miaosic.MetaData, quality miaosic.Quality) ([]miaosic.MediaUrl, error) { + return []miaosic.MediaUrl{}, miaosic.ErrNotImplemented +} + +func (d *dummySource) GetMediaLyric(meta miaosic.MetaData) ([]miaosic.Lyrics, error) { + return []miaosic.Lyrics{}, miaosic.ErrNotImplemented +} + +func (d *dummySource) MatchPlaylist(uri string) (miaosic.MetaData, bool) { + return miaosic.MetaData{}, false +} + +func (d *dummySource) GetPlaylist(meta miaosic.MetaData) (*miaosic.Playlist, error) { + return &miaosic.Playlist{}, miaosic.ErrNotImplemented +} diff --git a/internal/source/nosource.go b/internal/source/nosource.go new file mode 100644 index 0000000..c17f2ce --- /dev/null +++ b/internal/source/nosource.go @@ -0,0 +1,37 @@ +//go:build nosource + +package source + +import ( + "AynaLivePlayer/core/events" + "AynaLivePlayer/global" + "AynaLivePlayer/pkg/config" + "github.com/AynaLivePlayer/miaosic" +) + +type _sourceConfig struct { + LocalSourcePath string +} + +func (_ _sourceConfig) Name() string { + return "Source" +} + +func (_ _sourceConfig) OnLoad() { +} + +func (_ _sourceConfig) OnSave() { +} + +var sourceCfg = &_sourceConfig{ + LocalSourcePath: "./music", +} + +func Initialize() { + config.LoadConfig(sourceCfg) + miaosic.RegisterProvider(&dummySource{}) + global.EventManager.CallA( + events.MediaProviderUpdate, events.MediaProviderUpdateEvent{ + Providers: miaosic.ListAvailableProviders(), + }) +} diff --git a/internal/source/source.go b/internal/source/source.go index cf80401..ade462a 100644 --- a/internal/source/source.go +++ b/internal/source/source.go @@ -1,3 +1,5 @@ +//go:build !nosource + package source import ( @@ -34,9 +36,6 @@ var sourceCfg = &_sourceConfig{ func Initialize() { config.LoadConfig(sourceCfg) kugou.UseInstrumental() - if config.General.DistributionChannel != "github" { - miaosic.UnregisterAllProvider() - } miaosic.RegisterProvider(local.NewLocal(sourceCfg.LocalSourcePath)) global.EventManager.CallA( diff --git a/pkg/config/config.go b/pkg/config/config.go index a62126d..35f00bc 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -10,7 +10,7 @@ import ( const ( ProgramName = "卡西米尔唱片机" - Version uint32 = 0x010200 + Version uint32 = 0x010201 ) const ( diff --git a/pkg/config/config_general.go b/pkg/config/config_general.go index d5f5f6a..c49b829 100644 --- a/pkg/config/config_general.go +++ b/pkg/config/config_general.go @@ -2,18 +2,17 @@ package config type _GeneralConfig struct { BaseConfig - Width float32 - Height float32 - Language string - InfoApiServer string - AutoCheckUpdate bool - ShowSystemTray bool - PlayNextOnFail bool - UseSystemPlaylist bool - FixedSize bool - EnableSMC bool // enable system media control - CustomFonts string // use custom fonts, under ./assets file - DistributionChannel string // app distribution channel, default fanfan + Width float32 + Height float32 + Language string + InfoApiServer string + AutoCheckUpdate bool + ShowSystemTray bool + PlayNextOnFail bool + UseSystemPlaylist bool + FixedSize bool + EnableSMC bool // enable system media control + CustomFonts string // use custom fonts, under ./assets file } func (c *_GeneralConfig) Name() string { @@ -21,16 +20,15 @@ func (c *_GeneralConfig) Name() string { } var General = &_GeneralConfig{ - Language: "zh-CN", - ShowSystemTray: false, - InfoApiServer: "http://localhost:9090", - AutoCheckUpdate: true, - Width: 960, - Height: 480, - PlayNextOnFail: false, - UseSystemPlaylist: true, - FixedSize: true, - EnableSMC: true, - CustomFonts: "", - DistributionChannel: "fanfan", + Language: "zh-CN", + ShowSystemTray: false, + InfoApiServer: "http://localhost:9090", + AutoCheckUpdate: true, + Width: 960, + Height: 480, + PlayNextOnFail: false, + UseSystemPlaylist: true, + FixedSize: true, + EnableSMC: true, + CustomFonts: "", } diff --git a/plugin/diange/diange.go b/plugin/diange/diange.go index fc31010..9e12144 100644 --- a/plugin/diange/diange.go +++ b/plugin/diange/diange.go @@ -410,7 +410,11 @@ func (d *Diange) CreatePanel() fyne.CanvasObject { skipPlaylistCheck, ) sourceCfgs := []fyne.CanvasObject{} + prvdrs := miaosic.ListAvailableProviders() for source, cfg := range d.sourceConfigs { + if !slices.Contains(prvdrs, source) { + continue + } sourceCfgs = append( sourceCfgs, container.NewGridWithColumns(2, widget.NewLabel(source),