deezer

package
v0.40.3 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Single = iota
	Album
	Split
	EP
	UnknownType
)
View Source
const (
	APIEndPoint = "https://api.deezer.com"
)

Variables

This section is empty.

Functions

func ExtractDeezerAlbumID added in v0.39.2

func ExtractDeezerAlbumID(urlOrID string) (int, error)

Types

type Ajax added in v0.18.0

type Ajax struct {
	Error   []interface{} `json:"error"`
	Results struct {
		Count int `json:"count"`
		Data  []struct {
			Duration            string           `json:"DURATION"`
			DiskNumber          string           `json:"DISK_NUMBER"`
			DigitalReleaseDate  string           `json:"DIGITAL_RELEASE_DATE"`
			PhysicalReleaseDate string           `json:"PHYSICAL_RELEASE_DATE"`
			ArtistName          string           `json:"ART_NAME"`
			AlbumID             string           `json:"ALB_ID"`
			AlbumPicture        string           `json:"ALB_PICTURE"`
			AlbumTitle          string           `json:"ALB_TITLE"`
			Md5                 string           `json:"MD5_ORIGIN"`
			SongID              string           `json:"SNG_ID"`
			SongTitle           string           `json:"SNG_TITLE"`
			Version             string           `json:"VERSION"`
			SongContributors    SongContributors `json:"SNG_CONTRIBUTORS,omitempty"`
			Status              int              `json:"STATUS"`
			TrackNumber         string           `json:"TRACK_NUMBER"`
			TrackToken          string           `json:"TRACK_TOKEN"`
			FlacSize            string           `json:"FILESIZE_FLAC"`
			Type                int              `json:"TYPE"`
			UserID              int              `json:"USER_ID"`
			MediaVersion        string           `json:"MEDIA_VERSION"`
			TYPE2               string           `json:"__TYPE__"`
			ISRC                string           `json:"ISRC"`
		} `json:"data"`
		FilteredCount int `json:"filtered_count"`
		Total         int `json:"total"`
	} `json:"results"`
}

type Deezer

type Deezer struct {
	ArlCookie string
	SidCookie string

	LicenseToken string
	Client       *http.Client
	// contains filtered or unexported fields
}

Deezer structure for querying its API.

func New

func New(arl, sid string) *Deezer

New Deezer structure. api key can be blank for now.

func (*Deezer) GetAjaxAlbumInfo added in v0.21.0

func (d *Deezer) GetAjaxAlbumInfo(id int) (*Ajax, error)

func (*Deezer) GetCover added in v0.18.0

func (d *Deezer) GetCover(id int) (string, error)

func (*Deezer) GetDiscographyInfo added in v0.39.0

func (d *Deezer) GetDiscographyInfo(artistID int) (*Discography, error)

func (*Deezer) GetRelease added in v0.18.0

func (d *Deezer) GetRelease(id int) (*Release, error)

GetRelease from the API. Returns the complete response.

func (*Deezer) GetTrackIDsFromAlbumID

func (d *Deezer) GetTrackIDsFromAlbumID(id int) ([]int, error)

GetTrackIDsFromAlbumID returns a list of tracks ids.

func (*Deezer) SearchArtist added in v0.39.0

func (d *Deezer) SearchArtist(artist string) (*SearchResult, error)

type Discography added in v0.39.0

