spotify

package
v0.0.0-...-dcb5cf5 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	ID       string        `json:"id,omitempty"`
	URI      string        `json:"uri,omitempty"`
	Name     string        `json:"name,omitempty"`
	Type     ItemType      `json:"type,omitempty"`
	Duration time.Duration `json:"duration,omitempty"`
	AddedAt  time.Time     `json:"added_at,omitempty"`
	// Only for episode type
	ReleaseDate string `json:"release_date,omitempty"`
	// For comparison
	ReleaseDateTime time.Time `json:"-"`
}

func (*Item) GetFallbackDate

func (i *Item) GetFallbackDate() time.Time

func (*Item) TryResolveReleaseDate

func (i *Item) TryResolveReleaseDate(ctx context.Context)

type ItemType

type ItemType string
const (
	ItemTypeTrack   ItemType = "track"
	ItemTypeEpisode ItemType = "episode"
)

type Playlist

type Playlist struct {
	ID          string  `json:"id,omitempty"`
	Name        string  `json:"name,omitempty"`
	Description string  `json:"description,omitempty"`
	IsPublic    bool    `json:"is_public,omitempty"`
	Items       []*Item `json:"items,omitempty"`
}

type PlaylistFilterConfig

type PlaylistFilterConfig struct {
	TargetPlaylistID string                  `json:"target_playlist_id" validate:"required"`
	Description      string                  `json:"description" validate:"omitempty"`
	Sources          []*PlaylistFilterSource `json:"sources" validate:"required,dive,required"`
	// OrderBy is the order of the items in the target playlist
	// For items having no added time (e.g. shows), the release date is used as fallback
	OrderBy                          PlaylistOrder `json:"order_by" validate:"omitempty,oneof=added_at release_date"`
	AddLatestUpdateDateToDescription bool          `json:"add_latest_update_date_to_description" validate:"-"`
	LatestUpdateDateLocation         string        `json:"latest_update_date_location" validate:"-"`
}

type PlaylistFilterConfigSlice

type PlaylistFilterConfigSlice []*PlaylistFilterConfig

type PlaylistFilterSource

type PlaylistFilterSource struct {
	PlaylistID string           `json:"playlist_id" validate:"required_without=ShowID"`
	ShowID     string           `json:"show_id" validate:"required_without=PlaylistID"`
	Filters    *PlaylistFilters `json:"filters" validate:"required"`
}

type PlaylistFilters

type PlaylistFilters struct {
	ItemNameRegexp string `json:"item_name_regexp" validate:"omitempty"`
	MinDuration    int64  `json:"min_duration" validate:"omitempty"`
	MaxDuration    int64  `json:"max_duration" validate:"omitempty"`
}

type PlaylistOrder

type PlaylistOrder string
const (
	PlaylistOrderAddedAt     PlaylistOrder = "added_at"
	PlaylistOrderReleaseDate PlaylistOrder = "release_date"
)

type Show

type Show struct {
	ID          string  `json:"id,omitempty"`
	Name        string  `json:"name,omitempty"`
	Description string  `json:"description,omitempty"`
	Episodes    []*Item `json:"episodes,omitempty"`
}

type Spotifier

type Spotifier interface {
	SpotifiyAuther
	SpotifyPlaylister
	SpotifyShower
}

type SpotifiyAuther

type SpotifiyAuther interface {
	// GetUserToken returns the latest user token, which may be expired.
	// If the token has never been fetched, this will run authorization process.
	GetUserToken(ctx context.Context) (string, error)
	// GetNewUserToken returns a new user token, which is never expired, using the refresh token if present
	// or running the authorization process otherwise.
	GetNewUserToken(ctx context.Context) (string, error)
	// ResetUserTokens resets the user tokens, including the refresh token.
	// This should be used only for testing
	ResetUserTokens(ctx context.Context)
}

type SpotifyPlaylister

type SpotifyPlaylister interface {
	GetPlaylist(ctx context.Context, playlistID string) (*Playlist, error)
	UpdatePlaylistFilter(ctx context.Context, filterConfig *PlaylistFilterConfig) error
}

type SpotifyShower

type SpotifyShower interface {
	GetShow(ctx context.Context, showID string) (*Show, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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