mirror of
https://github.com/AynaLivePlayer/miaosic.git
synced 2025-12-14 08:48:12 +08:00
update package name
This commit is contained in:
24
api.go
24
api.go
@@ -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
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module miaosic
|
module github.com/AynaLivePlayer/miaosic
|
||||||
|
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
|
|||||||
19
miaosic.go
19
miaosic.go
@@ -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
|
||||||
|
|||||||
@@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package bilibili
|
package bilibili
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"miaosic"
|
"github.com/AynaLivePlayer/miaosic"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
7
providers/bilivideo/init.go
Normal file
7
providers/bilivideo/init.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package bilivideo
|
||||||
|
|
||||||
|
import "github.com/AynaLivePlayer/miaosic"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
miaosic.RegisterProvider(NewBilibiliViedo())
|
||||||
|
}
|
||||||
@@ -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
7
providers/kuwo/init.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package kuwo
|
||||||
|
|
||||||
|
import "github.com/AynaLivePlayer/miaosic"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
miaosic.RegisterProvider(NewKuwo())
|
||||||
|
}
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package local
|
package local
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"miaosic"
|
"github.com/AynaLivePlayer/miaosic"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
11
providers/local/playlist.go
Normal file
11
providers/local/playlist.go
Normal 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
|
||||||
|
}
|
||||||
@@ -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())
|
||||||
|
|||||||
@@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user