cover.go 595 B

12345678910111213141516171819202122
  1. package client
  2. import (
  3. "context"
  4. "fmt"
  5. "strconv"
  6. )
  7. func (c *QQMusic) AlbumCoverByID(ctx context.Context, albumID int) ([]byte, error) {
  8. u := fmt.Sprintf("https://imgcache.qq.com/music/photo/album/%s/albumpic_%s_0.jpg",
  9. strconv.Itoa(albumID%100),
  10. strconv.Itoa(albumID),
  11. )
  12. return c.downloadFile(ctx, u)
  13. }
  14. func (c *QQMusic) AlbumCoverByMediaID(ctx context.Context, mediaID string) ([]byte, error) {
  15. // original: https://y.gtimg.cn/music/photo_new/T002M000%s.jpg
  16. u := fmt.Sprintf("https://y.gtimg.cn/music/photo_new/T002R500x500M000%s.jpg", mediaID)
  17. return c.downloadFile(ctx, u)
  18. }