type Discography struct {
	Error   []interface{} `json:"error"`
	Results struct {
		ArtID        int64 `json:"art_id"`
		CacheVersion int64 `json:"cache_version"`
		Count        int64 `json:"count"`
		Data         []struct {
			AlbID      string `json:"ALB_ID"`
			AlbPicture string `json:"ALB_PICTURE"`
			AlbTitle   string `json:"ALB_TITLE"`
			Artists    []struct {
				ArtistsAlbumsOrder string `json:"ARTISTS_ALBUMS_ORDER"`
				ArtistIsDummy      bool   `json:"ARTIST_IS_DUMMY"`
				ArtID              string `json:"ART_ID"`
				ArtName            string `json:"ART_NAME"`
				ArtPicture         string `json:"ART_PICTURE"`
				Rank               string `json:"RANK"`
				RoleID             string `json:"ROLE_ID"`
				Type               string `json:"__TYPE__"`
			} `json:"ARTISTS"`
			ArtistsAlbumsIsOfficial bool   `json:"ARTISTS_ALBUMS_IS_OFFICIAL"`
			ArtID                   string `json:"ART_ID"`
			ArtName                 string `json:"ART_NAME"`
			Copyright               string `json:"COPYRIGHT"`
			DigitalReleaseDate      string `json:"DIGITAL_RELEASE_DATE"`
			ExplicitAlbumContent    struct {
				ExplicitCoverStatus  int64 `json:"EXPLICIT_COVER_STATUS"`
				ExplicitLyricsStatus int64 `json:"EXPLICIT_LYRICS_STATUS"`
			} `json:"EXPLICIT_ALBUM_CONTENT"`
			ExplicitLyrics      string `json:"EXPLICIT_LYRICS"`
			GenreID             string `json:"GENRE_ID"`
			Highlight           string `json:"HIGHLIGHT"`
			MinorGenreID        string `json:"MINOR_GENRE_ID"`
			NumberDisk          string `json:"NUMBER_DISK"`
			NumberTrack         string `json:"NUMBER_TRACK"`
			PhysicalReleaseDate string `json:"PHYSICAL_RELEASE_DATE"`
			ProducerLine        string `json:"PRODUCER_LINE"`
			ProviderID          string `json:"PROVIDER_ID"`
			Rank                string `json:"RANK"`
			RoleID              int64  `json:"ROLE_ID"`
			Status              string `json:"STATUS"`
			Type                string `json:"TYPE"`
			Type_               string `json:"__TYPE__"`
		} `json:"data"`
		FilteredCount int64 `json:"filtered_count"`
		Nb            int64 `json:"nb"`
		Start         int64 `json:"start"`
		Total         int64 `json:"total"`
	} `json:"results"`
}

type Release added in v0.18.0

type Release struct {
	Artist struct {
		ID            int    `json:"id"`
		Name          string `json:"name"`
		Picture       string `json:"picture"`
		PictureBig    string `json:"picture_big"`
		PictureMedium string `json:"picture_medium"`
		PictureSmall  string `json:"picture_small"`
		PictureXl     string `json:"picture_xl"`
		Tracklist     string `json:"tracklist"`
		Type          string `json:"type"`
	} `json:"artist"`
	Available    bool `json:"available"`
	Contributors []struct {
		ID            int    `json:"id"`
		Link          string `json:"link"`
		Name          string `json:"name"`
		Picture       string `json:"picture"`
		PictureBig    string `json:"picture_big"`
		PictureMedium string `json:"picture_medium"`
		PictureSmall  string `json:"picture_small"`
		PictureXl     string `json:"picture_xl"`
		Radio         bool   `json:"radio"`
		Role          string `json:"role"`
		Share         string `json:"share"`
		Tracklist     string `json:"tracklist"`
		Type          string `json:"type"`
	} `json:"contributors"`
	Cover                 string `json:"cover"`
	CoverBig              string `json:"cover_big"`
	CoverMedium           string `json:"cover_medium"`
	CoverSmall            string `json:"cover_small"`
	CoverXl               string `json:"cover_xl"`
	Duration              int    `json:"duration"`
	ExplicitContentCover  int    `json:"explicit_content_cover"`
	ExplicitContentLyrics int    `json:"explicit_content_lyrics"`
	ExplicitLyrics        bool   `json:"explicit_lyrics"`
	Fans                  int    `json:"fans"`
	GenreID               int    `json:"genre_id"`
	Genres                struct {
		Data []struct {
			ID      int    `json:"id"`
			Name    string `json:"name"`
			Picture string `json:"picture"`
			Type    string `json:"type"`
		} `json:"data"`
	} `json:"genres"`
	ID          int    `json:"id"`
	Label       string `json:"label"`
	Link        string `json:"link"`
	NbTracks    int    `json:"nb_tracks"`
	Rating      int    `json:"rating"`
	RecordType  string `json:"record_type"`
	ReleaseDate string `json:"release_date"`
	Share       string `json:"share"`
	Title       string `json:"title"`
	Tracklist   string `json:"tracklist"`
	Tracks      struct {
		Data []struct {
			Artist struct {
				ID        int    `json:"id"`
				Name      string `json:"name"`
				Tracklist string `json:"tracklist"`
				Type      string `json:"type"`
			} `json:"artist"`
			Duration              int    `json:"duration"`
			ExplicitContentCover  int    `json:"explicit_content_cover"`
			ExplicitContentLyrics int    `json:"explicit_content_lyrics"`
			ExplicitLyrics        bool   `json:"explicit_lyrics"`
			ID                    int    `json:"id"`
			Link                  string `json:"link"`
			Preview               string `json:"preview"`
			Rank                  int    `json:"rank"`
			Readable              bool   `json:"readable"`
			Title                 string `json:"title"`
			TitleShort            string `json:"title_short"`
			TitleVersion          string `json:"title_version"`
			Type                  string `json:"type"`
		} `json:"data"`
	} `json:"tracks"`
	Type string `json:"type"`
	Upc  string `json:"upc"`
}

