Skip to content

Commit

Permalink
更改ArtistDetail为ArtistHomepage
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoMengXinX committed Mar 20, 2022
1 parent b943ebb commit a8d06ad
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 63 deletions.
39 changes: 0 additions & 39 deletions api/artistDetail.go

This file was deleted.

39 changes: 39 additions & 0 deletions api/artistHomepage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package api

import (
"encoding/json"
"github.com/XiaoMengXinX/Music163Api-Go/types"
"github.com/XiaoMengXinX/Music163Api-Go/utils"
)

// ArtistHomepageAPI 获取歌手详情API
const ArtistHomepageAPI = "/api/personal/home/page/artist"

// ArtistHomepageReq 获取歌手详情API 的 body json
type ArtistHomepageReq struct {
ArtistId int64 `json:"artistId"`
}

// CreateArtistHomepageReqJson 创建获取歌手详情API 的 body json
func CreateArtistHomepageReqJson(artistId int64) string {
reqBody := ArtistHomepageReq{
ArtistId: artistId,
}
reqBodyJson, _ := json.Marshal(reqBody)
return string(reqBodyJson)
}

// GetArtistHomepage 获取歌手详情
func GetArtistHomepage(data utils.RequestData, artistID int64) (result types.ArtistHomepageData, err error) {
var options utils.EapiOption
options.Path = ArtistHomepageAPI
options.Url = "https://music.163.com/eapi/personal/home/page/artist"
options.Json = CreateArtistHomepageReqJson(artistID)
resBody, _, err := utils.ApiRequest(options, data)
if err != nil {
return result, err
}
err = json.Unmarshal([]byte(resBody), &result)
result.RawJson = resBody
return result, err
}
59 changes: 35 additions & 24 deletions types/artistDetail.go → types/artistHomepage.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package types

