deezer

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2021 License: ISC Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URL

func URL(ctype ContentType, id string) (link string)

URL returns a URL from a given content type and content id, being essentially the opposite of ParseURL.

Types

type Album

type Album struct {
	ID                  string          `json:"ALB_ID"`
	ArtistID            string          `json:"ART_ID"`
	ArtistName          string          `json:"ART_NAME"`
	LabelName           string          `json:"LABEL_NAME"`
	StyleName           string          `json:"STYLE_NAME"`
	Title               string          `json:"ALB_TITLE"`
	Version             string          `json:"VERSION"`
	Picture             string          `json:"ALB_PICTURE"`
	DigitalReleaseDate  string          `json:"DIGITAL_RELEASE_DATE"`
	PhysicalReleaseDate string          `json:"PHYSICAL_RELEASE_DATE"`
	ProviderID          string          `json:"PROVIDER_ID"`
	SonyProdID          string          `json:"SONY_PROD_ID"`
	UPC                 string          `json:"UPC"`
	Status              string          `json:"STATUS"`
	Fans                int             `json:"NB_FAN"`
	Available           bool            `json:"AVAILABLE"`
	ExplicitContent     ExplicitContent `json:"EXPLICIT_ALBUM_CONTENT"`
}

type Artist

type Artist struct {
	ID      string `json:"ART_ID"`
	Name    string `json:"ART_NAME"`
	Picture string `json:"ART_PICTURE"`
	Fans    int    `json:"NB_FAN"`
}

type ChunkDecrypter

type ChunkDecrypter struct {
	// contains filtered or unexported fields
}

func NewChunkDecrypter

func NewChunkDecrypter(songid string) (*ChunkDecrypter, error)

func (ChunkDecrypter) DecryptChunk

func (c ChunkDecrypter) DecryptChunk(dst, src []byte)

type Client

type Client struct {
	*http.Client
	Arl string
}

func NewClient

func NewClient(arl string) *Client

NewClient returns a Deezer client with the given arl (used for authentication) this arl can be gotten by following these instructions: https://notabug.org/RemixDevs/DeezloaderRemix/wiki/Login+via+userToken

func NewClientWithHTTPClient

func NewClientWithHTTPClient(arl string, client *http.Client) *Client

NewClientWithHTTPClient returns a Deezer client with the given arl. This is useful for setting a timeout for requests made by the Client. It will modify the given http.Client's Jar.

func (*Client) Album

func (c *Client) Album(id string) (*Album, error)

Album fetches an Album.

func (*Client) AlbumsByArtist

func (c *Client) AlbumsByArtist(id string) ([]Album, error)

AlbumsBy fetches albums in an artist's discography.

func (*Client) Artist

func (c *Client) Artist(id string) (*Artist, error)

Artist fetches an Artist.

func (*Client) AvailableQualities

func (c *Client) AvailableQualities(song Song) []Quality

AvailableQualities returns the available qualities for download of a song.

func (*Client) Download

func (c *Client) Download(song Song, quality Quality) (io.ReadCloser, error)

Download returns an io.ReadCloser from which the song can be read at the given quality. This function is deprecated and it is preferred to use song.Write

func (*Client) IsQualityAvailable

func (c *Client) IsQualityAvailable(song Song, quality Quality) bool

IsQualityAvailable returns whether or not a song is available to download for a song.

func (*Client) Lyrics added in v1.2.0

func (c *Client) Lyrics(id string) (*Lyrics, error)

Lyrics fetches a song's lyrics. The ID provided can be from a Song's LyricsID field.

func (*Client) Search

func (c *Client) Search(query, filter, output string, start, limit int) (*SearchResponse, error)

Search searches for artists/albums/songs.

func (*Client) Song

func (c *Client) Song(id string) (*Song, error)

Song fetches a Song.

func (*Client) SongsByAlbum

func (c *Client) SongsByAlbum(id string, songLimit int) ([]Song, error)

SongsByAlbum fetches up to songLimit songs on an album. If you want to fetch all of the songs on an album, use a songLimit of -1.

type ContentType

type ContentType string
const (
	ContentAlbum  ContentType = "album"
	ContentArtist ContentType = "artist"
	ContentSong   ContentType = "track"
)

func ParseURL

func ParseURL(link string) (ctype ContentType, id string)

ParseURL returns the content type and id of a given Deezer URL.

type Contributors

type Contributors struct {
	MainArtist []string `json:"main_artist"`
	Artist     []string `json:"artist"`
}

type DecryptingReader

type DecryptingReader struct {
	// contains filtered or unexported fields
}

func NewDecryptingReader

func NewDecryptingReader(r io.Reader, songid string) (*DecryptingReader, error)

NewDecryptingReader creates an DecryptingReader that reads from r and decrypts it using s.

