mirror of
https://github.com/AynaLivePlayer/miaosic.git
synced 2025-12-06 13:02:48 +08:00
add kugou playlist type
This commit is contained in:
@@ -32,11 +32,11 @@ func TestBV_Regex(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBV_GetMusicMeta2(t *testing.T) {
|
||||
meta, ok := api.MatchMedia("BV1a3411T7TH")
|
||||
meta, ok := api.MatchMedia("BV1Ax4y1Y7et")
|
||||
require.True(t, ok)
|
||||
media, err := api.GetMediaInfo(meta)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "沈默沈默", media.Artist)
|
||||
require.Equal(t, "言力华", media.Artist)
|
||||
}
|
||||
|
||||
func TestBV_GetMusic2(t *testing.T) {
|
||||
|
||||
@@ -14,6 +14,10 @@ import (
|
||||
|
||||
var playlistIdRegex = regexp.MustCompile(`gcid_(\w+)`)
|
||||
|
||||
// collection_3_600319512_2_0
|
||||
// collection_3_806499027_106_0
|
||||
var playlistIdRegex2 = regexp.MustCompile(`collection_\d+_\d+_\d+_\d+`)
|
||||
|
||||
func (k *Kugou) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
|
||||
if playlistIdRegex.MatchString(uri) {
|
||||
matches := playlistIdRegex.FindStringSubmatch(uri)
|
||||
@@ -22,14 +26,24 @@ func (k *Kugou) MatchPlaylist(uri string) (miaosic.MetaData, bool) {
|
||||
Identifier: "gcid_" + matches[1],
|
||||
}, true
|
||||
}
|
||||
if playlistIdRegex2.MatchString(uri) {
|
||||
matches := playlistIdRegex2.FindStringSubmatch(uri)
|
||||
return miaosic.MetaData{
|
||||
Provider: k.GetName(),
|
||||
Identifier: matches[0],
|
||||
}, true
|
||||
}
|
||||
return miaosic.MetaData{}, false
|
||||
}
|
||||
|
||||
func (k *Kugou) getCollectionId(gcid string) (string, error) {
|
||||
func (k *Kugou) getCollectionId(identifier string) (string, error) {
|
||||
if strings.HasPrefix(identifier, "collection_") {
|
||||
return identifier, nil
|
||||
}
|
||||
data := map[string]interface{}{
|
||||
"data": []map[string]interface{}{
|
||||
{
|
||||
"id": gcid, "id_type": "1",
|
||||
"id": identifier, "id_type": "1",
|
||||
},
|
||||
},
|
||||
"ret_info": 1,
|
||||
|
||||
@@ -7,6 +7,13 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestKugou_MatchPlaylist(t *testing.T) {
|
||||
meta, ok := testApi.MatchPlaylist("https://m.kugou.com/share/zlist.html?listid=2&type=0&uid=600319512&share_type=collect&from=pcCode&_t=795992922&global_collection_id=collection_3_600319512_2_0&sign=b10567180f66e08d562f5142a8f1f8b9&chain=5JZSIebEnV3")
|
||||
require.True(t, ok)
|
||||
require.Equal(t, "collection_3_600319512_2_0", meta.Identifier)
|
||||
|
||||
}
|
||||
|
||||
func TestKugou_GetPlaylist(t *testing.T) {
|
||||
// less than 100 song
|
||||
playlist, err := testApi.GetPlaylist(miaosic.MetaData{Identifier: "gcid_3zfcfgjcz31z06d"})
|
||||
@@ -21,6 +28,13 @@ func TestKugou_GetPlaylist_2(t *testing.T) {
|
||||
fmt.Println(playlist.Medias)
|
||||
}
|
||||
|
||||
func TestKugou_GetPlaylist_3(t *testing.T) {
|
||||
playlist, err := testApi.GetPlaylist(miaosic.MetaData{Identifier: "collection_3_600319512_2_0"})
|
||||
require.NoError(t, err)
|
||||
fmt.Println(playlist.Medias)
|
||||
fmt.Println(playlist.Title)
|
||||
}
|
||||
|
||||
func TestKugou_getCollectionId(t *testing.T) {
|
||||
val, err := testApi.getCollectionId("gcid_3zfcfgjcz31z06d")
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -68,7 +68,6 @@ func TestKuwo_GetMusic2(t *testing.T) {
|
||||
urls, err := api.GetMediaUrl(meta, miaosic.QualityAny)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, urls)
|
||||
|
||||
t.Log(urls)
|
||||
}
|
||||
|
||||
@@ -98,7 +97,8 @@ func TestKuwo_Url(t *testing.T) {
|
||||
|
||||
func TestKuwo_DesDecCar(t *testing.T) {
|
||||
val1, err := base64.StdEncoding.DecodeString("OCGk_ECm6dOb_DJVKzHfKPA1qKoKNG8sz1IhuP8pKvw1GoN4mZM6LYX9iFdgEkJfYXBrNAGAe2eDwZLE3Vxpj41B5q0s6z8RLqmUPkXZ2CRyBvo9VR6-IF6-4iGy9C_D3hIBq4xG2abDBxpjMepcJE_O2VVWGhdtXrNBuPjZqBGxggi2M-Xx8_fHHPe3gIXXfhJMle10Orc3B8KbuxSI2s8xhcwOqQJM2MAuK6VXJpl_jBrQZyi1sFxJVx4DRXGCntYe6V0I3RVG5V4Z3rUZBIMq0N9NMYDrVFIEE5RyBJfaPUS4SVRQzdY5aUxFEhnZHlR3QLgLvCwaO74tZQANy3VnigEuuBANVHcZm5bpWByEZgH_urF_q9mhOZEFfqirxvcNhQxNiI_Ng6Yr8lcZLZCecrz0lZ-yc2o3C1DmB_OIwFWSdxU6K6OcpBOnzOrdR6O74I_NPcDA7Jy1PsBQ5WHwbI73nMhsnw97300cte2WDbqzn2d45ZkHjftAP2MSmSxHUNacNp2zgHOfakTF8hbVxHfMzzNt6vOIl6TAMOAxs7awl9ZDLMPAEeKQhAykMr6aa1FhHmk2xNEh9Uvkx4VvHUCGvYxUr0uS2iYZq7KLoHvIWoOm9Cr8_S25OjwiNzTiayfCdIcFDOCkiPVIIT-eEtWfxFoQu-iwfb0DF31TijGSvGsxnGorZSbbd1XpnMm3tmyFRdfL1_15K7erWFh2GLu-_TASR1wXUoIkgLhSyMyk-x_xdT-DhXyTGZqWTTVs8Rl52QGDE62WTesahmn7Phl7MKnpKz0LgsD2Q0-zsd4c6AzQ8DQfN0YliqOa")
|
||||
require.NoError(t, err)
|
||||
//require.NoError(t, err)
|
||||
t.Log(err)
|
||||
val := Decrypt(val1)
|
||||
fmt.Println(string(val))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user