func (*Release) ReleaseYear added in v0.18.0

func (r *Release) ReleaseYear() int

type SearchResult added in v0.39.0

type SearchResult struct {
	Error   []interface{} `json:"error"`
	Results struct {
		Album struct {
			Count int64 `json:"count"`
			Data  []struct {
				AlbID      string `json:"ALB_ID"`
				AlbPicture string `json:"ALB_PICTURE"`
				AlbTitle   string `json:"ALB_TITLE"`
				Artists    []struct {
					ArtistsAlbumsOrder string `json:"ARTISTS_ALBUMS_ORDER"`
					ArtistIsDummy      bool   `json:"ARTIST_IS_DUMMY"`
					ArtID              string `json:"ART_ID"`
					ArtName            string `json:"ART_NAME"`
					ArtPicture         string `json:"ART_PICTURE"`
					Rank               string `json:"RANK"`
					RoleID             string `json:"ROLE_ID"`
					Type               string `json:"__TYPE__"`
				} `json:"ARTISTS"`
				ArtistIsDummy        bool   `json:"ARTIST_IS_DUMMY"`
				ArtID                string `json:"ART_ID"`
				ArtName              string `json:"ART_NAME"`
				Available            bool   `json:"AVAILABLE"`
				ExplicitAlbumContent struct {
					ExplicitCoverStatus  int64 `json:"EXPLICIT_COVER_STATUS"`
					ExplicitLyricsStatus int64 `json:"EXPLICIT_LYRICS_STATUS"`
				} `json:"EXPLICIT_ALBUM_CONTENT"`
				NumberTrack         string `json:"NUMBER_TRACK"`
				PhysicalReleaseDate string `json:"PHYSICAL_RELEASE_DATE"`
				Type                string `json:"TYPE"`
				Version             string `json:"VERSION"`
				Type_               string `json:"__TYPE__"`
			} `json:"data"`
			FilteredCount int64   `json:"filtered_count"`
			FilteredItems []int64 `json:"filtered_items"`
			Next          int64   `json:"next"`
			Total         int64   `json:"total"`
		} `json:"ALBUM"`
		Artist struct {
			Count int64 `json:"count"`
			Data  []struct {
				ArtistIsDummy bool   `json:"ARTIST_IS_DUMMY"`
				ArtID         string `json:"ART_ID"`
				ArtName       string `json:"ART_NAME"`
				ArtPicture    string `json:"ART_PICTURE"`
				NbFan         int64  `json:"NB_FAN"`
				Type          string `json:"__TYPE__"`
			} `json:"data"`
			FilteredCount int64         `json:"filtered_count"`
			FilteredItems []interface{} `json:"filtered_items"`
			Next          int64         `json:"next"`
			Total         int64         `json:"total"`
		} `json:"ARTIST"`
		Fuzzinness   bool          `json:"FUZZINNESS"`
		Order        []string      `json:"ORDER"`
		Query        string        `json:"QUERY"`
		RevisedQuery string        `json:"REVISED_QUERY"`
		TopResult    []interface{} `json:"TOP_RESULT"`
	} `json:"results"`
}

type SongContributors added in v0.21.4

type SongContributors map[string][]string

SongContributors is defined because the response is either a map, or an empty slice.

func (*SongContributors) UnmarshalJSON added in v0.21.4

func (w *SongContributors) UnmarshalJSON(data []byte) error

UnmarshalJSON allows to unmarshall JSON with an empty slice as contributors, without throwing errors. Instead, the song contributors return an empty map.

type UserData added in v0.18.0

type UserData struct {
	Error   []interface{} `json:"error"`
	Results struct {
		CheckForm string `json:"checkForm"`
		User      struct {
			Options struct {
				LicenseCountry string `json:"license_country"`
				LicenseToken   string `json:"license_token"`
			} `json:"OPTIONS"`
		} `json:"USER"`
	} `json:"results"`
}

Jump to

Keyboard shortcuts

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