mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-13 13:38:16 +08:00
add diange source command & fix bilibili video
This commit is contained in:
@@ -116,7 +116,6 @@ func (b *Bilibili) UpdateMediaUrl(media *player.Media) error {
|
||||
media.Header = map[string]string{
|
||||
"user-agent": "BiliMusic/2.233.3",
|
||||
}
|
||||
fmt.Println(fmt.Sprintf(b.InfoApi, media.Meta.(Meta).Id))
|
||||
uri := gjson.Get(resp, "data.cdns.0").String()
|
||||
if uri == "" {
|
||||
return ErrorExternalApi
|
||||
|
||||
@@ -82,7 +82,7 @@ func (b *BilibiliVideo) Search(keyword string) ([]*player.Media, error) {
|
||||
}
|
||||
|
||||
func (b *BilibiliVideo) UpdateMedia(media *player.Media) error {
|
||||
resp := httpGetString(fmt.Sprintf(b.InfoApi, media.Meta.(Meta).Id), nil)
|
||||
resp := httpGetString(fmt.Sprintf(b.InfoApi, b.getBv(media.Meta.(Meta).Id)), nil)
|
||||
if resp == "" {
|
||||
return ErrorExternalApi
|
||||
}
|
||||
@@ -98,12 +98,12 @@ func (b *BilibiliVideo) UpdateMedia(media *player.Media) error {
|
||||
}
|
||||
|
||||
func (b *BilibiliVideo) UpdateMediaUrl(media *player.Media) error {
|
||||
resp := httpGetString(fmt.Sprintf(b.InfoApi, media.Meta.(Meta).Id), nil)
|
||||
resp := httpGetString(fmt.Sprintf(b.InfoApi, b.getBv(media.Meta.(Meta).Id)), nil)
|
||||
if resp == "" {
|
||||
return ErrorExternalApi
|
||||
}
|
||||
jresp := gjson.Parse(resp)
|
||||
page := b.getPage(media.Meta.(Meta).Id)
|
||||
page := b.getPage(media.Meta.(Meta).Id) - 1
|
||||
cid := jresp.Get(fmt.Sprintf("data.View.pages.%d.cid", page)).String()
|
||||
if cid == "" {
|
||||
cid = jresp.Get("data.View.cid").String()
|
||||
|
||||
@@ -3,6 +3,7 @@ package provider
|
||||
import (
|
||||
"AynaLivePlayer/player"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -42,3 +43,44 @@ func TestBV_GetMusic(t *testing.T) {
|
||||
//fmt.Println(media)
|
||||
fmt.Println(media.Url)
|
||||
}
|
||||
|
||||
func TestBV_Regex(t *testing.T) {
|
||||
fmt.Println(regexp.MustCompile("^BV[0-9A-Za-z]+(\\?p=[0-9]+)?").FindString("BV1gA411P7ir?p=3"))
|
||||
}
|
||||
|
||||
func TestBV_GetMusicMeta2(t *testing.T) {
|
||||
var api MediaProvider = BilibiliVideoAPI
|
||||
|
||||
media := player.Media{
|
||||
Meta: Meta{
|
||||
Name: api.GetName(),
|
||||
Id: "BV1gA411P7ir?p=3",
|
||||
},
|
||||
}
|
||||
err := api.UpdateMedia(&media)
|
||||
fmt.Println(err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Println(media)
|
||||
}
|
||||
|
||||
func TestBV_GetMusic2(t *testing.T) {
|
||||
var api MediaProvider = BilibiliVideoAPI
|
||||
media := player.Media{
|
||||
Meta: Meta{
|
||||
Name: api.GetName(),
|
||||
Id: "BV1gA411P7ir?p=3",
|
||||
},
|
||||
}
|
||||
err := api.UpdateMedia(&media)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = api.UpdateMediaUrl(&media)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
//fmt.Println(media)
|
||||
fmt.Println(media.Url)
|
||||
}
|
||||
|
||||
@@ -44,6 +44,13 @@ func FormatPlaylistUrl(pname, uri string) (string, error) {
|
||||
return "", ErrorNoSuchProvider
|
||||
}
|
||||
|
||||
func MatchMedia(provider string, keyword string) *player.Media {
|
||||
if v, ok := Providers[provider]; ok {
|
||||
return v.MatchMedia(keyword)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Search(provider string, keyword string) ([]*player.Media, error) {
|
||||
if v, ok := Providers[provider]; ok {
|
||||
return v.Search(keyword)
|
||||
|
||||
Reference in New Issue
Block a user