spotify

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtistObj

type ArtistObj struct {
	Name string `json:"name"`
}

type LdJson

type LdJson struct {
	Context     string          `json:"@context,omitempty"`
	Type        string          `json:"@type"`
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	Image       []string        `json:"image"`
	ByArtist    json.RawMessage `json:"byArtist"`
	Audio       struct {
		ContentURL string `json:"contentUrl"`
		Duration   string `json:"duration,omitempty"`
	} `json:"audio"`
	Duration  string `json:"duration,omitempty"`
	Date      string `json:"datePublished,omitempty"`
	ReleaseOf struct {
		DatePublished string `json:"datePublished,omitempty"`
	} `json:"releaseOf,omitempty"`
	Track []struct {
		ItemListElement []struct {
			Item struct {
				Name       string          `json:"name"`
				PreviewURL string          `json:"previewUrl"`
				URL        string          `json:"url"`
				ByArtist   json.RawMessage `json:"byArtist"`
				Audio      struct {
					ContentURL string `json:"contentUrl"`
					Duration   string `json:"duration,omitempty"`
				} `json:"audio"`
				Duration      string `json:"duration,omitempty"`
				DatePublished string `json:"datePublished,omitempty"`
			} `json:"item"`
		} `json:"itemListElement"`
	} `json:"track"`
}

type Provider

type Provider interface {
	Name() string
	BaseURL() string
	Stream(url string) (string, error)
}

func DefaultProviders

func DefaultProviders(client *http.Client) []Provider

Provider list

type SearchResponse

type SearchResponse struct {
	Query        string         `json:"query"`
	Type         string         `json:"type"`
	Limit        int            `json:"limit"`
	TotalResults int            `json:"total_results"`
	Results      []SearchResult `json:"results"`
}

type SearchResult

type SearchResult struct {
	ID          string `json:"id"`
	URL         string `json:"url"`
	Image       string `json:"image"`
	Duration    int    `json:"duration,omitempty"`
	Artists     string `json:"artists"`
	Type        string `json:"type"`
	Name        string `json:"name"`
	Album       string `json:"album,omitempty"`
	ReleaseDate string `json:"release_date"`
	PreviewURL  string `json:"preview_url,omitempty"`
}

type SpotifyData

type SpotifyData struct {
	Type        string      `json:"type"`
	Name        string      `json:"name"`
	Artist      string      `json:"artist"`
	SpotifyID   string      `json:"spotify_id"`
	URL         string      `json:"url"`
	Image       string      `json:"image"`
	PreviewURL  string      `json:"preview_url,omitempty"`
	Tracks      []TrackInfo `json:"tracks"`
	Duration    int         `json:"duration,omitempty"`
	ReleaseDate string      `json:"release_date,omitempty"`
}

type SpotifyService

type SpotifyService struct {
	Client    *http.Client
	Providers []Provider
}

func NewSpotify

func NewSpotify(client *http.Client) *SpotifyService

func (*SpotifyService) AddAlbumTrack added in v1.1.0

func (s *SpotifyService) AddAlbumTrack(item struct {
	Name       string          `json:"name"`
	PreviewURL string          `json:"previewUrl"`
	URL        string          `json:"url"`
	ByArtist   json.RawMessage `json:"byArtist"`
	Audio      struct {
		ContentURL string `json:"contentUrl"`
		Duration   string `json:"duration,omitempty"`
	} `json:"audio"`
	Duration      string `json:"duration,omitempty"`
	DatePublished string `json:"datePublished,omitempty"`
}, data *SpotifyData)

func (*SpotifyService) AddTrackFromLdJson added in v1.1.0

func (s *SpotifyService) AddTrackFromLdJson(ld *LdJson, data *SpotifyData)

func (*SpotifyService) CreateSingleTrackEntry added in v1.1.0

func (s *SpotifyService) CreateSingleTrackEntry(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) EnhanceTrackData added in v1.2.2

func (s *SpotifyService) EnhanceTrackData(data *SpotifyData)

func (*SpotifyService) ExtractArtistNames added in v1.1.0

func (s *SpotifyService) ExtractArtistNames(artists []interface{}) []string

func (*SpotifyService) ExtractBasicData added in v1.1.0