func (*DecryptingReader) Read

func (r *DecryptingReader) Read(p []byte) (int, error)

Read reads up to n(p) bytes into p, returning how many bytes were read and any error.

func (*DecryptingReader) ReadChunk

func (r *DecryptingReader) ReadChunk() ([]byte, error)

ReadChunk returns the next n<=2048 bytes of the song. It automatically decrypts chunks when it has to (every third chunk). You most likely would prefer to use Read instead of ReadChunk because it implements io.Reader.

type ErrUnexpectedStatusCode

type ErrUnexpectedStatusCode struct{ Code int }

func (ErrUnexpectedStatusCode) Error

func (err ErrUnexpectedStatusCode) Error() string

type ExplicitContent

type ExplicitContent struct {
	LyricsStatus int `json:"EXPLICIT_LYRICS_STATUS"`
	CoverStatus  int `json:"EXPLICIT_COVER_STATUS"`
}

type Lyrics added in v1.2.0

type Lyrics struct {
	Text       string        `json:"LYRICS_TEXT"`
	ID         string        `json:"LYRICS_ID"`
	Copyrights string        `json:"LYRICS_COPYRIGHTS"`
	Writers    string        `json:"LYRICS_WRITERS"`
	Sync       []SyncedLyric `json:"LYRICS_SYNC_JSON"`
}

type Quality

type Quality int
const (
	MP3128 Quality = 1
	MP3320 Quality = 3
	FLAC   Quality = 9
)

type SearchResponse

type SearchResponse struct {
	Artists struct {
		Data []Artist `json:"data"`
	} `json:"ARTIST"`
	Songs struct {
		Data []Song `json:"data"`
	} `json:"TRACK"`
	Albums struct {
		Data []Album `json:"data"`
	} `json:"ALBUM"`
}

type Song

type Song struct {
	Filesize            string          `json:"FILESIZE"`
	ProductTrackID      string          `json:"PRODUCT_TRACK_ID"`
	DigitalReleaseDate  string          `json:"DIGITAL_RELEASE_DATE"`
	Title               string          `json:"SNG_TITLE"`
	ArtistID            string          `json:"ART_ID"`
	ProviderID          string          `json:"PROVIDER_ID"`
	ArtistName          string          `json:"ART_NAME"`
	HierarchicalTitle   string          `json:"HIERARCHICAL_TITLE"`
	ISRC                string          `json:"ISRC"`
	AlbumID             string          `json:"ALB_ID"`
	AlbumTitle          string          `json:"ALB_TITLE"`
	MD5Origin           string          `json:"MD5_ORIGIN"`
	ExplicitLyrics      string          `json:"EXPLICIT_LYRICS"`
	Duration            string          `json:"DURATION"`
	AlbumPicture        string          `json:"ALB_PICTURE"`
	ArtistPicture       string          `json:"ART_PICTURE"`
	Rank                string          `json:"RANK_SNG"`
	Version             string          `json:"VERSION"`
	DiskNumber          string          `json:"DISK_NUMBER"`
	MediaVersion        string          `json:"MEDIA_VERSION"`
	ID                  string          `json:"SNG_ID"`
	PhysicalReleaseDate string          `json:"PHYSICAL_RELEASE_DATE"`
	Contributors        Contributors    `json:"SNG_CONTRIBUTORS"`
	Artists             []Artist        `json:"ARTISTS"`
	ExplicitContent     ExplicitContent `json:"EXPLICIT_TRACK_CONTENT"`
	TrackNumber         int             `json:"TRACK_NUMBER,string"`
	FilesizeMP3128      int             `json:"FILESIZE_MP3_128,string"`
	UploadID            int             `json:"UPLOAD_ID"`
	FilesizeFLAC        int             `json:"FILESIZE_FLAC,string"`
	FilesizeMP3320      int             `json:"FILESIZE_MP3_320,string"`
	LyricsID            int             `json:"LYRICS_ID"`
	Status              int             `json:"STATUS"`
	Video               bool            `json:"VIDEO"`
}

func (Song) DownloadURL

func (s Song) DownloadURL(quality Quality) string

DownloadURL returns a download URL which can be used to stream the song. The audio returned from the URL will be encrypted so you should use a DecryptingReader to read it.

func (Song) Write added in v1.2.0

func (s Song) Write(w io.Writer, quality Quality) error

Write writes a song from Deezer at a given quality to w.

type SyncedLyric added in v1.2.0

type SyncedLyric struct {
	Timestamp    string `json:"lrc_timestamp,omitempty"`
	Duration     string `json:"duration,omitempty"`
	Line         string `json:"line"`
	Milliseconds int    `json:"milliseconds,omitempty"`
}

Directories

Path Synopsis
crypto
ecb

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL