spotify

package
v0.0.0-...-a8d8f77 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ApiUrl = "https://api.spotify.com/v1"
View Source
const AuthApiUrl = "https://accounts.spotify.com/api"
View Source
const CheckSavedTracksPath = "/me/tracks/contains"
View Source
const SpotifyUserIdSessionKey = "spotifyUserId"

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

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

func NewApi

func NewApi(config *config.Config, ds *data_store.DataStore) *Api

func NewAuthenticatedApi

func NewAuthenticatedApi(config *config.Config, ds *data_store.DataStore, spotifyUser *data_store.SpotifyUser, session *sessions.Session, w http.ResponseWriter, r *http.Request) *Api

func (*Api) SearchTracks

func (a *Api) SearchTracks(artist, album, track string, limit int, offset int) (*SearchResponse, *util.RequestError)

https://developer.spotify.com/documentation/web-api/reference/search

type CheckSavedTracksResponse

type CheckSavedTracksResponse map[string]bool

type ExternalUrls

type ExternalUrls struct {
	Spotify string `json:"spotify"`
}

type GetCurrentUserResponse

type GetCurrentUserResponse struct {
	DisplayName  string `json:"display_name"`
	Href         string `json:"href"`
	Id           string `json:"id"`
	ExternalUrls struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Images []struct {
		Height int    `json:"height"`
		Url    string `json:"url"`
		Width  int    `json:"width"`
	} `json:"images"`
}

type GetTokenResponse

type GetTokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

type Image

type Image struct {
	Height int    `json:"height"`
	Width  int    `json:"width"`
	Url    string `json:"url"`
}

type SaveTracksRequestBody

type SaveTracksRequestBody struct {
	TrackIds []string `json:"ids"`
}

type SearchResponse

type SearchResponse struct {
	Tracks struct {
		Href  string `json:"href"`
		Total int    `json:"total"`
		Items []struct {
			DiscNumber   int          `json:"disc_number"`
			DurationMs   int          `json:"duration_ms"`
			Explicit     bool         `json:"explicit"`
			ExternalUrls ExternalUrls `json:"external_urls"`
			Href         string       `json:"href"`
			Id           string       `json:"id"`
			Name         string       `json:"name"`
			TrackNumber  int          `json:"track_number"`
			Uri          string       `json:"uri"`
			Album        struct {
				AlbumType string `json:"album_type"`
				Artists   []struct {
					ExternalUrls ExternalUrls `json:"external_urls"`
					Href         string       `json:"href"`
					Id           string       `json:"id"`
					Name         string       `json:"name"`
					Uri          string       `json:"uri"`
				} `json:"artists"`
				ExternalUrls         ExternalUrls `json:"external_urls"`
				Href                 string       `json:"href"`
				Id                   string       `json:"id"`
				Images               []Image      `json:"images"`
				Name                 string       `json:"name"`
				ReleaseDate          string       `json:"release_date"`
				ReleaseDatePrecision string       `json:"release_date_precision"`
				TotalTracks          int          `json:"total_tracks"`
				Uri                  string       `json:"uri"`
			} `json:"album"`
			Artists []struct {
				ExternalUrls ExternalUrls `json:"external_urls"`
				Genres       []string     `json:"genres"`
				Href         string       `json:"href"`
				Id           string       `json:"id"`
				Images       []Image      `json:"images"`
				Name         string       `json:"name"`
				Uri          string       `json:"uri"`
			} `json:"artists"`
		} `json:"items"`
	} `json:"tracks"`
}

Jump to

Keyboard shortcuts

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