func (s *SpotifyService) ExtractBasicData(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ExtractEntity added in v1.1.0

func (s *SpotifyService) ExtractEntity(generic map[string]interface{}) map[string]interface{}

func (*SpotifyService) ExtractEntityAlternative added in v1.2.2

func (s *SpotifyService) ExtractEntityAlternative(generic map[string]interface{}) map[string]interface{}

func (*SpotifyService) ExtractPlaylistOrAlbumArtist added in v1.1.0

func (s *SpotifyService) ExtractPlaylistOrAlbumArtist(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ExtractPlaylistOrAlbumReleaseDate added in v1.1.0

func (s *SpotifyService) ExtractPlaylistOrAlbumReleaseDate(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ExtractReleaseDate

func (s *SpotifyService) ExtractReleaseDate(description string) string

func (*SpotifyService) ExtractTrackArtist added in v1.1.0

func (s *SpotifyService) ExtractTrackArtist(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ExtractTrackArtistFromMap added in v1.1.0

func (s *SpotifyService) ExtractTrackArtistFromMap(trackMap map[string]interface{}) string

func (*SpotifyService) ExtractTrackDuration added in v1.1.0

func (s *SpotifyService) ExtractTrackDuration(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ExtractTrackDurationFromMap added in v1.1.0

func (s *SpotifyService) ExtractTrackDurationFromMap(trackMap map[string]interface{}) int

func (*SpotifyService) ExtractTrackName added in v1.1.0

func (s *SpotifyService) ExtractTrackName(trackMap map[string]interface{}) string

func (*SpotifyService) ExtractTrackPreviewURL added in v1.1.0

func (s *SpotifyService) ExtractTrackPreviewURL(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ExtractTrackPreviewURLFromMap added in v1.1.0

func (s *SpotifyService) ExtractTrackPreviewURLFromMap(trackMap map[string]interface{}) string

func (*SpotifyService) ExtractTrackReleaseDate added in v1.1.0

func (s *SpotifyService) ExtractTrackReleaseDate(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) FetchEmbedData

func (s *SpotifyService) FetchEmbedData(data *SpotifyData)

func (*SpotifyService) GetInfo

func (s *SpotifyService) GetInfo(url string) (SpotifyData, error)

func (*SpotifyService) ParseArtistRaw

func (s *SpotifyService) ParseArtistRaw(raw json.RawMessage) string

func (*SpotifyService) ParseDurationToSeconds

func (s *SpotifyService) ParseDurationToSeconds(durationStr string) (int, error)

func (*SpotifyService) ParseNextData

func (s *SpotifyService) ParseNextData(jsonStr string, data *SpotifyData)

func (*SpotifyService) ParsePlaylistOrAlbumData added in v1.1.0

func (s *SpotifyService) ParsePlaylistOrAlbumData(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ParseSingleTrackData added in v1.1.0

func (s *SpotifyService) ParseSingleTrackData(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ProcessLdJson

func (s *SpotifyService) ProcessLdJson(ld *LdJson, data *SpotifyData)

func (*SpotifyService) ProcessLdJsonScript added in v1.1.0

func (s *SpotifyService) ProcessLdJsonScript(scriptText string, data *SpotifyData)

func (*SpotifyService) ProcessMusicAlbum added in v1.1.0

func (s *SpotifyService) ProcessMusicAlbum(ld *LdJson, data *SpotifyData)

func (*SpotifyService) ProcessMusicPlaylist added in v1.1.0

func (s *SpotifyService) ProcessMusicPlaylist(ld *LdJson, data *SpotifyData)

func (*SpotifyService) ProcessMusicRecording added in v1.1.0

func (s *SpotifyService) ProcessMusicRecording(ld *LdJson, data *SpotifyData)

func (*SpotifyService) ProcessSingleTrack added in v1.1.0

func (s *SpotifyService) ProcessSingleTrack(trackMap map[string]interface{}, data *SpotifyData)

func (*SpotifyService) ProcessTrackList added in v1.1.0

func (s *SpotifyService) ProcessTrackList(entity map[string]interface{}, data *SpotifyData)

func (*SpotifyService) Search

func (s *SpotifyService) Search(query string, searchType ...string) (*SearchResponse, error)

func (*SpotifyService) Stream

func (s *SpotifyService) Stream(url string) (StreamResult, error)

type StreamResult

type StreamResult struct {
	URL    string        `json:"url"`
	ID     string        `json:"id"`
	Type   string        `json:"type"`
	Source []TrackSource `json:"source"`
}

type TrackInfo

type TrackInfo struct {
	Name        string `json:"name"`
	Artist      string `json:"artist"`
	PreviewURL  string `json:"preview_url"`
	URL         string `json:"url"`
	Duration    int    `json:"duration"`
	ReleaseDate string `json:"release_date"`
	Image       string `json:"image"`
}

type TrackSource

type TrackSource struct {
	Title       string `json:"title"`
	Artist      string `json:"artist"`
	Image       string `json:"image"`
	URL         string `json:"url"`
	Duration    int    `json:"duration"`
	ReleaseDate string `json:"release_date"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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