Documentation ¶
Overview ¶
Package godler provides ...
Package godler provides ...
Package godler provides ...
Package godler provides ...
Package godler provides ...
Package godler provides ...
Package godler provides ...
Package godler provides ...
Package godler provides ...
Package godler provides ...
Index ¶
- Constants
- Variables
- func AppendFile(filePath string, b []byte) error
- func FileExists(filepath string) bool
- func GetDefaultDownloadDir() string
- func GetDownloadDir() string
- func GetReaderFromURI(uri string) (io.Reader, error)
- func ProcessDownloadTasker(t IDownloadTasker)
- func RunDownloadTasker(t IDownloadTasker) error
- func WriteFile(filePath string, b []byte) error
- type DownloadConfig
- type DownloadInfo
- type DownloadTaskConfig
- type DownloadTasker
- type DownloadType
- type Downloader
- func (d *Downloader) Build() error
- func (d Downloader) Download(info *DownloadInfo) error
- func (d Downloader) FormatPath(uri string) string
- func (d Downloader) FormatURI(uri string) string
- func (d Downloader) GetCacheDir() string
- func (d Downloader) GetDir() string
- func (d Downloader) GetName() string
- func (d Downloader) GetPath() string
- func (d Downloader) Match() bool
- func (d Downloader) Process() float64
- type FileDownloader
- type Header
- type IDownloadTasker
- type IDownloader
- type IPathFormater
- type ITasker
- type IType
- type IURIFormater
- type Logger
- type M3U8Downloader
- type NewDownloaderFunc
- type RangeSegment
- type Segment
- type Task
- type TaskFunc
- type Tasker
- func (t *Tasker) AddTask(task *Task)
- func (t *Tasker) AfterRun() error
- func (t *Tasker) BeforeRun() error
- func (t *Tasker) Build() error
- func (t *Tasker) BuildTasks() error
- func (t Tasker) GetTasks() []*Task
- func (t *Tasker) Run(runTaskFunc TaskFunc) error
- func (t *Tasker) SyncRun(runTaskFunc TaskFunc) error
- type TaskerConfig
- type UrlType
Constants ¶
View Source
const ( PermFile fs.FileMode = 0666 PermDir = 0755 )
View Source
const (
DOWNLOAD_DIR string = "~/Downloads"
)
View Source
const (
SEGMENT_SIZE int = 16 * 1024 * 1024
)
Variables ¶
View Source
var (
LoggerPath string
)
Functions ¶
func AppendFile ¶
func GetDefaultDownloadDir ¶
func GetDefaultDownloadDir() string
func GetDownloadDir ¶
func GetDownloadDir() string
func ProcessDownloadTasker ¶
func ProcessDownloadTasker(t IDownloadTasker)
func RunDownloadTasker ¶
func RunDownloadTasker(t IDownloadTasker) error
Types ¶
type DownloadConfig ¶
func NewDownloadConfig ¶
func NewDownloadConfig(downloadDir string, name string) *DownloadConfig
type DownloadInfo ¶
type DownloadTaskConfig ¶
type DownloadTaskConfig struct { *TaskerConfig *DownloadConfig }
func NewDownloadTaskConfig ¶
func NewDownloadTaskConfig( downloadDir string, name string, ) *DownloadTaskConfig
type DownloadTasker ¶
type DownloadTasker struct { *Tasker *Downloader }
func NewDownloadTasker ¶
func NewDownloadTasker( uri string, config *DownloadTaskConfig, ) (*DownloadTasker, error)
func (*DownloadTasker) AfterRun ¶
func (dt *DownloadTasker) AfterRun() error
type DownloadType ¶
type DownloadType string
const ( TYPE_M3U8 DownloadType = "m3u8" TYPE_FILE = "file" )
type Downloader ¶
type Downloader struct { *tools.URL Config *DownloadConfig // 下载配置 Segments *[]Segment // 下载片段集合 // contains filtered or unexported fields }
下载器父类
func NewDownloader ¶
func NewDownloader(uri string, config *DownloadConfig) (*Downloader, error)
初始化 Downloader
func (*Downloader) Build ¶
func (d *Downloader) Build() error
func (Downloader) Download ¶
func (d Downloader) Download(info *DownloadInfo) error
func (Downloader) FormatPath ¶
func (d Downloader) FormatPath(uri string) string
func (Downloader) FormatURI ¶
func (d Downloader) FormatURI(uri string) string
func (Downloader) GetCacheDir ¶
func (d Downloader) GetCacheDir() string
func (Downloader) GetDir ¶
func (d Downloader) GetDir() string
func (Downloader) GetName ¶
func (d Downloader) GetName() string
func (Downloader) GetPath ¶
func (d Downloader) GetPath() string
func (Downloader) Match ¶
func (d Downloader) Match() bool
type FileDownloader ¶
type FileDownloader struct { *DownloadTasker RangeSegments *[]RangeSegment WithPart bool CacheDir string }
func NewFileDownloader ¶
func NewFileDownloader(dt *DownloadTasker) *FileDownloader
func (*FileDownloader) AfterRun ¶
func (f *FileDownloader) AfterRun() error
func (*FileDownloader) Build ¶
func (f *FileDownloader) Build() error
func (*FileDownloader) BuildTasks ¶
func (f *FileDownloader) BuildTasks() error
func (FileDownloader) Match ¶
func (f FileDownloader) Match() bool
func (FileDownloader) MergeFile ¶
func (f FileDownloader) MergeFile()
type Header ¶
type Header struct { ContentLength []string `json:"Content-Length"` AcceptRanges []string `json:"Accept-Ranges"` }
func (Header) GetAcceptRanges ¶
func (Header) GetContentLength ¶
func (Header) GetRangeSegments ¶
func (h Header) GetRangeSegments(SegmentSize int) []RangeSegment
type IDownloadTasker ¶
type IDownloadTasker interface { ITasker IDownloader RunTask(*Task) error }
下载任务管理器
func MatchDownloadTasker ¶
func MatchDownloadTasker( uri string, config *DownloadTaskConfig, ) (IDownloadTasker, error)
匹配下载任务器
type IDownloader ¶
type IDownloader interface { Match() bool Build() error Download(*DownloadInfo) error Process() float64 }
下载接口
type IPathFormater ¶
type IType ¶
type IType interface {
Match(string) DownloadType
}
type IURIFormater ¶
type Logger ¶
type Logger interface { Infof(format string, v ...interface{}) Errorf(format string, v ...interface{}) Warnf(format string, v ...interface{}) Debugf(format string, v ...interface{}) }
var (
Log Logger
)
type M3U8Downloader ¶
type M3U8Downloader struct { *DownloadTasker M3U8PlayList m3u8.Playlist M3U8ListType m3u8.ListType }
func NewM3U8Downloader ¶
func NewM3U8Downloader(dt *DownloadTasker) *M3U8Downloader
func (*M3U8Downloader) Build ¶
func (m *M3U8Downloader) Build() error
func (*M3U8Downloader) BuildTasks ¶
func (m *M3U8Downloader) BuildTasks() error
func (M3U8Downloader) FormatPath ¶
func (m M3U8Downloader) FormatPath(uri string) string
func (M3U8Downloader) Match ¶
func (m M3U8Downloader) Match() bool
func (M3U8Downloader) SaveM3U8 ¶
func (m M3U8Downloader) SaveM3U8(mediaPlaylist *m3u8.MediaPlaylist)
保存 m3u8 数据
type NewDownloaderFunc ¶
type NewDownloaderFunc func(*DownloadTasker) IDownloadTasker
type RangeSegment ¶
type Tasker ¶
type Tasker struct { TaskId string Config *TaskerConfig Tasks []*Task WaitGroup sync.WaitGroup // contains filtered or unexported fields }
func NewTasker ¶
func NewTasker(config *TaskerConfig) *Tasker
func (*Tasker) BuildTasks ¶
type TaskerConfig ¶
func NewTaskerConfig ¶
func NewTaskerConfig() *TaskerConfig
Source Files ¶
Click to show internal directories.
Click to hide internal directories.