예제 #1
0
파일: mpd.go 프로젝트: woody7527/MuseBot
func constructSongInfo(songDetails mpd.Attrs, m *MpdBackend) *musebot.SongInfo {
	length, _ := strconv.ParseInt(songDetails["Time"], 10, 0)

	musicUrl := songDetails["file"]
	if songDetails["file"][0:7] != "file://" {
		musicUrl = "file://" + m.musicDir + musicUrl
	}

	//stickermap, _ := m.client.StickerGet("song", songDetails["file"], "coverarturl")
	stickermap_b, _ := m.client.StickerGet("song", songDetails["file"], "songinfo")

	si := musebot.SongInfo{}
	//log.Println(si, stickermap_b["songinfo"])
	err := json.Unmarshal([]byte(stickermap_b["songinfo"]), &si)
	if err == nil {
		var wasOk bool
		sdp, wasOk := si.ProviderName.(string)
		if wasOk {
			si.Provider, wasOk = musebot.CurrentProviders[sdp]
		}
	} else {
		si.ProviderName = "<<LOCAL>>"
		si.Title = songDetails["Title"]
		si.Album = songDetails["Album"]
		si.Artist = songDetails["Artist"]
	}
	si.MusicUrl = musicUrl
	si.Length = int(length)
	si.Id = songDetails["Id"]
	return &si
}
예제 #2
0
func (p *GroovesharkProvider) groovesharkSongToMuseBotSong(r map[string]interface{}, song *musebot.SongInfo) {
	coverArtFn := r["CoverArtFilename"].(string)
	if coverArtFn == "" {
		coverArtFn = "http://images.grooveshark.com/static/albums/500_default.png"
	} else {
		coverArtFn = "http://images.grooveshark.com/static/albums/500_" + coverArtFn
	}
	Title, ok := r["SongName"].(string)
	if !ok {
		Title = r["Name"].(string)
	}
	song.Title = Title
	song.Artist = r["ArtistName"].(string)
	song.Album = r["AlbumName"].(string)
	song.CoverArtUrl = coverArtFn
	song.Provider = p
	song.ProviderName = p.PackageName()
	song.ProviderId = r["SongID"].(string)
}