コード例 #1
0
ファイル: baiduplayer.go プロジェクト: zero2012/music
func (this *baiduMusicPlayer) parserMusicLinkList(js *simplejson.Json, musicList *map[string]*element.MusicInfo) {
	data := js.Get("data").MustMap()
	if songList, ok := data["songList"].([]interface{}); ok {
		for _, info := range songList {
			musicInfo := info.(map[string]interface{})
			id := musicInfo["songId"].(json.Number).String()
			if _, ok := (*musicList)[id]; !ok {
				fmt.Println("Key Not Found")
				continue
			}

			var music *element.MusicInfo = (*musicList)[id]
			if musicInfo["showLink"] == nil {
				delete(*musicList, id)
				continue
			}
			music.MusicPath = musicInfo["showLink"].(string)
			if musicInfo["lrcLink"] == nil {
				delete(*musicList, id)
				continue
			}
			music.LyricPath = baiduMusicHost + musicInfo["lrcLink"].(string)
			if musicInfo["time"] == nil {
				delete(*musicList, id)
				continue
			}
			musicTime, _ := musicInfo["time"].(json.Number).Int64()
			music.MusicTime = int(musicTime)
			music.MusicFormat = "mp3"
		}
	} else {
		musicList = nil
	}
}
コード例 #2
0
ファイル: baiduplayer.go プロジェクト: zero2012/music
func (this *baiduMusicPlayer) checkMusicIsValid(musicInfo *element.MusicInfo) bool {
	// 非http://yinyueshiting.baidu.com个歌曲屏蔽
	if strings.HasPrefix(musicInfo.MusicPath, "http://yinyueshiting.baidu.com") {
		if musicInfo.LyricPath == "http://fm.baidu.com" {
			// 将歌词不对的,直接将歌词赋值空
			musicInfo.LyricPath = ""
		}
		return true
	}
	return false
}