mirror of
https://github.com/AynaLivePlayer/miaosic.git
synced 2025-12-13 00:08:13 +08:00
update package name
This commit is contained in:
24
api.go
24
api.go
@@ -1,5 +1,29 @@
|
||||
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) {
|
||||
// if v, ok := Providers[meta.Name]; ok {
|
||||
// return v.GetPlaylist(meta)
|
||||
|
||||
19
miaosic.go
19
miaosic.go
@@ -60,10 +60,27 @@ type MediaInfo struct {
|
||||
|
||||
type Playlist struct {
|
||||
Title string
|
||||
Medias []*MediaInfo
|
||||
Medias []MediaInfo
|
||||
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 {
|
||||
// GetName returns the name of the provider.
|
||||
GetName() string
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package bilibili
|
||||
|
||||
import (
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/AynaLivePlayer/miaosic/providers"
|
||||
"github.com/aynakeya/deepcolor"
|
||||
"github.com/aynakeya/deepcolor/dphttp"
|
||||
"github.com/tidwall/gjson"
|
||||
"miaosic"
|
||||
"miaosic/providers"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package bilibili
|
||||
|
||||
import (
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/stretchr/testify/require"
|
||||
"miaosic"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package bilibili
|
||||
|
||||
import (
|
||||
"miaosic"
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package bilibili
|
||||
|
||||
import "miaosic"
|
||||
import "github.com/AynaLivePlayer/miaosic"
|
||||
|
||||
func (n *Bilibili) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
|
||||
return miaosic.MetaData{}, false
|
||||
|
||||
@@ -3,13 +3,13 @@ package bilivideo
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/AynaLivePlayer/miaosic/providers"
|
||||
"github.com/aynakeya/deepcolor"
|
||||
"github.com/aynakeya/deepcolor/dphttp"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/tidwall/gjson"
|
||||
"miaosic"
|
||||
"miaosic/providers"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package bilivideo
|
||||
|
||||
import (
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"miaosic"
|
||||
"regexp"
|
||||
"strings"
|
||||
"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
|
||||
|
||||
import "miaosic"
|
||||
import "github.com/AynaLivePlayer/miaosic"
|
||||
|
||||
func (n *BilibiliVideo) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
|
||||
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 (
|
||||
"fmt"
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/AynaLivePlayer/miaosic/providers"
|
||||
"github.com/aynakeya/deepcolor"
|
||||
"github.com/aynakeya/deepcolor/dphttp"
|
||||
"github.com/spf13/cast"
|
||||
@@ -9,8 +11,6 @@ import (
|
||||
"html"
|
||||
"math"
|
||||
"math/rand"
|
||||
"miaosic"
|
||||
"miaosic/providers"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package kuwo
|
||||
|
||||
import (
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"miaosic"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package kuwo
|
||||
|
||||
import "miaosic"
|
||||
import "github.com/AynaLivePlayer/miaosic"
|
||||
|
||||
func (n *Kuwo) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
|
||||
return miaosic.MetaData{}, false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"miaosic"
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/dhowden/tag"
|
||||
"github.com/sahilm/fuzzy"
|
||||
"miaosic"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
@@ -2,8 +2,8 @@ package local
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/sahilm/fuzzy"
|
||||
"miaosic"
|
||||
"sort"
|
||||
"strings"
|
||||
"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
|
||||
|
||||
import "miaosic"
|
||||
import "github.com/AynaLivePlayer/miaosic"
|
||||
|
||||
func init() {
|
||||
miaosic.RegisterProvider(NewNetease())
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
neteaseApi "github.com/XiaoMengXinX/Music163Api-Go/api"
|
||||
"miaosic"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package netease
|
||||
|
||||
import (
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
neteaseApi "github.com/XiaoMengXinX/Music163Api-Go/api"
|
||||
neteaseTypes "github.com/XiaoMengXinX/Music163Api-Go/types"
|
||||
neteaseUtil "github.com/XiaoMengXinX/Music163Api-Go/utils"
|
||||
"github.com/spf13/cast"
|
||||
"miaosic"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package netease
|
||||
|
||||
import (
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/stretchr/testify/require"
|
||||
"miaosic"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package netease
|
||||
|
||||
import "miaosic"
|
||||
import "github.com/AynaLivePlayer/miaosic"
|
||||
|
||||
func (n *Netease) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
|
||||
return miaosic.MetaData{}, false
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"github.com/AynaLivePlayer/miaosic"
|
||||
"github.com/aynakeya/deepcolor/dphttp"
|
||||
"miaosic"
|
||||
)
|
||||
|
||||
type FileApiParam struct {
|
||||
|
||||
Reference in New Issue
Block a user