func (b *Bandcamp) GetSong(id codec.ID) (codec.Song, error) { t := b.Tracks[id] if t == nil { return nil, fmt.Errorf("missing %v", id) } return mpa.NewSong(func() (io.ReadCloser, int64, error) { log.Println("BANDCAMP", id) res, err := http.Get(t.File.Mp3_128) if err != nil { return nil, 0, err } return res.Body, 0, nil }) }
func (g *GMusic) GetSong(id codec.ID) (codec.Song, error) { f := g.Tracks[id] if f == nil { return nil, fmt.Errorf("missing %v", id) } return mpa.NewSong(func() (io.ReadCloser, int64, error) { log.Println("GMUSIC", id) r, err := g.GMusic.GetStream(string(id)) if err != nil { return nil, 0, err } size, _ := strconv.ParseInt(f.EstimatedSize, 10, 64) return r.Body, size, nil }) }
func (s *Soundcloud) GetSong(id codec.ID) (codec.Song, error) { log.Println("SOUNDCLOUD", id) _, client, err := s.getService() if err != nil { return nil, err } f := s.Favorites[id] if f == nil { return nil, fmt.Errorf("bad id: %v", id) } return mpa.NewSong(func() (io.ReadCloser, int64, error) { res, err := client.Get(f.StreamURL + "?client_id=" + oauthClientID) if err != nil { return nil, 0, err } if err := googleapi.CheckResponse(res); err != nil { return nil, 0, err } return res.Body, 0, nil }) }
func (s *Stream) GetSong(codec.ID) (codec.Song, error) { return mpa.NewSong(s.reader()) }