utils

package
v0.0.0-...-ff7dc16 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Banner()

Banner prints out the name of cli tool

func OpenInBrowser

func OpenInBrowser(url string) error

OpenInBrowser opens a given url in the default browser based on each platform

Types

type AlbumArt

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

AlbumArt to hold images

type ExternalId

type ExternalId struct {
	Isrc string `json:"isrc"`
	Ean  string `json:"ean"`
	Upc  string `json:"upc"`
}

ExternalId struct for storing external urls to spotify

type ExternalUrl

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

ExternalUrl struct for storing external urls to spotify

type FullSoundtrack

type FullSoundtrack struct {
	Album            SimplifiedAlbum    `json:"album"`
	Artists          []SimplifiedArtist `json:"artists"`
	AvailableMarkets []string           `json:"available_markets"`
	DiscNumber       int                `json:"disc_number"`
	DurationMs       int                `json:"duration_ms"`
	Explicit         bool               `json:"explicit"`
	ExternalIds      ExternalId         `json:"external_ids"`
	ExternalUrls     ExternalUrl        `json:"external_urls"`
	Href             string             `json:"href"`
	Id               string             `json:"id"`
	IsPlayable       bool               `json:"is_playable"`
	LinkedFrom       string             `json:"linked_from"`
	Restrictions     string             `json:"restrictions"`
	Name             string             `json:"name"`
	Popularity       int                `json:"popularity"`
	PreviewUrl       string             `json:"preview_url"`
	TrackNumber      int                `json:"track_number"`
	Type             string             `json:"type"`
	Uri              string             `json:"uri"`
	IsLocal          bool               `json:"is_local"`
}

FullSoundtrack for working with storing full soundtrack object

type OAuthToken

type OAuthToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

OAuthToken struct used for working with OAuth token

func TestAndSetToken

func TestAndSetToken() (OAuthToken, error)

TestAndSetToken returns an OAuthToken if it can be retrieved from TOKEN_FILE

func (*OAuthToken) GetNewAccessToken

func (token *OAuthToken) GetNewAccessToken() error

GetNewAccessToken returns a new access token and also writes the new tokens in TOKEN_FILE

func (*OAuthToken) SaveTokenToFile

func (token *OAuthToken) SaveTokenToFile(r *http.Response, refreshed bool) error

SaveTokenToFile retrieves access-token and refresh-token from http.Response and persists them to TOKEN_FILE

func (*OAuthToken) ValidateAccessToken

func (token *OAuthToken) ValidateAccessToken() error

ValidateAccessToken checks if access-token has expired or not by hitting Spotify

type RetryRequest

type RetryRequest struct {
	Attempt  int
	Max      int
	Min      int
	Duration time.Duration
}

RetryRequest is a mechanism to retry http requests after sometime

func (*RetryRequest) Backoff

func (r *RetryRequest) Backoff(cooldownTime int)

Backoff sets a time.Duration after which one should retry sending an http request

type SimplifiedAlbum

type SimplifiedAlbum struct {
	AlbumType            string             `json:"album_type"`
	Artists              []SimplifiedArtist `json:"artists"`
	AvailableMarkets     []string           `json:"available_markets"`
	ExternalUrls         ExternalUrl        `json:"external_urls"`
	Href                 string             `json:"href"`
	Id                   string             `json:"id"`
	Images               []AlbumArt         `json:"images"`
	Name                 string             `json:"name"`
	ReleaseDate          string             `json:"release_date"`
	ReleaseDatePrecision string             `json:"release_date_precision"`
	Restrictions         string             `json:"restrictions"`
	Type                 string             `json:"type"`
	Uri                  string             `json:"uri"`
}

AlbumItems to hold an array of Album

type SimplifiedArtist

type SimplifiedArtist struct {
	Href         string      `json:"href"`
	Id           string      `json:"id"`
	Name         string      `json:"name"`
	Type         string      `json:"artist"`
	Uri          string      `json:"uri"`
	ExternalUrls ExternalUrl `json:"external_urls"`
}

SimplifiedArtist to hold an artist's info

type SimplifiedSoundtrack

type SimplifiedSoundtrack struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

Soundtrack for working with sound tracks obtained from albums

Jump to

Keyboard shortcuts

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