//reimplement download to insert info into id3 tags func (dm *DownloadableMusic) Do() (resp curl.Response, err error) { resp, err = dm.DownloadableFile.Do() if err != nil { return } mp3file, err := id3.Open(dm.ActualPath()) defer mp3file.Close() //add id3 info mp3file.SetTitle(dm.Title) mp3file.SetArtist(dm.Artist) if dm.Album != "" { mp3file.SetAlbum(dm.Album) } if dm.Genre != "" { mp3file.SetGenre(dm.Genre) } //download and insert lyrics if dm.LyricsId != 0 { rac := requestwrapper.RequestAccesser{Token: dm.AccessToken} parms := map[string]string{"lyrics_id": strconv.FormatFloat(dm.LyricsId, 'f', -1, 64)} vkresp, err := rac.MakeRequest("audio.getLyrics", parms) if err != nil { return resp, err } lyrics := vkresp["response"].(map[string]interface{})["text"].(string) frt := v2.V23FrameTypeMap["USLT"] lyricsFrame := v2.NewTextFrame(frt, lyrics) mp3file.AddFrames(lyricsFrame) } return }
func setFrame(tag *id3.File, frameName string, value string) bool { frame := tag.Frame(frameName) if frame != nil { // fmt.Println("changing frame") if textFramer, ok := frame.(v2.TextFramer); ok { textFramer.SetEncoding("UTF-8") textFramer.SetText(value) return true } } else { // fmt.Println("adding frame") ft := v2.V23FrameTypeMap[frameName] textFrame := v2.NewTextFrame(ft, "") textFrame.SetEncoding("UTF-8") textFrame.SetText(value) tag.AddFrames(textFrame) } return false }