Documentation ¶
Index ¶
- Constants
- func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error
- type AbortRequest
- type CustomTemplate
- type DownloadInfo
- type DownloadOutput
- type DownloadProgress
- type DownloadRequest
- type LoadBalancer
- type MemoryDB
- type MessageQueue
- type Node
- type Pool
- type PostprocessTemplate
- type Process
- type ProcessResponse
- type ProgressTemplate
- type Session
- type SetCookiesRequest
- type Stack
- type Worker
Constants ¶
const ( StatusPending = iota StatusDownloading StatusCompleted StatusErrored )
Variables ¶
This section is empty.
Functions ¶
func PlaylistDetect ¶
func PlaylistDetect(req DownloadRequest, mq *MessageQueue, db *MemoryDB) error
Types ¶
type AbortRequest ¶
type AbortRequest struct {
Id string `json:"id"`
}
struct representing the intent to stop a specific process
type CustomTemplate ¶
type CustomTemplate struct { Id string `json:"id"` Name string `json:"name"` Content string `json:"content"` }
represents a user defined collection of yt-dlp arguments
type DownloadInfo ¶
type DownloadInfo struct { URL string `json:"url"` Title string `json:"title"` Thumbnail string `json:"thumbnail"` Resolution string `json:"resolution"` Size int32 `json:"filesize_approx"` VCodec string `json:"vcodec"` ACodec string `json:"acodec"` Extension string `json:"ext"` OriginalURL string `json:"original_url"` FileName string `json:"filename"` CreatedAt time.Time `json:"created_at"` }
Used to deser the yt-dlp -J output
type DownloadOutput ¶
type DownloadOutput struct { Path string Filename string SavedFilePath string `json:"savedFilePath"` }
Defines where and how the download needs to be saved
type DownloadProgress ¶
type DownloadProgress struct { Status int `json:"process_status"` Percentage string `json:"percentage"` Speed float32 `json:"speed"` ETA float32 `json:"eta"` }
Progress for the Running call
type DownloadRequest ¶
type DownloadRequest struct { Id string URL string `json:"url"` Path string `json:"path"` Rename string `json:"rename"` Params []string `json:"params"` }
struct representing the intent to start a download
type LoadBalancer ¶
type LoadBalancer struct {
// contains filtered or unexported fields
}
func (*LoadBalancer) Balance ¶
func (b *LoadBalancer) Balance(work chan Process)
type MemoryDB ¶
type MemoryDB struct {
// contains filtered or unexported fields
}
In-Memory Thread-Safe Key-Value Storage with optional persistence
func NewMemoryDB ¶
func NewMemoryDB() *MemoryDB
func (*MemoryDB) All ¶
func (m *MemoryDB) All() *[]ProcessResponse
Returns a slice of all currently stored processes progess
type MessageQueue ¶
type MessageQueue struct {
// contains filtered or unexported fields
}
func NewMessageQueue ¶
func NewMessageQueue() (*MessageQueue, error)
Creates a new message queue. By default it will be created with a size equals to nthe number of logical CPU cores -1. The queue size can be set via the qs flag.
func (*MessageQueue) Publish ¶
func (m *MessageQueue) Publish(p *Process)
Publish a message to the queue and set the task to a peding state.
func (*MessageQueue) SetupConsumers ¶
func (m *MessageQueue) SetupConsumers()
type PostprocessTemplate ¶
type PostprocessTemplate struct {
FilePath string `json:"filepath"`
}
type Process ¶
type Process struct { Id string Url string Livestream bool Params []string Info DownloadInfo Progress DownloadProgress Output DownloadOutput // contains filtered or unexported fields }
Process descriptor
func (*Process) Complete ¶
func (p *Process) Complete()
Keep process in the memoryDB but marks it as complete Convention: All completed processes has progress -1 and speed 0 bps.
func (*Process) GetFileName ¶
func (p *Process) GetFileName(o *DownloadOutput) error
func (*Process) SetMetadata ¶
func (*Process) SetPending ¶
func (p *Process) SetPending()
func (*Process) Start ¶
func (p *Process) Start()
Starts spawns/forks a new yt-dlp process and parse its stdout. The process is spawned to outputting a custom progress text that Resembles a JSON Object in order to Unmarshal it later. This approach is anyhow not perfect: quotes are not escaped properly. Each process is not identified by its PID but by a UUIDv4
type ProcessResponse ¶
type ProcessResponse struct { Id string `json:"id"` Progress DownloadProgress `json:"progress"` Info DownloadInfo `json:"info"` Output DownloadOutput `json:"output"` Params []string `json:"params"` }
struct representing the response sent to the client as JSON-RPC result field
type ProgressTemplate ¶
type ProgressTemplate struct { Percentage string `json:"percentage"` Speed float32 `json:"speed"` Size string `json:"size"` Eta float32 `json:"eta"` }
Used to unmarshall yt-dlp progress
type Session ¶
type Session struct {
Processes []ProcessResponse `json:"processes"`
}
struct representing the current status of the memoryDB used for serializaton/persistence reasons
type SetCookiesRequest ¶
type SetCookiesRequest struct {
Cookies string `json:"cookies"`
}
struct representing request of creating a netscape cookies file