deezer

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FLAC    Format = 9
	MP3_320        = 3
	MP3_256        = 5
	MP3_128        = 1
)
View Source
const AlbumAPIFormat = "https://api.deezer.com/album/%d"

Variables

View Source
var NoMD5Error = errors.New("no MD5 hash -- try authenticating")

Functions

func DecryptSongFile

func DecryptSongFile(key []byte, inputPath, outputPath string) error

DecryptSongFile decrypts the encrypted chunks of a song downloaded from deezer

func DumpResponse

func DumpResponse(resp *http.Response, message string)

DumpResponse dumps a response with logrus

func ECB

func ECB(key, data []byte) ([]byte, error)

ECB implementation since golang technically doesn't support it based on https://stackoverflow.com/questions/24072026/golang-aes-ecb-encryption input data is automatically zero-padded

func MD5Hash

func MD5Hash(data []byte) string

MD5Hash hashes the input data and returns it as a string

func MakeURLPath

func MakeURLPath(track *Track, format Format) (string, error)

MakeURLPath generates the path of the download URL

Types

type API

type API struct {
	APIToken string

	DebugMode bool
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(debugMode bool) (*API, error)

NewAPI creates a new API with a http Client with cookie jar

func (*API) ApiRequest

func (api *API) ApiRequest(method string, body io.Reader) (*http.Response, error)

ApiRequest performs an API request

func (*API) CookieLogin

func (api *API) CookieLogin(arl string) error

CookieLogin allows the user to log in using their arl cookie taken from a browser

func (*API) GetAlbumData added in v0.2.0

func (api *API) GetAlbumData(ID int) (*Album, error)

GetAlbum gets the album based on its ID

func (*API) GetSongData

func (api *API) GetSongData(ID int) (*Track, error)

GetSongData gets a track

func (*API) MobileApiRequest

func (api *API) MobileApiRequest(method string, body io.Reader) (*http.Response, error)

MobileApiRequest performs a mobile API request

type Album added in v0.2.0

type Album struct {
	ID        int
	Title     string
	Link      string
	CoverURL  string
	Covers    Covers
	Date      time.Time
	Tracklist []AlbumTrack
	Tracks    []*Track
	// contains filtered or unexported fields
}

Album stores the data for the album of interest

func NewAlbum added in v0.2.0

func NewAlbum(response *AlbumResponse, api *API) (*Album, error)

NewAlbum create an Album from an AlbumResponse

func (*Album) GetTracks added in v0.2.0

func (album *Album) GetTracks() ([]*Track, error)

GetTracks gets all tracks in an album and store them in album.Tracks. Also return the slice.

type AlbumResponse added in v0.2.0

type AlbumResponse struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	Link        string `json:"link"`
	CoverURL    string `json:"cover"`
	CoverSmall  string `json:"cover_small"`
	CoverMedium string `json:"cover_medium"`
	CoverBig    string `json:"cover_big"`
	CoverXL     string `json:"cover_xl"`
	Date        string `json:"release_date"`
	Tracks      struct {
		Data []AlbumTrack `json:"data"`
	} `json:tracks"`
}

AlbumResponse is an intermediate format for getting album data that stores the data before putting it in an Album struct

type AlbumTrack added in v0.2.0

type AlbumTrack struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
	Link  string `json:"link"`
}

type Covers added in v0.2.0

type Covers struct {
	Small  string
	Medium string
	Big    string
	XL     string
}

Covers stores the different cover sizes available

type Format

type Format int

type Track

type Track struct {
	ID           int     `json:"SNG_ID,string"`
	Title        string  `json:"SNG_TITLE"`
	TrackNumber  int     `json:"TRACK_NUMBER,string"`
	Gain         float32 `json:"GAIN,string"`
	MD5          string  `json:"MD5_ORIGIN"`
	MediaVersion int     `json:"MEDIA_VERSION,string"`
	// contains filtered or unexported fields
}

func (*Track) GetBlowfishKey

func (track *Track) GetBlowfishKey() []byte

getBlowfishKey calculates the key required to decrypt the blowfish-encrypted file

func (*Track) GetDownloadURL

func (track *Track) GetDownloadURL(format Format) (*url.URL, error)

GetDownloadURL gets the download url (as a *url.URL) for a given format

func (*Track) GetMD5

func (track *Track) GetMD5() error

GetMD5 uses an alternative API to get the MD5 of the track

Jump to

Keyboard shortcuts

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