spotify

package
v0.0.0-...-f539960 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SpotifyClientID : Spotify app client ID
	SpotifyClientID = ":SPOTIFY_CLIENT_ID:"
	// SpotifyClientSecret : Spotify app client secret key
	SpotifyClientSecret = ":SPOTIFY_CLIENT_SECRET:"
)
View Source
const (
	// SpotifyRedirectURL : Spotify app redirect URL
	SpotifyRedirectURL = "http://%s:8080/callback"
	// SpotifyFaviconURL : Spotify app redirect URL's favicon
	SpotifyFaviconURL = "https://spotify.com/favicon.ico"
	// SpotifyHTMLAutoCloseTimeout : Spotify app redirect URL's autoclose timeout
	SpotifyHTMLAutoCloseTimeout = "5" // s
	// SpotifyHTMLAutoCloseTimeoutMs : Spotify app redirect URL's autoclose timeout in ms (automatically parsed from SpotifyHTMLAutoCloseTimeout)
	SpotifyHTMLAutoCloseTimeoutMs = SpotifyHTMLAutoCloseTimeout + "000" // ms
	// SpotifyHTMLSigAuthor : Spotify app redirect URL's footer quoted author
	SpotifyHTMLSigAuthor = "streambinder"
	// SpotifyHTMLSigIcon : Spotify app redirect URL's footer quoted author icon
	SpotifyHTMLSigIcon = "" /* 9092-byte string literal not displayed */
	// SpotifyHTMLTemplate : Spotify app redirect URLS's template
	SpotifyHTMLTemplate = `<!DOCTYPE html>
		<html>
		<head>
			<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
			<title>SpotiTube</title>
			<link rel="icon" href="` + SpotifyFaviconURL + `" type="image/x-icon" />
			<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
			<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed" />
			<style>
				body               { font: 20px 'Roboto Condensed', sans-serif; text-align: center; margin: 75px 0; padding: 50px; color: #333; border: solid 5px #1ED760; border-left: none; border-right: none; }
				body *             { text-align: center; }
				h1                 { font-size: 40px; text-transform: uppercase; }
				h1>i.fa            { margin: auto 10px; }
				article            { display: block; text-align: left; width: 650px; margin: 0 auto 50px; }
				a                  { color: #dc8100; text-decoration: none; }
				a:hover            { color: #333; text-decoration: none; }
				p.timer            { font-size: 14px; color: #A0A0A0; text-align: center; text-transform: uppercase; }
				div.signature      { border: 1px solid rgba(0, 0, 0, 0.05); border-radius: 5px; text-align: center; }
				div.signature>img  { width: 35px; vertical-align: middle; }
				div.signature>span { font-size: 15px; color: #505050; }
			</style>
			<script type="text/javascript">
				var timeleft = ` + SpotifyHTMLAutoCloseTimeout + `;
				var downloadTimer = setInterval(function() {
					timeleft--;
					document.getElementById("timer").textContent = timeleft;
					if(timeleft <= 0)
						clearInterval(downloadTimer);
				}, 1000);
				function setAutoClose() { window.setTimeout(autoClose, ` + SpotifyHTMLAutoCloseTimeoutMs + `); }
				function autoClose() { window.close(); }
			</script>
		</head>
		<body onLoad="setAutoClose()">
			<article>
				<h1><i class="fa fa-thumbs-up" aria-hidden="true"></i><br>%s</h1>
				<div>
					<h3>%s</h3>
					<br><br><br>
					<p class="timer">Window will attempt to close in <span id="timer">` + SpotifyHTMLAutoCloseTimeout + `</span> seconds.</p>
					<br>
					<div class="signature">
						<img src="` + SpotifyHTMLSigIcon + `"/>
						<span>` + SpotifyHTMLSigAuthor + `</span>
					</div>
				</div>
			</article>
		</body>
		</html>`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Album

type Album = spotify.FullAlbum

Album is an alias for Spotify FullAlbum

type AuthURL

type AuthURL struct {
	Full  string
	Short string
}

AuthURL : struct object containing both the full authentication URL provided by Spotify and the shortened one using TinyURL

func BuildAuthURL

func BuildAuthURL(callbackHost string) *AuthURL

BuildAuthURL : generate new authentication URL

type Client

type Client struct {
	*spotify.Client
	AuthChan chan *spotify.Client
}

Client : struct object containing all the informations needed to authenticate and fetch from Spotify

func Auth

func Auth(url string, authHost string, xdgOpen bool) (*Client, error)

Auth : start local callback server to handle xdg-preferred browser authentication redirection

func (*Client) Album

func (c *Client) Album(id ID) (*Album, error)

Album returns a Spotify FullAlbum, specular to the array of Spotify ID

func (*Client) AlbumTracks

func (c *Client) AlbumTracks(uri string) ([]*track.Track, error)

AlbumTracks returns the array of tracks contained in it

func (*Client) LibraryTracks

func (c *Client) LibraryTracks() ([]*track.Track, error)

LibraryTracks : return array of Spotify FullTrack of all authenticated user library songs

func (*Client) Playlist

func (c *Client) Playlist(uri string) (*Playlist, error)

Playlist : return Spotify FullPlaylist from input string playlistURI

func (*Client) PlaylistTracks

func (c *Client) PlaylistTracks(uri string) ([]*track.Track, error)

PlaylistTracks : return array of Spotify FullTrack of all input string playlistURI identified playlist

func (*Client) RemoveLibraryTracks

func (c *Client) RemoveLibraryTracks(ids []ID) error

RemoveLibraryTracks : remove an array of tracks by their IDs from library

func (*Client) RemovePlaylistTracks

func (c *Client) RemovePlaylistTracks(uri string, ids []ID) error

RemovePlaylistTracks : remove an array of tracks by their IDs from playlist

func (*Client) User

func (c *Client) User() (string, string)

User : get authenticated username from authenticated client

type ID

type ID = spotify.ID

ID is an alias for Spotify ID

func IDFromURI

func IDFromURI(uri string) ID

IDFromURI return a Spotify ID from URI string

type Playlist

type Playlist = spotify.FullPlaylist

Playlist is an alias for Spotify FullPlaylist

type Track

type Track = spotify.FullTrack

Track is an alias for Spotify FullTrack

Jump to

Keyboard shortcuts

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