sptui

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 28 Imported by: 0

README

sptui

Go Report Card

Overview

sptui is a Spotify TUI player, written in Go and leveraging the charmbracelet/bubbletea library.

Installation

Visit the GitHub Releases page for sptui and download the appropriate binary for your operating system.

Usage

Connecting to Spotify’s API

To use sptui, you need to connect it to Spotify's API. Follow these steps:

  1. Go to the Spotify Dashboard.
  2. Create a new app to obtain your Client ID and Client Secret.
  3. In Edit Settings, add http://localhost:21112/callback to the Redirect URIs. Don’t forget to save your changes.
  4. Set your Client ID as an environment variable SPOTIFY_ID.
  5. Run sptui. You will see an official Spotify URL for authentication.
# Replace your_client_id with the actual Client ID you obtained from Spotify.
SPOTIFY_ID=your_client_id sptui
  1. Open the provided URL in a web browser and log in to your Spotify account to grant the necessary permissions. After granting permission, you might be redirected to a blank page. This is normal and indicates that the authentication process is complete.

Once authenticated, you are ready to use sptui!

API Token Storage

Once authenticated, your Spotify API token will be stored at ${HOME}/.config/sptui/spotify_token.json. Ensure this file is kept secure as it contains sensitive information.

Key Bindings

Here are the key bindings for sptui:

Key Action
h j k l Navigate (left, down, up, right)
esc Return to the previous screen
q Quit sptui
:play Play current selection
:pause Pause playback
:next Next track
:prev Previous track
:device Select a device

Documentation

Index

Constants

View Source
const (
	PLAYLIST = iota
	ALBUM
	PODCAST
)

Tab

View Source
const (
	TOP = iota
	TRACKLIST
)

Screen Mode

View Source
const (
	NONE = iota
	INPUT
	ERROR
)

Text Input Mode

View Source
const (
	// ZWSP represents zero-width space.
	ZWSP = '\u200B'

	// ZWNBSP represents zero-width no-break space.
	ZWNBSP = '\uFEFF'

	// ZWJ represents zero-width joiner.
	ZWJ = '\u200D'

	// ZWNJ represents zero-width non-joiner.
	ZWNJ = '\u200C'
)

Variables

This section is empty.

Functions

func AnimTextTickCmd

func AnimTextTickCmd(id string, t time.Duration) tea.Cmd

func CleanString

func CleanString(s string) string

func FetchAlbumsCmd

func FetchAlbumsCmd(client *spotify.Client, opts ...spotify.RequestOption) tea.Cmd

func FetchPlaylistsCmd

func FetchPlaylistsCmd(client *spotify.Client, opts ...spotify.RequestOption) tea.Cmd

func FetchShowsCmd

func FetchShowsCmd(client *spotify.Client, opts ...spotify.RequestOption) tea.Cmd

func GetAlbumCmd

func GetAlbumCmd(client *spotify.Client, id spotify.ID) tea.Cmd

func GetAvailableDevicesCmd added in v0.1.2

func GetAvailableDevicesCmd(client *spotify.Client) tea.Cmd

func GetCurrentlyPlayingTrackCmd

func GetCurrentlyPlayingTrackCmd(client *spotify.Client) tea.Cmd

func GetPlaylistCmd

func GetPlaylistCmd(client *spotify.Client, id spotify.ID) tea.Cmd

func GetShowCmd

func GetShowCmd(client *spotify.Client, id spotify.ID) tea.Cmd

func LoadMoreCmd

func LoadMoreCmd() tea.Cmd

func NewTokenExpiredError

func NewTokenExpiredError() error

func NextPlaybackCmd

func NextPlaybackCmd(client *spotify.Client) tea.Cmd

func Normalize

func Normalize(s string) string

Normalize form C

func PadOrTruncate

func PadOrTruncate(s string, n int) string

func PausePlaybackCmd

func PausePlaybackCmd(client *spotify.Client) tea.Cmd

func PreviousPlaybackCmd

func PreviousPlaybackCmd(client *spotify.Client) tea.Cmd

func RemoveZeroWidthSpace

func RemoveZeroWidthSpace(s string) string

func StartPlaybackCmd

func StartPlaybackCmd(client *spotify.Client, opts *spotify.PlayOptions) tea.Cmd

func UpdateDepthCmd

func UpdateDepthCmd(d int) tea.Cmd

func WrapText

func WrapText(s string, width int, line int) string

