Documentation ¶
Index ¶
- Variables
- func AddToHistory(text string)
- func CloseInstances(socket string)
- func ConfigPath(ftype string) (string, error)
- func FormatDuration(duration int) string
- func FormatPublished(published string) string
- func GetDataFromURL(uri string) []string
- func GetProgress(width int) (string, string, error)
- func HistoryForward() string
- func HistoryReverse() string
- func IsValidURL(uri string) (*url.URL, error)
- func LoadPlaylist(id string, audio bool) error
- func LoadVideo(id string, audio bool) error
- func MPVStart() error
- func SaveHistory()
- func SendRequest(ctx context.Context, c *Client, param string) (*http.Response, error)
- func SetupConfig() error
- func SetupFlags() error
- func SetupHistory()
- func SuspendApp(t tcell.Screen)
- func UpdateClient() error
- type ChannelResult
- type Client
- func (c *Client) Channel(id, stype, params string, cancel bool) (ChannelResult, error)
- func (c *Client) ChannelPlaylists(id string, cancel bool) (ChannelResult, error)
- func (c *Client) ChannelSearch(id, query string, getmore bool) ([]SearchResult, error)
- func (c *Client) ChannelVideos(id string, cancel bool) (ChannelResult, error)
- func (c *Client) ClientRequest(ctx context.Context, param string) (*http.Response, error)
- func (c *Client) Playlist(id string, cancel bool) (PlaylistResult, error)
- func (c *Client) Search(stype, text string, getmore bool, chanid ...string) ([]SearchResult, error)
- func (c *Client) Video(id string) (VideoResult, error)
- type Connector
- func (c *Connector) Call(args ...interface{}) (interface{}, error)
- func (c *Connector) CycleLoop()
- func (c *Connector) CycleMute()
- func (c *Connector) CyclePaused()
- func (c *Connector) CycleShuffle()
- func (c *Connector) Duration() int
- func (c *Connector) Get(prop string) (interface{}, error)
- func (c *Connector) IsClosed() bool
- func (c *Connector) IsEOF() bool
- func (c *Connector) IsIdle() bool
- func (c *Connector) IsMuted() bool
- func (c *Connector) IsPaused() bool
- func (c *Connector) IsShuffle() bool
- func (c *Connector) LoadFile(title string, duration int, files ...string) error
- func (c *Connector) LoadPlaylist(plpath string, replace bool) error
- func (c *Connector) LoopType(file bool) string
- func (c *Connector) MPVStop(rm bool)
- func (c *Connector) MediaType() string
- func (c *Connector) Next()
- func (c *Connector) Play()
- func (c *Connector) PlaylistClear()
- func (c *Connector) PlaylistCount() int
- func (c *Connector) PlaylistData() string
- func (c *Connector) PlaylistDelete(entry int)
- func (c *Connector) PlaylistMove(a, b int)
- func (c *Connector) PlaylistPlayLatest()
- func (c *Connector) PlaylistPos() int
- func (c *Connector) PlaylistTitle(pos int) string
- func (c *Connector) Prev()
- func (c *Connector) SeekBackward()
- func (c *Connector) SeekForward()
- func (c *Connector) Set(prop string, value interface{}) error
- func (c *Connector) SetPlaylistPos(pos int)
- func (c *Connector) Stop()
- func (c *Connector) TimePosition() int
- func (c *Connector) WaitUntilClosed()
- type FormatData
- type PlaylistResult
- type PlaylistVideo
- type SearchResult
- type VideoResult
Constants ¶
This section is empty.
Variables ¶
var ( // MPVErrors is a channel to receive mpv error messages. MPVErrors chan string // MPVFileLoaded is a channel to receive file-loaded events. MPVFileLoaded chan struct{} )
var ( // PlistCtx is used here and the UI playlist code // to detect if the user tried to cancel the playlist // loading. PlistCtx context.Context // PlistCancel is used to cancel the playlist loading. PlistCancel context.CancelFunc )
Functions ¶
func AddToHistory ¶
func AddToHistory(text string)
AddToHistory adds text to the history buffer. Taken from https://github.com/abs-lang/abs/repl/history.go (addToHistory)
func CloseInstances ¶
func CloseInstances(socket string)
CloseInstances sends a quit command to instances running on the socket.
func ConfigPath ¶
ConfigPath returns the absolute path for the given filetype: socket, history and config, and performs actions related to it.
func FormatDuration ¶
FormatDuration takes a duration as seconds and returns a hh:mm:ss string.
func FormatPublished ¶
FormatPublished takes a duration in the format: "1 day ago", and returns it in the format: "1d".
func GetDataFromURL ¶
GetDataFromURL parses specific url fields and returns their values.
func GetProgress ¶
GetProgress renders a progress bar and media data.
func HistoryForward ¶
func HistoryForward() string
HistoryForward moves a step forward in the history buffer, and returns a text.
func HistoryReverse ¶
func HistoryReverse() string
HistoryReverse moves a step back in the history buffer, and returns a text.
func IsValidURL ¶
IsValidURL checks if a URL is valid.
func LoadPlaylist ¶ added in v0.0.5
LoadPlaylist takes a playlist ID, determines whether to play video or just audio (according to the audio parameter), and appropriately loads the URLs into mpv.
func LoadVideo ¶
LoadVideo takes a video ID, determines whether to play video or just audio (according to the audio parameter), and appropriately loads the URLs into mpv.
func MPVStart ¶
func MPVStart() error
MPVStart loads the mpv executable, and connects to the socket.
func SaveHistory ¶
func SaveHistory()
SaveHistory saves the contents of the history buffer to the history file. Taken from https://github.com/abs-lang/abs/repl/history.go (saveHistory)
func SendRequest ¶
SendRequest sends a request to a url and returns a response.
func SetupConfig ¶
func SetupConfig() error
SetupConfig checks for the config directory, and creates one if it doesn't exist.
func SetupHistory ¶
func SetupHistory()
SetupHistory reads the history file and loads the search history. Taken from https://github.com/abs-lang/abs/repl/history.go (Start)
func SuspendApp ¶ added in v0.0.4
func SuspendApp(t tcell.Screen)
SuspendApp suspends the application.
func UpdateClient ¶
func UpdateClient() error
UpdateClient queries available instances and updates the client.
Types ¶
type ChannelResult ¶ added in v0.0.5
type ChannelResult struct { Title string `json:"title"` ChannelID string `json:"authorId"` Author string `json:"author"` Description string `json:"description"` ViewCount int `json:"viewCount"` Videos []PlaylistVideo `json:"videos"` Playlists []PlaylistResult `json:"playlists"` }
ChannelResult stores the channel data.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client stores the host and http client data.
func (*Client) Channel ¶ added in v0.0.5
func (c *Client) Channel(id, stype, params string, cancel bool) (ChannelResult, error)
Channel gets the playlist with the given ID and returns a ChannelResult. If id is blank, it indicates that more results are to be loaded for the same channel ID (stored in plistid). When cancel is true, it will stop loading the channel.
func (*Client) ChannelPlaylists ¶ added in v0.0.5
func (c *Client) ChannelPlaylists(id string, cancel bool) (ChannelResult, error)
ChannelPlaylists loads only the playlists present in the channel.
func (*Client) ChannelSearch ¶ added in v0.0.6
func (c *Client) ChannelSearch(id, query string, getmore bool) ([]SearchResult, error)
ChannelSearch searches for a query string in the channel.
func (*Client) ChannelVideos ¶ added in v0.0.5
func (c *Client) ChannelVideos(id string, cancel bool) (ChannelResult, error)
ChannelVideos loads only the videos present in the channel.
func (*Client) ClientRequest ¶
ClientRequest sends a request to the API and returns a response.
func (*Client) Playlist ¶ added in v0.0.5
func (c *Client) Playlist(id string, cancel bool) (PlaylistResult, error)
Playlist gets the playlist with the given ID and returns a PlaylistResult. If id is blank, it indicates that more results are to be loaded for the same playlist ID (stored in plistid). When cancel is true, it will stop loading the playlist.
func (*Client) Search ¶
Search searches for the given string and returns a SearchResult slice. It queries for two pages of results, and keeps a track of the number of pages currently returned. If the getmore parameter is true, it will add two more pages to the already tracked page number, and return the result.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector stores the mpvipc connection data.
func MPVConnect ¶
MPVConnect attempts to connect to the mpv instance.
func NewConnector ¶
func NewConnector(conn *mpvipc.Connection) *Connector
NewConnector returns a Connector with an active mpvipc connection.
func (*Connector) CycleLoop ¶
func (c *Connector) CycleLoop()
CycleLoop toggles between looping a file, playlist or none.
func (*Connector) CycleMute ¶ added in v0.0.5
func (c *Connector) CycleMute()
CycleMute toggles the playback mute state.
func (*Connector) CyclePaused ¶
func (c *Connector) CyclePaused()
CyclePaused toggles between pause and play states.
func (*Connector) CycleShuffle ¶
func (c *Connector) CycleShuffle()
CycleShuffle cycles the playlist's shuffle state.
func (*Connector) LoadFile ¶ added in v0.0.2
LoadFile loads the given file into mpv along with the relevant metadata. If the files parameter contains more than one filename argument, it will consider the first entry as the video file and the second entry as the audio file, set the relevant options and pass them to mpv.
func (*Connector) LoadPlaylist ¶ added in v0.0.2
LoadPlaylist loads a playlist file. If replace is false, it appends the loaded playlist to the current playlist, otherwise it replaces the current playlist.
func (*Connector) LoopType ¶
LoopType determines if the loop option is set, and determines if it is one of loop-file or loop-playlist.
func (*Connector) MediaType ¶
MediaType determines if currently playing file is of audio or video type.
func (*Connector) PlaylistClear ¶
func (c *Connector) PlaylistClear()
PlaylistClear clears the playlist.
func (*Connector) PlaylistCount ¶
PlaylistCount returns the total amount of files in the playlist.
func (*Connector) PlaylistData ¶
PlaylistData return the current playlist data.
func (*Connector) PlaylistDelete ¶ added in v0.0.2
PlaylistDelete deletes an entry from the playlist.
func (*Connector) PlaylistMove ¶ added in v0.0.2
PlaylistMove moves an entry to a different index in the playlist.
func (*Connector) PlaylistPlayLatest ¶
func (c *Connector) PlaylistPlayLatest()
PlaylistPlayLatest plays the latest entry in the playlist.
func (*Connector) PlaylistPos ¶
PlaylistPos returns the current position of the file in the playlist.
func (*Connector) PlaylistTitle ¶ added in v0.0.2
PlaylistTitle returns the title, or filename of the playlist entry if title is not available.
func (*Connector) SeekBackward ¶
func (c *Connector) SeekBackward()
SeekBackward seeks the track backward.
func (*Connector) SeekForward ¶
func (c *Connector) SeekForward()
SeekForward seeks the track forward.
func (*Connector) SetPlaylistPos ¶
SetPlaylistPos sets the playlist position.
func (*Connector) TimePosition ¶
TimePosition returns the current position in the file.
func (*Connector) WaitUntilClosed ¶
func (c *Connector) WaitUntilClosed()
WaitUntilClosed waits until a connection is closed.
type FormatData ¶ added in v0.0.4
type FormatData struct { Type string `json:"type"` URL string `json:"url"` Itag string `json:"itag"` Resolution string `json:"resolution,omitempty"` }
FormatData stores the media format data.
type PlaylistResult ¶ added in v0.0.5
type PlaylistResult struct { Title string `json:"title"` PlaylistID string `json:"playlistId"` Author string `json:"author"` Description string `json:"description"` VideoCount int `json:"videoCount"` ViewCount int `json:"viewCount"` Videos []PlaylistVideo `json:"videos"` }
PlaylistResult stores the playlist data.
type PlaylistVideo ¶ added in v0.0.5
type PlaylistVideo struct { Title string `json:"title"` VideoID string `json:"videoId"` Author string `json:"author"` LengthSeconds int `json:"lengthSeconds"` }
PlaylistVideo stores the playlist's video data.
type SearchResult ¶
type SearchResult struct { Type string `json: "type"` Title string `json: "title"` AuthorID string `json: "authorId"` VideoID string `json: "videoId"` PlaylistID string `json: "playlistId"` Author string `json: "author"` PublishedText string `json: "publishedText"` Description string `json: "description"` VideoCount int `json: "videoCount"` LengthSeconds int `json: "lengthSeconds"` }
SearchResult stores the search result data.
type VideoResult ¶
type VideoResult struct { Title string `json:"title"` Author string `json:"author"` VideoID string `json:"videoId"` LengthSeconds int `json:"lengthSeconds"` FormatStreams []FormatData `json:"formatStreams"` AdaptiveFormats []FormatData `json:"adaptiveFormats"` }
VideoResult stores the video data.