update package name

This commit is contained in:
aynakeya
2024-04-09 05:33:38 -07:00
parent ec74a21f78
commit ee87ff3f7b
25 changed files with 90 additions and 24 deletions

24
api.go
View File

@@ -1,5 +1,29 @@
package miaosic package miaosic
func SearchByProvider(provider string, keyword string, page, size int) ([]MediaInfo, error) {
p, ok := GetProvider(provider)
if !ok {
return nil, ErrorNoSuchProvider
}
return p.Search(keyword, page, size)
}
func GetMediaUrl(meta MetaData, quality Quality) ([]MediaUrl, error) {
provider, ok := GetProvider(meta.Provider)
if !ok {
return nil, ErrorNoSuchProvider
}
return provider.GetMediaUrl(meta, quality)
}
func GetMediaInfo(meta MetaData) (MediaInfo, error) {
provider, ok := GetProvider(meta.Provider)
if !ok {
return MediaInfo{}, ErrorNoSuchProvider
}
return provider.GetMediaInfo(meta)
}
//func GetPlaylist(meta *model.Meta) ([]*model.Media, error) { //func GetPlaylist(meta *model.Meta) ([]*model.Media, error) {
// if v, ok := Providers[meta.Name]; ok { // if v, ok := Providers[meta.Name]; ok {
// return v.GetPlaylist(meta) // return v.GetPlaylist(meta)

2
go.mod
View File

@@ -1,4 +1,4 @@
module miaosic module github.com/AynaLivePlayer/miaosic
go 1.20 go 1.20

View File

