godock: github.com/sqp/godock/libs/net/videodl Index | Files

package videodl

import "github.com/sqp/godock/libs/net/videodl"

Package videodl provides a video file downloader around the youtube-dl command (only for now).

Index

Package Files

history.go index.html.go manager.go videodl.go web.go youtubedl.go ytdl.go

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.

func FilterFormats Uses

func FilterFormats(formats []*Format, filters ...FuncFilterFormatTest) []*Format

FilterFormats filters a list of formats with the provided test.

type BackendID Uses

type BackendID int

BackendID represents the identifier of a backend.

const (
    BackendInternal BackendID = iota
    BackendYoutubeDL
)

Backends list.

type Commands Uses

type Commands struct {
    CmdOpenDir   string
    CmdOpenWeb   string
    CmdOpenVideo string
}

Commands defines custom user commands to open programs.

type Config Uses

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 Uses

type Controler interface {
    Action() cdtype.AppAction
    PopupDialog(cdtype.DialogData) error
}

Controler defines actions needed from a cdtype.AppBase.

type DownloadFunc Uses

type DownloadFunc func(*Video, *Format)

DownloadFunc defines a quality set function.

type Downloader Uses

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 Uses

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 Uses

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 Uses

func NewYTDLFile(log cdtype.Logger, url string) (Filer, error)

NewYTDLFile creates a video file downloader.

func NewYoutubeDLFile Uses

func NewYoutubeDLFile(log cdtype.Logger, url string) (Filer, error)

NewYoutubeDLFile creates a video file downloader.

type Format Uses

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).

type FuncFilterFormatTest Uses

type FuncFilterFormatTest func(*Format) bool

FuncFilterFormatTest defines a filter format test callback.

type FuncFilterFormats Uses

type FuncFilterFormats func([]*Format) []*Format

FuncFilterFormats defines a filter format test callback.

type FuncNewFiler Uses

type FuncNewFiler func(log cdtype.Logger, url string) (Filer, error)

FuncNewFiler defines the filer creation from a download backend.

type FuncPopupDialog Uses

type FuncPopupDialog func(cdtype.DialogData) error

FuncPopupDialog defines a dialog display function.

type HistoryVideo Uses

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 Uses

func NewHistoryVideo(app history.AppletLike, filename string) *HistoryVideo

NewHistoryVideo creates a videodl history manager with the given file location.

func (*HistoryVideo) Add Uses

func (h *HistoryVideo) Add(q *Video) error

Add adds a video to the download queue.

func (*HistoryVideo) Done Uses

func (h *HistoryVideo) Done() error

Done moves the first item in the queue to the done list.

func (*HistoryVideo) Find Uses

func (h *HistoryVideo) Find(url string) *Video

Find finds the video patching the given source url.

func (*HistoryVideo) Next Uses

func (h *HistoryVideo) Next() (*Video, bool)

Next returns the first video in the download queue.

func (*HistoryVideo) Queued Uses

func (h *HistoryVideo) Queued() int

Queued returns the size of the download queue.

func (*HistoryVideo) Remove Uses

func (h *HistoryVideo) Remove(vid *Video, list *[]*Video) error

Remove removes the given video from the given list.

type Manager Uses

type Manager struct {
    *Config
    *Commands

    EnabledWeb bool
    StartedWeb bool
    // contains filtered or unexported fields
}

Manager defines a video file download manager.

func NewManager Uses

func NewManager(control Controler, log cdtype.Logger, hist *HistoryVideo) *Manager

NewManager creates a video file download manager.

func (*Manager) Actions Uses

func (m *Manager) Actions(firstID int, actionAdd func(acts ...*cdtype.Action))

Actions fills an applet actions list with videodl actions.

func (*Manager) CancelDownload Uses

func (m *Manager) CancelDownload()

CancelDownload stops the current download.

func (*Manager) DialogCategory Uses

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 Uses

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 Uses

