collection

package
v0.12.8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: GPL-3.0 Imports: 23 Imported by: 5

Documentation

Index

Constants

View Source
const NSYoutube = "yt"

Variables

View Source
var (
	ErrNotExists     = errors.New("playlist does not exist")
	ErrSongNotExists = errors.New("song does not exist")
	ErrExists        = errors.New("playlist already exists")
)
View Source
var ErrUnknown = errors.New("unknown")

Functions

func Download

func Download(w io.Writer, src *url.URL) error

func DownloadAudio

func DownloadAudio(w io.Writer, src *url.URL) error

func GlobalID

func GlobalID(i IDer) string

func IsErrExists

func IsErrExists(err error) bool

func IsErrNotExists

func IsErrNotExists(err error) bool

func TempFile

func TempFile(file string) string

Types

type Collection

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

func New

func New(l *log.Logger, dir string, queue *Queue, concurrentDownloads int, autoSave bool) *Collection

func (*Collection) AddSong

func (c *Collection) AddSong(playlist string, s Song, reappend bool) error

func (*Collection) Create

func (c *Collection) Create(n string) error

func (*Collection) DelSong

func (c *Collection) DelSong(playlist string, s Song) error

func (*Collection) DelSongIndexes

func (c *Collection) DelSongIndexes(playlist string, ix []int) error

func (*Collection) Delete

func (c *Collection) Delete(n string) error

func (*Collection) Exists

func (c *Collection) Exists(n string) bool

func (*Collection) Find

func (c *Collection) Find(ns, id string) (Song, error)

func (*Collection) FindAll added in v0.12.1

func (c *Collection) FindAll(ns, id string) (Song, []string, error)

func (*Collection) FromYoutube

func (c *Collection) FromYoutube(r *youtube.Result) *YoutubeSong

func (*Collection) FromYoutubeURL

func (c *Collection) FromYoutubeURL(url, title string) (*YoutubeSong, error)

func (*Collection) Init

func (c *Collection) Init() error

func (*Collection) List

func (c *Collection) List() []string

func (*Collection) Load

func (c *Collection) Load() error

func (*Collection) MoveSongIndex

func (c *Collection) MoveSongIndex(playlist string, from []int, to int) error

func (*Collection) PlaylistSongs

func (c *Collection) PlaylistSongs(playlist string) ([]Song, error)

func (*Collection) Problematics

func (c *Collection) Problematics() *Problematics

func (*Collection) Queue

func (c *Collection) Queue(ix int, n string) error

func (*Collection) QueueSong

func (c *Collection) QueueSong(ix int, s Song)

func (*Collection) RegisterUnmarshaler

func (c *Collection) RegisterUnmarshaler(ns string, unmarshaler Unmarshaler)

func (*Collection) RenameSong added in v0.9.5

func (c *Collection) RenameSong(s Song, name string)

func (*Collection) Run

func (c *Collection) Run(ratelimitDownloads, ratelimitMeta <-chan struct{})

func (*Collection) Save

func (c *Collection) Save() error

func (*Collection) Search

func (c *Collection) Search(q string) []*SearchResult

func (*Collection) SongPath

func (c *Collection) SongPath(id IDer) string

func (*Collection) Songs

func (c *Collection) Songs() []Song

func (*Collection) UnreferencedDownloads

func (c *Collection) UnreferencedDownloads() []string

type IDer

type IDer interface {
	NS() string
	ID() string
}

type Playlist

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

func NewPlaylist

func NewPlaylist(name string) *Playlist

func (*Playlist) Add

func (p *Playlist) Add(s Song, reappend bool)

func (*Playlist) Del

func (p *Playlist) Del(s Song)

func (*Playlist) DelIndexes

func (p *Playlist) DelIndexes(ix []int)

func (*Playlist) Find

func (p *Playlist) Find(ns, id string) (Song, error)

func (*Playlist) List

func (p *Playlist) List() []Song

func (*Playlist) Move

func (p *Playlist) Move(from, to Song)

func (*Playlist) MoveIndex

func (p *Playlist) MoveIndex(from []int, to int)

func (*Playlist) Queue

func (p *Playlist) Queue(q *Queue, ix int)

func (*Playlist) Search

