mirror of
https://github.com/AynaLivePlayer/miaosic.git
synced 2025-12-06 13:02:48 +08:00
add api. fix kuwo
This commit is contained in:
8
api.go
8
api.go
@@ -57,6 +57,14 @@ func MatchMedia(keyword string) (MetaData, bool) {
|
|||||||
return MetaData{}, false
|
return MetaData{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MatchMediaByProvider(provider string, uri string) (MetaData, bool) {
|
||||||
|
p, ok := GetProvider(provider)
|
||||||
|
if !ok {
|
||||||
|
return MetaData{}, false
|
||||||
|
}
|
||||||
|
return p.MatchMedia(uri)
|
||||||
|
}
|
||||||
|
|
||||||
//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)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package kuwo
|
package kuwo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/AynaLivePlayer/miaosic"
|
"github.com/AynaLivePlayer/miaosic"
|
||||||
"github.com/AynaLivePlayer/miaosic/providers"
|
"github.com/AynaLivePlayer/miaosic/providers"
|
||||||
@@ -77,6 +78,9 @@ func NewKuwo() *Kuwo {
|
|||||||
|
|
||||||
deepcolor.ParserGJson,
|
deepcolor.ParserGJson,
|
||||||
func(resp *gjson.Result, urls *[]miaosic.MediaUrl) error {
|
func(resp *gjson.Result, urls *[]miaosic.MediaUrl) error {
|
||||||
|
if resp.Get("code").Int() != 200 {
|
||||||
|
return errors.New("miaosic: kuwo api error" + resp.Get("msg").String())
|
||||||
|
}
|
||||||
if resp.Get("data.url").String() == "" {
|
if resp.Get("data.url").String() == "" {
|
||||||
return miaosic.ErrorExternalApi
|
return miaosic.ErrorExternalApi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,17 @@ func TestKuwo_GetMusic(t *testing.T) {
|
|||||||
t.Log(urls)
|
t.Log(urls)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestKuwo_GetMusic2(t *testing.T) {
|
||||||
|
meta := miaosic.MetaData{
|
||||||
|
Provider: api.GetName(),
|
||||||
|
Identifier: "6510096",
|
||||||
|
}
|
||||||
|
urls, err := api.GetMediaUrl(meta, miaosic.QualityAny)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotEmpty(t, urls)
|
||||||
|
t.Log(urls)
|
||||||
|
}
|
||||||
|
|
||||||
func TestKuwo_UpdateMediaLyric(t *testing.T) {
|
func TestKuwo_UpdateMediaLyric(t *testing.T) {
|
||||||
meta := miaosic.MetaData{
|
meta := miaosic.MetaData{
|
||||||
Provider: api.GetName(),
|
Provider: api.GetName(),
|
||||||
|
|||||||
Reference in New Issue
Block a user