func (m *Manager) Download(url string)

Download downloads a video file from the server at configured quality (can be ask).

func (*Manager) Enqueue Uses

func (m *Manager) Enqueue(vid *Video)

Enqueue enqueues an item to the download list.

func (*Manager) EnqueueAndStart Uses

func (m *Manager) EnqueueAndStart(vid *Video)

EnqueueAndStart enqueues an item and starts downloading.

func (*Manager) FilePath Uses

func (m *Manager) FilePath(vid Video) string

FilePath returns the full path to the video file.

func (*Manager) FilterBlacklist Uses

func (m *Manager) FilterBlacklist() FuncFilterFormats

FilterBlacklist provides a filter formats call to remove blacklisted file types.

func (*Manager) IsActive Uses

func (m *Manager) IsActive() bool

IsActive returns whether a download is in progress or not.

func (*Manager) Menu Uses

func (m *Manager) Menu(menu cdtype.Menuer)

Menu fills an applet actions list with videodl actions.

func (*Manager) MenuQuality Uses

func (m *Manager) MenuQuality(menu cdtype.Menuer, qual *Quality, list []Quality)

MenuQuality returns the list of available streams and formats for the video.

func (*Manager) MenuTypeDL Uses

func (m *Manager) MenuTypeDL(menu cdtype.Menuer, typ *TypeDL)

MenuTypeDL fills the menu with a submenu to select TypeDL (audio, video or both).

func (*Manager) OpenFolder Uses

func (m *Manager) OpenFolder()

OpenFolder opens the destination folder.

func (*Manager) ServeHTTP Uses

func (m *Manager) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*Manager) SetConfig Uses

func (m *Manager) SetConfig(conf *Config)

SetConfig sets the config data for the manager.

func (*Manager) SetEditList Uses

func (m *Manager) SetEditList(call func() error)

SetEditList updates the edit list call action.

func (*Manager) SetEnabledWeb Uses

func (m *Manager) SetEnabledWeb(s WebState)

SetEnabledWeb sets the web service state.

func (*Manager) SetPostCheck Uses

func (m *Manager) SetPostCheck(call func() error)

SetPostCheck sets the post-upload action.

func (*Manager) SetPreCheck Uses

func (m *Manager) SetPreCheck(call func() error)

SetPreCheck sets the pre-upload action.

func (*Manager) SetStartedWeb Uses

func (m *Manager) SetStartedWeb(b bool)

SetStartedWeb sets the status of the web service.

func (*Manager) Start Uses

func (m *Manager) Start()

Start starts downloading queued items.

func (*Manager) ToggleEnableDownload Uses

func (m *Manager) ToggleEnableDownload()

ToggleEnableDownload toggles the status of the download activity (dl/pause).

func (*Manager) ToggleEnableWeb Uses

func (m *Manager) ToggleEnableWeb()

ToggleEnableWeb toggles the status of the web service.

func (*Manager) WebAutoStart Uses

func (m *Manager) WebAutoStart() func()

WebAutoStart starts temporarily the web service, until the returned stop func is called.

func (*Manager) WebRegister Uses

func (m *Manager) WebRegister()

WebRegister registers the web service.

func (*Manager) WebStart Uses

func (m *Manager) WebStart()

WebStart starts the web service.

func (*Manager) WebStop Uses

func (m *Manager) WebStop()

WebStop stops the web service.

func (*Manager) WebURL Uses

func (m *Manager) WebURL() string

WebURL formats the web service base url.

func (*Manager) WebUnregister Uses

func (m *Manager) WebUnregister()

WebUnregister unregister the web service.

type Progress Uses

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

Progress will try to provide download progress report.

func NewProgress Uses

func NewProgress() *Progress

NewProgress creates a download progress reporter.

func (*Progress) SetMax Uses

func (p *Progress) SetMax(m int64)

SetMax sets the expected size of the download.

func (*Progress) Write Uses

