spotify

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 12 Imported by: 0

README

SpotifyGoWrapper

Installation and Usage

import "github.com/tomsteer1/SpotifyGoWrapper"

The LoadConfig function will initalise the wrapper

spotify.conf

client_id: <Insert Client ID>
client_secret: <Insert Client Secret>
token:
refresh_token: 
expiry:
redirect_uri: http://localhost:8080/callback
auth_type: <User or Client>
scope: <Insert Scopes seperated with %20>
enable_logs: <true/false>

func LoadConfig

func LoadConfig()

Loads the local file spotify.conf

func RefreshToken

func RefreshToken()

Refreshes the token if using the user auth type

func GetCurrentSong

func GetCurrentSong() CurrentTrack

Will return the currently playing track

func GetPlaylist

func GetPlaylist(playlist_id string) Playlist 

Gets the information about the playlist

func AddTrackToPlaylist

func AddTrackToPlaylist(playlist_id string, track_id string) bool

Adds a single track of track_id to the playlist of playlist_id

func AddTracksToPlaylist

func AddTracksToPlaylist(playlist_id string, track_ids []string) bool

Adds multiple tracks to the playlist of playlist_id

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTrackToPlaylist

func AddTrackToPlaylist(playlist_id string, track_id string) bool

func AddTracksToPlaylist

func AddTracksToPlaylist(playlist_id string, track_ids []string) bool

func LoadConfig

func LoadConfig(filePath ...string)

func RefreshToken

func RefreshToken()

Types

type Album

type Album struct {
	Album_type    string   `json:"album_type"`
	Artists       []Artist `json:"artists"`
	External_urls struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Href                   string  `json:"href"`
	Id                     string  `json:"id"`
	Images                 []Image `json:"images"`
	Name                   string  `json:"name"`
	Release_date           string  `json:"release_date"`
	Release_date_precision string  `json:"release_date_precision"`
	Total_tracks           int     `json:"total_tracks"`
	Type                   string  `json:"type"`
	Uri                    string  `json:"uri"`
}

type Artist

type Artist struct {
	External_urls struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Href string `json:"href"`
	Id   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
	Uri  string `json:"uri"`
}

type Auth_Response

type Auth_Response struct {
	Access_token  string `json:"access_token"`
	Token_type    string `json:"token_type"`
	Expires_in    int    `json:"expires_in"`
	Refresh_token string `json:"refresh_token"`
}

type ConfigFile

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

type CurrentTrack

type CurrentTrack struct {
	Item        Track `json:"item"`
	Progress_ms int   `json:"progress_ms"`
	Timestamp   int   `json:"timestamp"`
	Is_playing  bool  `json:"is_playing"`
}

func GetCurrentSong

func GetCurrentSong() CurrentTrack

type Image

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

type Playlist

type Playlist struct {
	Href  string `json:"href"`
	Id    string `json:"id"`
	Name  string `json:"name"`
	Owner struct {
		Display_name  string `json:"display_name"`
		External_urls struct {
			Spotify string `json:"spotify"`
		} `json:"external_urls"`
		Href string `json:"href"`
		Id   string `json:"id"`
		Type string `json:"type"`
		Uri  string `json:"uri"`
	} `json:"owner"`
	Public        bool `json:"public"`
	Collaborative bool `json:"collaborative"`
	Followers     struct {
		Href  interface{} `json:"href"`
		Total int         `json:"total"`
	} `json:"followers"`
	Images []Image `json:"images"`
	Tracks struct {
		Href  string `json:"href"`
		Total int    `json:"total"`
		Item  []struct {
			Added_at string `json:"added_at"`
			Added_by struct {
				External_urls struct {
					Spotify string `json:"spotify"`
				} `json:"external_urls"`
				Href string `json:"href"`
				Id   string `json:"id"`
				Type string `json:"type"`
				Uri  string `json:"uri"`
			} `json:"added_by"`
			Is_local bool  `json:"is_local"`
			Track    Track `json:"track"`
		} `json:"items"`
	} `json:"tracks"`
	Type string `json:"type"`
	Uri  string `json:"uri"`
}

func GetPlaylist

func GetPlaylist(playlist_id string) Playlist

type Track

type Track struct {
	Album        Album    `json:"album"`
	Artists      []Artist `json:"artists"`
	Disc_number  int      `json:"disc_number"`
	Duration_ms  int      `json:"duration_ms"`
	Explicit     bool     `json:"explicit"`
	External_ids struct {
		Isrc string `json:"isrc"`
	} `json:"external_ids"`
	External_urls struct {
		Spotify string `json:"spotify"`
	} `json:"external_urls"`
	Href         string `json:"href"`
	Id           string `json:"id"`
	Is_local     bool   `json:"is_local"`
	Name         string `json:"name"`
	Popularity   int    `json:"popularity"`
	Preview_url  string `json:"preview_url"`
	Track_number int    `json:"track_number"`
	Type         string `json:"type"`
	Uri          string `json:"uri"`
}

Jump to

Keyboard shortcuts

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