Versions in this module Expand all Collapse all v0 v0.3.1 Jun 2, 2023 v0.3.0 May 4, 2023 Changes in this version + var ErrInvalidDownloadType = errors.New("not a valid DownloadType") + var ErrInvalidDownloadVersion = errors.New("not a valid DownloadVersion") + func Censor(in string, pad string, chars int, front bool) string + func GetCurrentIPAddress(hClient *http.Client) (ip string) + func Truncate(in string, chars, mode int) string + type DownloadTask interface + Download func(ctx context.Context) error + Progress func(sb *strings.Builder) error + ResetDelta func() + Type func() DownloadType + type DownloadType int + const DownloadTypeLiveHLS + const DownloadTypeThreaded + func ParseDownloadType(name string) (DownloadType, error) + func (x *DownloadType) UnmarshalText(text []byte) error + func (x DownloadType) MarshalText() ([]byte, error) + func (x DownloadType) Ptr() *DownloadType + func (x DownloadType) String() string + type DownloadVersion int + const DownloadVersionV1 + func ParseDownloadVersion(name string) (DownloadVersion, error) + func (x *DownloadVersion) UnmarshalText(text []byte) error + func (x DownloadVersion) MarshalText() ([]byte, error) + func (x DownloadVersion) Ptr() *DownloadVersion + func (x DownloadVersion) String() string + type GlobalDownloadTracker struct + CurrentIP *atomic.String + DeltaBytes *atomic.Uint64 + DownloadedBytes *atomic.Uint64 + DownloadedFiles *atomic.Uint64 + GraceFulStop *atomic.Bool + IdleSince *atomic.Time + IdleTimeout *atomic.Int64 + IdleValue *atomic.Uint64 + LastTick *atomic.Time + Tasks *hashmap.Map[string, DownloadTask] + TotalBytes *atomic.Uint64 + TotalFiles *atomic.Uint64 + TotalThreads *atomic.Uint64 + func NewGlobalDownloadTracker(idleTimeout time.Duration) *GlobalDownloadTracker + func (global *GlobalDownloadTracker) IdleTimeoutExceeded() bool + func (global *GlobalDownloadTracker) PollIP(hClient *http.Client) + func (global *GlobalDownloadTracker) Stop() + func (global *GlobalDownloadTracker) Tick(humanReadable bool) string + type StreamHLSTask struct + BaseUrl *url.URL + BufferChan chan *bytes.Buffer + FileLocation *atomic.String + FileName *atomic.String + Global *GlobalDownloadTracker + HClient *http.Client + Muxer *StreamMuxer + Opts []gokhttp_requests.Option + PlayListUrl *atomic.String + ReqOpts []gokhttp_requests.Option + SaveSegments bool + SegmentCache *hashmap.Map[string, time.Time] + SegmentChan chan *m3u8.SegmentItem + TaskStats *StreamStats + TaskType DownloadType + TaskVersion DownloadVersion + func NewStreamHLSTask(global *GlobalDownloadTracker, hClient *http.Client, ...) (*StreamHLSTask, error) + func (st *StreamHLSTask) Download(ctx context.Context) error + func (st *StreamHLSTask) Progress(sb *strings.Builder) error + func (st *StreamHLSTask) ResetDelta() + func (st *StreamHLSTask) Type() DownloadType + type StreamMuxer struct + Demuxer *mpeg2.TSDemuxer + F *os.File + Muxer *mpeg2.TSMuxer + Streams map[mpeg2.TS_STREAM_TYPE]uint16 + func NewStreamMuxer(f *os.File) *StreamMuxer + func (m *StreamMuxer) AddStreams(buf *bytes.Buffer) error + func (m *StreamMuxer) Demux(cid mpeg2.TS_STREAM_TYPE, frame []byte, pts uint64, dts uint64) + func (m *StreamMuxer) Mux(pkg []byte) + type StreamStats struct + DownloadedBytes *atomic.Uint64 + DownloadedDuration *atomic.Int64 + DownloadedSegments *atomic.Uint64 + type ThreadedChunk struct + ChunkID *atomic.Uint64 + ChunkStart uint64 + ChunkStop uint64 + DeltaBytes *atomic.Uint64 + DownloadedBytes *atomic.Uint64 + F *os.File + FileSize *atomic.Uint64 + type ThreadedDownloadTask struct + ChunkCount *atomic.Uint64 + Chunks *hashmap.Map[string, *ThreadedChunk] + FileLocation *atomic.String + FileName *atomic.String + FileURL *atomic.String + Global *GlobalDownloadTracker + HClient *http.Client + ReqOpts []gokhttp_requests.Option + Resumable *atomic.Bool + TaskStats *ThreadedChunk + TaskType DownloadType + TaskVersion DownloadVersion + func NewThreadedDownloadTask(ctx context.Context, hClient *http.Client, global *GlobalDownloadTracker, ...) (*ThreadedDownloadTask, error) + func (tt *ThreadedDownloadTask) Download(ctx context.Context) error + func (tt *ThreadedDownloadTask) Progress(sb *strings.Builder) error + func (tt *ThreadedDownloadTask) ResetDelta() + func (tt *ThreadedDownloadTask) Type() DownloadType