Types

type AlbumDetailMsg

type AlbumDetailMsg struct {
	Album *spotify.FullAlbum
}

type AlbumMsg

type AlbumMsg struct {
	Albums *spotify.SavedAlbumPage
}

type AnimTextModel

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

func NewAnimText

func NewAnimText(t string, id string, opts ...AnimTextModelOpt) AnimTextModel

func (AnimTextModel) UpdateAnimText

func (m AnimTextModel) UpdateAnimText(msg tea.Msg) (AnimTextModel, tea.Cmd)

func (AnimTextModel) ViewAnimText

func (m AnimTextModel) ViewAnimText() string

type AnimTextModelOpt

type AnimTextModelOpt func(*AnimTextModel)

func WithWidth

func WithWidth(w int) AnimTextModelOpt

type AuthMsg

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

type BarConfig

type BarConfig struct {
	TickID     string
	Percent    float64
	IsPlaying  bool
	DeltaDur   float64
	TrackTitle string
}

type BarModel

type BarModel struct {
	IsPlaying bool
	// contains filtered or unexported fields
}

func NewBarModel

func NewBarModel(conf BarConfig) BarModel

func (BarModel) PositionMs added in v0.1.2

func (m BarModel) PositionMs() int

func (BarModel) UpdateBar

func (m BarModel) UpdateBar(msg tea.Msg, client *spotify.Client) (BarModel, tea.Cmd)

func (BarModel) ViewBar

func (m BarModel) ViewBar() string

type CurrentlyPlayingMsg

type CurrentlyPlayingMsg struct {
	Track *spotify.CurrentlyPlaying
}

type ErrMsg

type ErrMsg struct {
	Err error
}

type HelpModel

type HelpModel struct {
	KeyMap KeyMap
	// contains filtered or unexported fields
}

func NewHelp

func NewHelp() HelpModel

func (HelpModel) FullHelp

func (m HelpModel) FullHelp() [][]key.Binding

func (HelpModel) ShortHelp

func (m HelpModel) ShortHelp() []key.Binding

func (HelpModel) View

func (m HelpModel) View() string

type KeyMap

type KeyMap struct {
	Play   key.Binding
	Pause  key.Binding
	Next   key.Binding
	Prev   key.Binding
	Help   key.Binding
	Device key.Binding
}

type ListModel

type ListModel struct {
	Fetching bool
	// contains filtered or unexported fields
}

func NewListModel

func NewListModel(items []list.Item, opts ...ListModelOpt) ListModel

func (ListModel) InitList

func (m ListModel) InitList() tea.Cmd

func (ListModel) UpdateList

func (m ListModel) UpdateList(msg tea.Msg, depth int) (ListModel, tea.Cmd)

func (ListModel) View

func (m ListModel) View(depth int) string

type ListModelOpt

type ListModelOpt func(*ListModel)

func WithTitle

func WithTitle(title string) ListModelOpt

type LoadMoreMsg

type LoadMoreMsg struct{}

type PlaybackMsg

type PlaybackMsg struct {
}

type PlayerDevicesMsg added in v0.1.2

type PlayerDevicesMsg struct {
	PlayerDevices []spotify.PlayerDevice
}

type PlaylistDetailMsg

type PlaylistDetailMsg struct {
	Playlist *spotify.FullPlaylist
}

type PlaylistMsg

type PlaylistMsg struct {
	Playlists *spotify.SimplePlaylistPage
}

type ShowDetailMsg

type ShowDetailMsg struct {
	Show *spotify.FullShow
}

type ShowMsg

type ShowMsg struct {
	Shows *spotify.SavedShowPage
}

type TabModel

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

func NewTabModel

func NewTabModel() TabModel

func (TabModel) Init

func (m TabModel) Init() tea.Cmd

func (TabModel) Update

func (m TabModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (TabModel) View

func (m TabModel) View() string

type TextModel

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

func NewTextModel

func NewTextModel() TextModel

func (TextModel) InitText

func (m TextModel) InitText() tea.Cmd

func (TextModel) UpdateText

func (m TextModel) UpdateText(msg tea.Msg) (TextModel, tea.Cmd)

func (TextModel) ViewText

func (m TextModel) ViewText(textMode int) string

type TokenExpiredError

type TokenExpiredError struct {
	Message string
}

func (TokenExpiredError) Error

func (e TokenExpiredError) Error() string

type UpdateDepthMsg

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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