Documentation ¶
Overview ¶
Package videodl provides a video file downloader around the youtube-dl command (only for now).
Index ¶
- Constants
- type BackendID
- type Commands
- type Config
- type Controler
- type DownloadFunc
- type Downloader
- type Entry
- type Filer
- type Format
- type FuncFilterFormatTest
- type FuncFilterFormats
- type FuncNewFiler
- type FuncPopupDialog
- type HistoryVideo
- type Manager
- func (m *Manager) Actions(firstID int, actionAdd func(acts ...*cdtype.Action))
- func (m *Manager) CancelDownload()
- func (m *Manager) DialogCategory(filterFormats FuncFilterFormats, callDialog FuncPopupDialog, ...)
- func (m *Manager) DialogQuality(filterFormats FuncFilterFormats, callDialog FuncPopupDialog, ...)
- func (m *Manager) Download(url string)
- func (m *Manager) Enqueue(vid *Video)
- func (m *Manager) EnqueueAndStart(vid *Video)
- func (m *Manager) FilePath(vid Video) string
- func (m *Manager) FilterBlacklist() FuncFilterFormats
- func (m *Manager) IsActive() bool
- func (m *Manager) Menu(menu cdtype.Menuer)
- func (m *Manager) MenuQuality(menu cdtype.Menuer, qual *Quality, list []Quality)
- func (m *Manager) MenuTypeDL(menu cdtype.Menuer, typ *TypeDL)
- func (m *Manager) OpenFolder()
- func (m *Manager) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (m *Manager) SetConfig(conf *Config)
- func (m *Manager) SetEditList(call func() error)
- func (m *Manager) SetEnabledWeb(s WebState)
- func (m *Manager) SetPostCheck(call func() error)
- func (m *Manager) SetPreCheck(call func() error)
- func (m *Manager) SetStartedWeb(b bool)
- func (m *Manager) Start()
- func (m *Manager) ToggleEnableDownload()
- func (m *Manager) ToggleEnableWeb()
- func (m *Manager) WebAutoStart() func()
- func (m *Manager) WebRegister()
- func (m *Manager) WebStart()
- func (m *Manager) WebStop()
- func (m *Manager) WebURL() string
- func (m *Manager) WebUnregister()
- type Progress
- type Quality
- type TypeDL
- type Video
- type VideoDler
- type WebState
- type YTDL
- type YTDLFile
- type YoutubeDL
- type YoutubeDLFile
Constants ¶
const ( HistoryFile = "videodl_history.txt" WebPath = "video" )
HistoryFile defines the name of the default history file.
const ( ActionOpenFolder = iota ActionCancelDownload ActionEnableDownload ActionEnableWeb ActionEditList ActionCount // Number of defined actions )
Videodl actions.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { BackendID BackendID Path string Quality Quality TypeDL TypeDL EnabledDL bool // EnabledWeb bool // StartedWeb bool JSWindowOption string Blacklist []string }
Config defines the videodl service configuration. Can be used directly as applet config.
type Controler ¶
type Controler interface { Action() cdtype.AppAction PopupDialog(cdtype.DialogData) error }
Controler defines actions needed from a cdtype.AppBase.
type DownloadFunc ¶
DownloadFunc defines a quality set function.
type Downloader ¶
type Downloader interface { // SetConfig sets the config data for the manager. // SetConfig(*Config) // SetEditList updates the edit list call action. // SetEditList(call func() error) // SetPreCheck sets the pre-upload action. // SetPreCheck(call func() error) // SetPostCheck sets the post-upload action. // SetPostCheck(call func() error) // IsActive returns whether a download is in progress or not. // IsActive() bool // FilterBlacklist provides a filter formats call to remove blacklisted file types. // FilterBlacklist() FuncFilterFormats WebRegister() WebUnregister() WebAutoStart() func() // SetEnabledWeb sets the web service state. // SetEnabledWeb(WebState) // WebURL formats the web service base url. // WebURL() string // Download downloads a video file from the server at configured quality (can be ask). // Download(url string) // Enqueue enqueues an item to the download list. // Enqueue(*Video) EnqueueAndStart(*Video) Start() OpenFolder() CancelDownload() Actions(firstID int, actionAdd func(...*cdtype.Action)) Menu(cdtype.Menuer) DialogQuality(filterFormats FuncFilterFormats, callDialog FuncPopupDialog, callDL DownloadFunc, v *Video) }
Downloader defines the usage of the video download manager.
type Entry ¶
type Entry struct { Name string // name of the object IsDir bool Mode os.FileMode Viewed bool URL string Fail bool }
Entry defines a list entry to provide as json
type Filer ¶
type Filer interface { Title() (string, error) DownloadCmd(path string, format *Format, progress *Progress) func() error Formats() ([]*Format, error) }
Filer defines the usage of a video file downloader.
func NewYTDLFile ¶
NewYTDLFile creates a video file downloader.
type Format ¶
type Format struct { Itag int // Key reference for the stream. Extension string // Media extension (mp4, flv...) Resolution string // Video resolution. Size int // File size in MiB. VideoEncoding string AudioEncoding string AudioBitrate int // contains filtered or unexported fields }
Format defines the format of a media stream (audio or video).
func FilterFormats ¶
func FilterFormats(formats []*Format, filters ...FuncFilterFormatTest) []*Format
FilterFormats filters a list of formats with the provided test.
type FuncFilterFormatTest ¶
FuncFilterFormatTest defines a filter format test callback.
type FuncFilterFormats ¶
FuncFilterFormats defines a filter format test callback.
type FuncNewFiler ¶
FuncNewFiler defines the filer creation from a download backend.
type FuncPopupDialog ¶
type FuncPopupDialog func(cdtype.DialogData) error
FuncPopupDialog defines a dialog display function.
type HistoryVideo ¶
type HistoryVideo struct { history.History Queue []*Video // still to do. List []*Video // already done. }
HistoryVideo stores and saves videodl done and queued lists.
func NewHistoryVideo ¶
func NewHistoryVideo(app history.AppletLike, filename string) *HistoryVideo
NewHistoryVideo creates a videodl history manager with the given file location.
func (*HistoryVideo) Add ¶
func (h *HistoryVideo) Add(q *Video) error
Add adds a video to the download queue.
func (*HistoryVideo) Done ¶
func (h *HistoryVideo) Done() error
Done moves the first item in the queue to the done list.
func (*HistoryVideo) Find ¶
func (h *HistoryVideo) Find(url string) *Video
Find finds the video patching the given source url.
func (*HistoryVideo) Next ¶
func (h *HistoryVideo) Next() (*Video, bool)
Next returns the first video in the download queue.
func (*HistoryVideo) Queued ¶
func (h *HistoryVideo) Queued() int
Queued returns the size of the download queue.
type Manager ¶
type Manager struct { *Config *Commands EnabledWeb bool StartedWeb bool // contains filtered or unexported fields }
Manager defines a video file download manager.
func NewManager ¶
func NewManager(control Controler, log cdtype.Logger, hist *HistoryVideo) *Manager
NewManager creates a video file download manager.
func (*Manager) CancelDownload ¶
func (m *Manager) CancelDownload()
CancelDownload stops the current download.
func (*Manager) DialogCategory ¶
func (m *Manager) DialogCategory(filterFormats FuncFilterFormats, callDialog FuncPopupDialog, callDL DownloadFunc, vid *Video)
DialogCategory prepares a dialog to ask the category assigned to next downloads.
func (*Manager) DialogQuality ¶
func (m *Manager) DialogQuality(filterFormats FuncFilterFormats, callDialog FuncPopupDialog, callDL DownloadFunc, vid *Video)
DialogQuality prepares a dialog to ask the desired quality and download.
func (*Manager) Download ¶
Download downloads a video file from the server at configured quality (can be ask).
func (*Manager) EnqueueAndStart ¶
EnqueueAndStart enqueues an item and starts downloading.
func (*Manager) FilterBlacklist ¶
func (m *Manager) FilterBlacklist() FuncFilterFormats
FilterBlacklist provides a filter formats call to remove blacklisted file types.
func (*Manager) MenuQuality ¶
MenuQuality returns the list of available streams and formats for the video.
func (*Manager) MenuTypeDL ¶
MenuTypeDL fills the menu with a submenu to select TypeDL (audio, video or both).
func (*Manager) OpenFolder ¶
func (m *Manager) OpenFolder()
OpenFolder opens the destination folder.
func (*Manager) SetEditList ¶
SetEditList updates the edit list call action.
func (*Manager) SetEnabledWeb ¶
SetEnabledWeb sets the web service state.
func (*Manager) SetPostCheck ¶
SetPostCheck sets the post-upload action.
func (*Manager) SetPreCheck ¶
SetPreCheck sets the pre-upload action.
func (*Manager) SetStartedWeb ¶
SetStartedWeb sets the status of the web service.
func (*Manager) ToggleEnableDownload ¶
func (m *Manager) ToggleEnableDownload()
ToggleEnableDownload toggles the status of the download activity (dl/pause).
func (*Manager) ToggleEnableWeb ¶
func (m *Manager) ToggleEnableWeb()
ToggleEnableWeb toggles the status of the web service.
func (*Manager) WebAutoStart ¶
func (m *Manager) WebAutoStart() func()
WebAutoStart starts temporarily the web service, until the returned stop func is called.
func (*Manager) WebRegister ¶
func (m *Manager) WebRegister()
WebRegister registers the web service.
func (*Manager) WebUnregister ¶
func (m *Manager) WebUnregister()
WebUnregister unregister the web service.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress will try to provide download progress report.
type Quality ¶
type Quality int
Quality defines the download quality setting.
type Video ¶
type Video struct { *Format Name string URL string DateAdded time.Time DateDone *time.Time Fail bool Viewed bool Category string // contains filtered or unexported fields }
Video defines a video
type VideoDler ¶
type VideoDler interface { New(log cdtype.Logger, url string) (Filer, error) MenuQuality() []Quality }
VideoDler defines the backend interface.
type YTDL ¶
type YTDL struct{}
YTDL implements the VideoDler interface with internal ytdl library.
func (YTDL) MenuQuality ¶
MenuQuality returns the list of available streams and formats for the video.
type YTDLFile ¶
YTDLFile defines a video file downloader around the ytdl library.
func (*YTDLFile) DownloadCmd ¶
DownloadCmd downloads the video file from server.
type YoutubeDL ¶
type YoutubeDL struct{}
YoutubeDL implements the VideoDler interface with external youtube-dl command.
func (YoutubeDL) MenuQuality ¶
MenuQuality returns the list of available streams and formats for the video.
type YoutubeDLFile ¶
type YoutubeDLFile struct {
// contains filtered or unexported fields
}
YoutubeDLFile defines a video file downloader around the youtube-dl command.
func (*YoutubeDLFile) DownloadCmd ¶
func (f *YoutubeDLFile) DownloadCmd(path string, format *Format, progress *Progress) func() error
DownloadCmd downloads the video file from server.
func (*YoutubeDLFile) Formats ¶
func (f *YoutubeDLFile) Formats() ([]*Format, error)
Formats returns the list of available streams and formats for the video.
func (*YoutubeDLFile) Title ¶
func (f *YoutubeDLFile) Title() (string, error)
Title gets the title of the video.