@@ -60,10 +60,27 @@ type MediaInfo struct {
type Playlist struct { type Playlist struct {
Title string Title string
Medias []*MediaInfo Medias []MediaInfo
Meta MetaData Meta MetaData
} }
func (p *Playlist) DisplayName() string {
if p.Title != "" {
return p.Title
}
return p.Meta.ID()
}
func (p *Playlist) Copy() Playlist {
medias := make([]MediaInfo, len(p.Medias))
copy(medias, p.Medias)
return Playlist{
Title: p.Title,
Medias: medias,
Meta: p.Meta,
}
}
type MediaProvider interface { type MediaProvider interface {
// GetName returns the name of the provider. // GetName returns the name of the provider.
GetName() string GetName() string

View File

@@ -1,11 +1,11 @@
package bilibili package bilibili
import ( import (
"github.com/AynaLivePlayer/miaosic"
"github.com/AynaLivePlayer/miaosic/providers"
"github.com/aynakeya/deepcolor" "github.com/aynakeya/deepcolor"
"github.com/aynakeya/deepcolor/dphttp" "github.com/aynakeya/deepcolor/dphttp"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"miaosic"
"miaosic/providers"
"regexp" "regexp"
) )

View File

@@ -1,8 +1,8 @@
package bilibili package bilibili
import ( import (
"github.com/AynaLivePlayer/miaosic"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"miaosic"
"testing" "testing"
) )

View File

@@ -1,7 +1,7 @@
package bilibili package bilibili
import ( import (
"miaosic" "github.com/AynaLivePlayer/miaosic"
) )
func init() { func init() {

View File

@@ -1,6 +1,6 @@
package bilibili package bilibili
import "miaosic" import "github.com/AynaLivePlayer/miaosic"
func (n *Bilibili) MatchPlaylist(uri string) (miaosic.MetaData, bool) { func (n *Bilibili) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
return miaosic.MetaData{}, false return miaosic.MetaData{}, false

View File

@@ -3,13 +3,13 @@ package bilivideo
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/AynaLivePlayer/miaosic"
"github.com/AynaLivePlayer/miaosic/providers"
"github.com/aynakeya/deepcolor" "github.com/aynakeya/deepcolor"
"github.com/aynakeya/deepcolor/dphttp" "github.com/aynakeya/deepcolor/dphttp"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/spf13/cast" "github.com/spf13/cast"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"miaosic"
"miaosic/providers"
"regexp" "regexp"
) )

View File

@@ -1,9 +1,9 @@
package bilivideo package bilivideo
import ( import (
"github.com/AynaLivePlayer/miaosic"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"miaosic"
"regexp" "regexp"
"strings" "strings"
"testing" "testing"

View File

@@ -0,0 +1,7 @@
package bilivideo
import "github.com/AynaLivePlayer/miaosic"
func init() {
miaosic.RegisterProvider(NewBilibiliViedo())
}

View File

@@ -1,6 +1,6 @@
package bilivideo package bilivideo
import "miaosic" import "github.com/AynaLivePlayer/miaosic"
func (n *BilibiliVideo) MatchPlaylist(uri string) (miaosic.MetaData, bool) { func (n *BilibiliVideo) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
return miaosic.MetaData{}, false return miaosic.MetaData{}, false

7
providers/kuwo/init.go Normal file
View File

@@ -0,0 +1,7 @@
package kuwo
import "github.com/AynaLivePlayer/miaosic"
func init() {
miaosic.RegisterProvider(NewKuwo())
}

View File

@@ -2,6 +2,8 @@ package kuwo
import ( import (
"fmt" "fmt"
"github.com/AynaLivePlayer/miaosic"
"github.com/AynaLivePlayer/miaosic/providers"
"github.com/aynakeya/deepcolor" "github.com/aynakeya/deepcolor"
"github.com/aynakeya/deepcolor/dphttp" "github.com/aynakeya/deepcolor/dphttp"
"github.com/spf13/cast" "github.com/spf13/cast"
@@ -9,8 +11,6 @@ import (
"html" "html"
"math" "math"
"math/rand" "math/rand"
"miaosic"
"miaosic/providers"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"

View File

@@ -1,9 +1,9 @@
package kuwo package kuwo
import ( import (
"github.com/AynaLivePlayer/miaosic"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"miaosic"
"testing" "testing"
) )

View File

@@ -1,6 +1,6 @@
package kuwo package kuwo
import "miaosic" import "github.com/AynaLivePlayer/miaosic"
func (n *Kuwo) MatchPlaylist(uri string) (miaosic.MetaData, bool) { func (n *Kuwo) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
return miaosic.MetaData{}, false return miaosic.MetaData{}, false

View File

@@ -1,7 +1,7 @@
package local package local
import ( import (
"miaosic" "github.com/AynaLivePlayer/miaosic"
"os" "os"
"path" "path"
"strings" "strings"

View File

@@ -1,9 +1,9 @@
package local package local
import ( import (
"github.com/AynaLivePlayer/miaosic"
"github.com/dhowden/tag" "github.com/dhowden/tag"
"github.com/sahilm/fuzzy" "github.com/sahilm/fuzzy"
"miaosic"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"

View File

@@ -2,8 +2,8 @@ package local
import ( import (
"fmt" "fmt"
"github.com/AynaLivePlayer/miaosic"
"github.com/sahilm/fuzzy" "github.com/sahilm/fuzzy"
"miaosic"
"sort" "sort"
"strings" "strings"
"testing" "testing"

View File

@@ -0,0 +1,11 @@
package local
import "github.com/AynaLivePlayer/miaosic"
func (l *localPlaylist) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
return miaosic.MetaData{}, false
}
func (l *localPlaylist) GetPlaylist(meta miaosic.MetaData) (*miaosic.Playlist, error) {
return nil, miaosic.ErrNotImplemented
}

View File

@@ -1,6 +1,6 @@
package netease package netease
import "miaosic" import "github.com/AynaLivePlayer/miaosic"
func init() { func init() {
miaosic.RegisterProvider(NewNetease()) miaosic.RegisterProvider(NewNetease())

View File

@@ -4,8 +4,8 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/AynaLivePlayer/miaosic"
neteaseApi "github.com/XiaoMengXinX/Music163Api-Go/api" neteaseApi "github.com/XiaoMengXinX/Music163Api-Go/api"
"miaosic"
"net/http" "net/http"
) )

View File

@@ -1,11 +1,11 @@
package netease package netease
import ( import (
"github.com/AynaLivePlayer/miaosic"
neteaseApi "github.com/XiaoMengXinX/Music163Api-Go/api" neteaseApi "github.com/XiaoMengXinX/Music163Api-Go/api"
neteaseTypes "github.com/XiaoMengXinX/Music163Api-Go/types" neteaseTypes "github.com/XiaoMengXinX/Music163Api-Go/types"
neteaseUtil "github.com/XiaoMengXinX/Music163Api-Go/utils" neteaseUtil "github.com/XiaoMengXinX/Music163Api-Go/utils"
"github.com/spf13/cast" "github.com/spf13/cast"
"miaosic"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"

View File

@@ -1,8 +1,8 @@
package netease package netease
import ( import (
"github.com/AynaLivePlayer/miaosic"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"miaosic"
"strings" "strings"
"testing" "testing"
) )

View File

@@ -1,6 +1,6 @@
package netease package netease
import "miaosic" import "github.com/AynaLivePlayer/miaosic"
func (n *Netease) MatchPlaylist(uri string) (miaosic.MetaData, bool) { func (n *Netease) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
return miaosic.MetaData{}, false return miaosic.MetaData{}, false

View File

@@ -1,8 +1,8 @@
package providers package providers
import ( import (
"github.com/AynaLivePlayer/miaosic"
"github.com/aynakeya/deepcolor/dphttp" "github.com/aynakeya/deepcolor/dphttp"
"miaosic"
) )
type FileApiParam struct { type FileApiParam struct {