func (p *Progress) Write(data []byte) (n int, e error)

Write implements io.Writer to count download progress.

type Quality Uses

type Quality int

Quality defines the download quality setting.

const (
    QualityAsk Quality = iota
    QualityBestFound
    QualityBestPossible
    QualityCount // Number of quality actions defined.
)

Quality settings.

func (Quality) String Uses

func (q Quality) String() string

func (Quality) Tooltip Uses

func (q Quality) Tooltip() string

Tooltip returns the tooltip text displayed for the quality setting.

type TypeDL Uses

type TypeDL int

TypeDL defines the media type filtering.

const (
    TypeDLAll TypeDL = iota
    TypeDLAudio
    TypeDLVideo
    TypeDLVideoWithAudio
)

TypeDL settings.

func (TypeDL) String Uses

func (t TypeDL) String() string

func (TypeDL) Tooltip Uses

func (t TypeDL) Tooltip() string

Tooltip returns the tooltip text displayed for the media type filter.

type Video Uses

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

func NewVideo Uses

func NewVideo(url string, filer Filer) (*Video, error)

NewVideo creates a video for the remote url.

type VideoDler Uses

type VideoDler interface {
    New(log cdtype.Logger, url string) (Filer, error)
    MenuQuality() []Quality
}

VideoDler defines the backend interface.

type WebState Uses

type WebState int

WebState defines the state of the web service.

const (
    WebStateDisabled WebState = iota
    WebStateStopped
    WebStateStarted
)

TypeDL settings.

func (WebState) Tooltip Uses

func (s WebState) Tooltip() string

Tooltip returns the tooltip text displayed for the web service state.

type YTDL Uses

type YTDL struct{}

YTDL implements the VideoDler interface with internal ytdl library.

func (YTDL) MenuQuality Uses

func (f YTDL) MenuQuality() []Quality

MenuQuality returns the list of available streams and formats for the video.

func (YTDL) New Uses

func (f YTDL) New(log cdtype.Logger, url string) (Filer, error)

New creates a filer with the ytdl backend for the given url.

type YTDLFile Uses

type YTDLFile struct {
    ytdl.VideoInfo
    // contains filtered or unexported fields
}

YTDLFile defines a video file downloader around the ytdl library.

func (*YTDLFile) DownloadCmd Uses

func (f *YTDLFile) DownloadCmd(path string, locformat *Format, progress *Progress) func() error

DownloadCmd downloads the video file from server.

func (*YTDLFile) Formats Uses

func (f *YTDLFile) Formats() ([]*Format, error)

Formats returns the list of available streams and formats for the video.

func (*YTDLFile) Title Uses

func (f *YTDLFile) Title() (string, error)

Title gets the title of the video.

type YoutubeDL Uses

type YoutubeDL struct{}

YoutubeDL implements the VideoDler interface with external youtube-dl command.

func (YoutubeDL) MenuQuality Uses

func (f YoutubeDL) MenuQuality() []Quality

MenuQuality returns the list of available streams and formats for the video.

func (YoutubeDL) New Uses

func (f YoutubeDL) New(log cdtype.Logger, url string) (Filer, error)

New creates a filer with the youtube-dl backend for the given url.

type YoutubeDLFile Uses

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

YoutubeDLFile defines a video file downloader around the youtube-dl command.

func (*YoutubeDLFile) DownloadCmd Uses

func (f *YoutubeDLFile) DownloadCmd(path string, format *Format, progress *Progress) func() error

DownloadCmd downloads the video file from server.

func (*YoutubeDLFile) Formats Uses

func (f *YoutubeDLFile) Formats() ([]*Format, error)

Formats returns the list of available streams and formats for the video.

func (*YoutubeDLFile) Title Uses

func (f *YoutubeDLFile) Title() (string, error)

Title gets the title of the video.

Package videodl imports 25 packages (graph) and is imported by 1 packages. Updated 2017-10-02. Refresh now. Tools for package owners.