fix name error

This commit is contained in:
Jay 2019-03-27 13:56:24 +00:00
parent 7c694686b6
commit 4b7149b66b

View File

@ -9,7 +9,6 @@ import (
"strings" "strings"
"git.trj.tw/golang/mtfosbot/module/apis" "git.trj.tw/golang/mtfosbot/module/apis"
"git.trj.tw/golang/mtfosbot/module/utils"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"git.trj.tw/golang/mtfosbot/module/config" "git.trj.tw/golang/mtfosbot/module/config"
@ -52,11 +51,11 @@ func getHeaders(token ...interface{}) map[string]string {
// ChannelItem - // ChannelItem -
type ChannelItem struct { type ChannelItem struct {
ID string `json:"id"` ID string `json:"id"`
Sinppet ChannelSinppet `json:"sinppet"` Snippet ChannelSnippet `json:"snippet"`
} }
// ChannelSinppet - // ChannelSnippet -
type ChannelSinppet struct { type ChannelSnippet struct {
Title string `json:"title"` Title string `json:"title"`
Description string `json:"description"` Description string `json:"description"`
CustomURL string `json:"customUrl"` CustomURL string `json:"customUrl"`
@ -99,7 +98,6 @@ func QueryYoutubeName(id string) (n string, err error) {
} }
bodyBytes, err := ioutil.ReadAll(resp.Body) bodyBytes, err := ioutil.ReadAll(resp.Body)
fmt.Println("body ::: ", string(bodyBytes))
if err != nil { if err != nil {
return "", err return "", err
} }
@ -109,7 +107,6 @@ func QueryYoutubeName(id string) (n string, err error) {
}{} }{}
err = json.Unmarshal(bodyBytes, &apiRes) err = json.Unmarshal(bodyBytes, &apiRes)
fmt.Println("api resp ::: ", utils.ToMap(apiRes))
if err != nil { if err != nil {
return "", err return "", err
} }
@ -119,10 +116,8 @@ func QueryYoutubeName(id string) (n string, err error) {
} }
for _, v := range apiRes.Items { for _, v := range apiRes.Items {
fmt.Println("data :::: ", v)
if v.ID == id { if v.ID == id {
fmt.Println("id match ::: ", v.Sinppet) return v.Snippet.Title, nil
return v.Sinppet.Title, nil
} }
} }