spotify

package
v0.0.0-...-9625bed Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: GPL-3.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TerribleSongNames = []string{
	"acapella",
	"acappella",
	"as made famous",
	"in the style of",
	"in style of",
	"karaoke",
	"made famous by",
	"originally performed by",
	"reprise",
	"tribute",
}

Functions

func CalculateMatchRatio

func CalculateMatchRatio(radio string, spotify *ImmutableSpotifyTrack) int

Calculates match ratio between song name stored in a string from radio (e.g. "Artist - Some song") and a given SpotifyTrack. Returns match ratio from 0 to 100, anything below 75 is bad quality, while 50 and less is probably worthless.

Types

type Cache

type Cache interface {
	// Playlist cache methods
	Add(playlistId string, track *ImmutableSpotifyTrack) error
	ReplaceAll(playlistId string, tracks []*ImmutableSpotifyTrack) error
	Remove(playlistId string, track *ImmutableSpotifyTrack) error
	Get(playlistId string) []*ImmutableSpotifyTrack
	IsCached(playlistId string) bool
}

type ImmutableSpotifyTrack

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

func (*ImmutableSpotifyTrack) Artist

func (t *ImmutableSpotifyTrack) Artist() string

func (*ImmutableSpotifyTrack) Id

func (t *ImmutableSpotifyTrack) Id() string

func (*ImmutableSpotifyTrack) String

func (t *ImmutableSpotifyTrack) String() string

func (*ImmutableSpotifyTrack) Title

func (t *ImmutableSpotifyTrack) Title() string

type PlaylistItem

type PlaylistItem struct {
	Track SpotifyTrack
}

type PlaylistResponse

type PlaylistResponse struct {
	Items []PlaylistItem
	Total int
	Next  string
}

type SearchResponse

type SearchResponse struct {
	Tracks SearchResponseBody
}

type SearchResponseBody

type SearchResponseBody struct {
	Items []SpotifyTrack
}

type Spotify

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

func New

func New(ctx context.Context, market string) (*Spotify, error)

func (*Spotify) AddToPlaylist

func (s *Spotify) AddToPlaylist(ctx context.Context, playlistId string, track *ImmutableSpotifyTrack) error

func (*Spotify) FindTracks

func (s *Spotify) FindTracks(ctx context.Context, query string) ([]*ImmutableSpotifyTrack, error)

func (*Spotify) ListLiked

func (s *Spotify) ListLiked(ctx context.Context) ([]*ImmutableSpotifyTrack, error)

func (*Spotify) ListPlaylist

func (s *Spotify) ListPlaylist(ctx context.Context, playlistId string) ([]*ImmutableSpotifyTrack, error)

func (*Spotify) ListPlaylistWithFilter

func (s *Spotify) ListPlaylistWithFilter(ctx context.Context, playlistId string, filter func(SpotifyTrack) bool) ([]*ImmutableSpotifyTrack, error)

func (*Spotify) RemoveFromPlaylist

func (s *Spotify) RemoveFromPlaylist(ctx context.Context, playlistId string, track *ImmutableSpotifyTrack) error

type SpotifyAlbum

type SpotifyAlbum struct {
	Id      string
	Name    string
	Artists []SpotifyArtist
}

type SpotifyArtist

type SpotifyArtist struct {
	Id   string
	Name string
}

type SpotifyTrack

type SpotifyTrack struct {
	Id               string
	Name             string
	DurationMs       int64 `json:"duration_ms"`
	Popularity       int
	Artists          []SpotifyArtist
	Album            SpotifyAlbum
	AvailableMarkets []string `json:"available_markets"`
}

func (SpotifyTrack) ArtistAsString

func (t SpotifyTrack) ArtistAsString() string

func (SpotifyTrack) String

func (t SpotifyTrack) String() string

Jump to

Keyboard shortcuts

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