deezer

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FLAC    Format = 9
	MP3_320        = 3
	MP3_256        = 5
)

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) 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 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