func (p *Playlist) Search(q string) []Song

type Problematic

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

func (Problematic) Reason

func (p Problematic) Reason() error

func (Problematic) Song

func (p Problematic) Song() Song

type Problematics

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

func NewProblematics

func NewProblematics() *Problematics

func (*Problematics) Add

func (p *Problematics) Add(s Song, err error)

func (*Problematics) Del

func (p *Problematics) Del(s IDer)

func (*Problematics) List

func (p *Problematics) List() []Problematic

func (*Problematics) Reason

func (p *Problematics) Reason(s IDer) string

type Queue

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

func NewQueue

func NewQueue() *Queue

func (*Queue) Add

func (q *Queue) Add(ix int, s Song)

func (*Queue) AddSlice

func (q *Queue) AddSlice(ix int, songs []Song)

func (*Queue) Current

func (q *Queue) Current() *QueueItem

func (*Queue) CurrentIndex

func (q *Queue) CurrentIndex() int

func (*Queue) Next

func (q *Queue) Next() *QueueItem

func (*Queue) Prev

func (q *Queue) Prev() *QueueItem

func (*Queue) Reset

func (q *Queue) Reset()

func (*Queue) SetCurrentIndex

func (q *Queue) SetCurrentIndex(i int)

func (*Queue) Shuffle added in v0.9.2

func (q *Queue) Shuffle()

func (*Queue) ShuffleRange added in v0.9.2

func (q *Queue) ShuffleRange(start, end int)

ShuffleRange shuffles items in the queue in range [start, end] if start < 0: shuffle from beginning if end < 0: shuffle until the end thus ShuffleRange(-1, -1) shuffles the entire queue

func (*Queue) Slice

func (q *Queue) Slice() []Song

func (*Queue) String

func (q *Queue) String() string

type QueueItem

type QueueItem struct {
	Song
	// contains filtered or unexported fields
}

func (*QueueItem) IsBeyondFirst

func (q *QueueItem) IsBeyondFirst() bool

func (*QueueItem) IsBeyondLast

func (q *QueueItem) IsBeyondLast() bool

func (*QueueItem) Next

func (q *QueueItem) Next() *QueueItem

func (*QueueItem) Prev

func (q *QueueItem) Prev() *QueueItem

type SearchResult added in v0.12.0

type SearchResult struct {
	Song
	Playlists []string
}

type Song

type Song interface {
	IDer
	Title() string
	UpdateTitle() error
	SetTitle(string)
	Local() bool
	URL() (*url.URL, error)
	File() (string, error)
	Marshal(*binary.Writer) error
	PageURL() (*url.URL, error)
}

type SongTasks

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

SongTasks runs a bunch of tasks on a song concurrenly with a given ratelimiter.

func NewSongTasks

func NewSongTasks(
	concurrency int,
	rate <-chan struct{},
	filter func(Song) bool,
	cb func(Song),
) *SongTasks

NewSongTasks creates a new SongTask that will execute cb() for every item that returns true when passed through filter(). filter will also be executed concurrenly but never ratelimited.

func (*SongTasks) Add

func (t *SongTasks) Add(s Song)

func (*SongTasks) Start

func (t *SongTasks) Start()

type Unmarshaler

type Unmarshaler func(dec *binary.Reader) (Song, error)

type YoutubeSong

type YoutubeSong struct {
	*youtube.Result
	// contains filtered or unexported fields
}

func YoutubeSongUnmarshal added in v0.8.0

func YoutubeSongUnmarshal(c *Collection, dec *binary.Reader) (*YoutubeSong, error)

func (*YoutubeSong) File

func (s *YoutubeSong) File() (string, error)

func (*YoutubeSong) Local

func (s *YoutubeSong) Local() bool

func (*YoutubeSong) Marshal

func (s *YoutubeSong) Marshal(w *binary.Writer) error

func (*YoutubeSong) NS

func (s *YoutubeSong) NS() string

func (*YoutubeSong) PageURL added in v0.8.0

func (s *YoutubeSong) PageURL() (*url.URL, error)

func (*YoutubeSong) URL

func (s *YoutubeSong) URL() (*url.URL, error)

Jump to

Keyboard shortcuts

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