// ArtistDetailData 获取歌手详细API返回数据
type ArtistDetailData struct {
// ArtistHomepageData 获取歌手详细API返回数据
type ArtistHomepageData struct {
RawJson string
Code int `json:"code"`
Data struct {
Expand All @@ -16,7 +16,7 @@ type ArtistDetailData struct {
Position string `json:"position"`
Md5 interface{} `json:"md5"`
Channel string `json:"channel"`
UiElement *struct {
UiElement struct {
MainTitle struct {
Title string `json:"title"`
TitleImgId interface{} `json:"titleImgId"`
Expand Down Expand Up @@ -45,9 +45,9 @@ type ArtistDetailData struct {
Id interface{} `json:"id"`
BlockId interface{} `json:"blockId"`
CreativeId interface{} `json:"creativeId"`
CreativeType *string `json:"creativeType"`
CreativeType string `json:"creativeType"`
Position string `json:"position"`
Action *struct {
Action struct {
ClickAction struct {
Action int `json:"action"`
TargetUrl string `json:"targetUrl"`
Expand All @@ -57,10 +57,10 @@ type ArtistDetailData struct {
AdInfo interface{} `json:"adInfo"`
Code interface{} `json:"code"`
Resources []struct {
ResourceType *string `json:"resourceType"`
ResourceId *string `json:"resourceId"`
ResourceType string `json:"resourceType"`
ResourceId string `json:"resourceId"`
ResourceUrl interface{} `json:"resourceUrl"`
ResourceExtInfo *struct {
ResourceExtInfo struct {
CommentCount int `json:"commentCount,omitempty"`
PlayCount int `json:"playCount"`
Users []struct {
Expand Down Expand Up @@ -203,7 +203,7 @@ type ArtistDetailData struct {
Single int `json:"single"`
NoCopyrightRcmd interface{} `json:"noCopyrightRcmd"`
HMusic struct {
Name *string `json:"name"`
Name string `json:"name"`
Id int64 `json:"id"`
Size int `json:"size"`
Extension string `json:"extension"`
Expand All @@ -214,7 +214,7 @@ type ArtistDetailData struct {
VolumeDelta float64 `json:"volumeDelta"`
} `json:"hMusic"`
MMusic struct {
Name *string `json:"name"`
Name string `json:"name"`
Id int64 `json:"id"`
Size int `json:"size"`
Extension string `json:"extension"`
Expand All @@ -225,7 +225,7 @@ type ArtistDetailData struct {
VolumeDelta float64 `json:"volumeDelta"`
} `json:"mMusic"`
LMusic struct {
Name *string `json:"name"`
Name string `json:"name"`
Id int64 `json:"id"`
Size int `json:"size"`
Extension string `json:"extension"`
Expand All @@ -236,7 +236,7 @@ type ArtistDetailData struct {
VolumeDelta float64 `json:"volumeDelta"`
} `json:"lMusic"`
BMusic struct {
Name *string `json:"name"`
Name string `json:"name"`
Id int64 `json:"id"`
Size int `json:"size"`
Extension string `json:"extension"`
Expand Down Expand Up @@ -372,7 +372,7 @@ type ArtistDetailData struct {
RadioFeeType int `json:"radioFeeType,omitempty"`
RadioFeeScope int `json:"radioFeeScope,omitempty"`
} `json:"resourceExtInfo"`
ResourceExt *struct {
ResourceExt struct {
LikeCount int `json:"likeCount,omitempty"`
Liked bool `json:"liked,omitempty"`
Song struct {
Expand Down Expand Up @@ -756,15 +756,15 @@ type ArtistDetailData struct {
ParentCommentId int `json:"parentCommentId"`
} `json:"comments,omitempty"`
} `json:"resourceExt"`
ResourcePolicyId *string `json:"resourcePolicyId"`
Action *struct {
ResourcePolicyId string `json:"resourcePolicyId"`
Action struct {
ClickAction struct {
Action int `json:"action"`
TargetUrl string `json:"targetUrl"`
} `json:"clickAction"`
} `json:"action"`
UiElement struct {
MainTitle *struct {
MainTitle struct {
Title string `json:"title"`
TitleImgId interface{} `json:"titleImgId"`
TitleImgUrl interface{} `json:"titleImgUrl"`
Expand All @@ -787,15 +787,26 @@ type ArtistDetailData struct {
Height int `json:"height"`
Action interface{} `json:"action"`
} `json:"images"`
Labels interface{} `json:"labels"`
TextLinks interface{} `json:"textLinks"`
Descriptions interface{} `json:"descriptions"`
Icons interface{} `json:"icons"`
Buttons []struct {
Labels interface{} `json:"labels"`
TextLinks []struct {
Tag interface{} `json:"tag"`
Text string `json:"text"`
Url interface{} `json:"url"`
} `json:"textLinks"`
Descriptions []struct {
Tag interface{} `json:"tag"`
Description string `json:"description"`
} `json:"descriptions"`
Icons []struct {
Tag interface{} `json:"tag"`
ImgId int `json:"imgId"`
ImgUrl string `json:"imgUrl"`
} `json:"icons"`
Buttons []struct {
Tag interface{} `json:"tag"`
Text string `json:"text"`
ImageUrl interface{} `json:"imageUrl"`
Action *struct {
Action struct {
ClickAction struct {
Action int `json:"action"`
TargetUrl string `json:"targetUrl"`
Expand All @@ -810,11 +821,11 @@ type ArtistDetailData struct {
Valid bool `json:"valid"`
Alg interface{} `json:"alg"`
Scm interface{} `json:"scm"`
VisibleStatus *string `json:"visibleStatus"`
VisibleStatus string `json:"visibleStatus"`
} `json:"resources"`
} `json:"creatives"`
CanRefresh bool `json:"canRefresh"`
VisibleStatus *string `json:"visibleStatus"`
VisibleStatus string `json:"visibleStatus"`
BlockConfig interface{} `json:"blockConfig"`
BlockCursor interface{} `json:"blockCursor"`
HasMore bool `json:"hasMore"`
Expand Down

0 comments on commit a8d06ad

Please sign in to comment.