core

package
v0.0.0-...-447db5d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExtensionGroups = map[FileType][]string{
	TypeVideo: {
		".mp4", ".mkv", ".avi", ".mov", ".wmv", ".flv", ".webm", ".m4v",
		".mpg", ".mpeg", ".m2ts", ".mts", ".ts", ".m3u8", ".mpd", ".iso",
		".vob", ".3gp", ".ogv", ".ogg", ".qt", ".rm", ".rmvb", ".asf",
		".divx", ".xvid", ".264", ".265", ".hevc",
	},
	TypeMusic: {
		".mp3", ".wav", ".flac", ".aac", ".ogg", ".m4a", ".opus", ".wma",
		".alac", ".ape", ".dsd", ".dff", ".dsf", ".mid", ".midi", ".ra",
		".voc", ".vox", ".aiff", ".au", ".snd", ".amr", ".awb", ".weba",
	},
	TypeImage: {
		".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg", ".webp", ".ico",
		".tiff", ".tif", ".raw", ".cr2", ".nef", ".arw", ".dng", ".heif",
		".heic", ".jfif", ".pjpeg", ".pjp", ".avif", ".apng", ".cur",
	},
	TypeDocument: {
		".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt",
		".rtf", ".odt", ".ods", ".odp", ".odg", ".csv", ".json", ".xml",
		".md", ".epub", ".mobi", ".azw", ".azw3", ".cbr", ".cbz", ".ps",
		".tex", ".log", ".ini", ".cfg", ".conf", ".yaml", ".yml",
	},
	TypeArchive: {
		".zip", ".rar", ".7z", ".tar", ".gz", ".bz2", ".xz", ".tgz",
		".tbz2", ".txz", ".zst", ".lzma", ".lz", ".lzh", ".cab", ".arj",
		".deb", ".rpm", ".pkg", ".msi", ".apk", ".ipa", ".jar", ".war",
	},
}
View Source
var LogHook func(level, msg string)

Functions

func DownloadFromCapturedJSON

func DownloadFromCapturedJSON(jsonFile string, maxConcurrent int) error

func InitDefaults

func InitDefaults()

func InstallCertificate

func InstallCertificate() error

func RunHAD

func RunHAD()

func ShowManualInstructions

func ShowManualInstructions()

func Size4Human

func Size4Human(n int64) string

Types

type AdaptiveBuffer

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

func (*AdaptiveBuffer) Size

func (ab *AdaptiveBuffer) Size() int

func (*AdaptiveBuffer) Update

func (ab *AdaptiveBuffer) Update(speedMBps float64)

type BWScheduleConfig

type BWScheduleConfig struct {
	NightFrom  string `json:"night_from"`
	NightTo    string `json:"night_to"`
	DayLimit   int64  `json:"day_limit"`
	NightLimit int64  `json:"night_limit"`
}

type BandwidthSchedule

type BandwidthSchedule struct {
	From time.Time
	To   time.Time
}

func (*BandwidthSchedule) IsActive

func (bs *BandwidthSchedule) IsActive() bool

type CaptureConfig

type CaptureConfig struct {
	Port             string
	FileTypes        []FileType
	CustomExtensions []string
	Headers          map[string]string
	Cookie           string
	AutoDownload     bool
	OutputDir        string
	MinFileSize      int64
	MaxFileSize      int64
	ConfidenceLevel  int
	SaveToFile       string
	Verbose          bool
	CaptureBody      bool
	FilterDomain     string
	FilterPattern    string
	DedupeWindow     time.Duration
	MaxCaptured      int
}

type CaptureProxy

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

func NewCaptureProxy

func NewCaptureProxy(config *CaptureConfig) *CaptureProxy

func (*CaptureProxy) ExportLogs

func (cp *CaptureProxy) ExportLogs(format, filename string) error

func (*CaptureProxy) GetCapturedItems

func (cp *CaptureProxy) GetCapturedItems() []CapturedItem

func (*CaptureProxy) GetRequestLogs

func (cp *CaptureProxy) GetRequestLogs() []RequestLog

func (*CaptureProxy) GetStats

func (cp *CaptureProxy) GetStats() map[string]interface{}

func (*CaptureProxy) Start

func (cp *CaptureProxy) Start() error

type CapturedItem

type CapturedItem struct {
	URL          string            `json:"url"`
	FileType     FileType          `json:"file_type"`
	Extension    string            `json:"extension"`
	Size         int64             `json:"size"`
	Title        string            `json:"title"`
	SourceURL    string            `json:"source_url"`
	Timestamp    time.Time         `json:"timestamp"`
	Confidence   int               `json:"confidence"`
	Method       string            `json:"method"`
	StatusCode   int               `json:"status_code"`
	ContentType  string            `json:"content_type"`
	Headers      map[string]string `json:"headers,omitempty"`
	Downloaded   bool              `json:"downloaded"`
	DownloadPath string            `json:"download_path,omitempty"`
}

type DownloadQueue

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

func NewDownloadQueue

func NewDownloadQueue() *DownloadQueue

func (*DownloadQueue) Add

func (q *DownloadQueue) Add(u string, priority int)

func (*DownloadQueue) Len

func (q *DownloadQueue) Len() int

func (*DownloadQueue) LoadFromFile

func (q *DownloadQueue) LoadFromFile(path string) error

func (*DownloadQueue) Pop

func (q *DownloadQueue) Pop() (QueueItem, bool)

type DownloadTask

type DownloadTask struct {
	GID      string
	URLs     []string
	Status   string
	Added    time.Time
	Started  time.Time
	Finished time.Time
	Cancel   context.CancelFunc
	FileName string
	Size     int64
	Done     int64
	Error    string
}

type Downloader

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

func (*Downloader) Pause

func (dl *Downloader) Pause()

func (*Downloader) Run

func (dl *Downloader) Run()

type File

type File struct {
	Name   string  `xml:"name,attr"`
	Size   int64   `xml:"size"`
	Hashes []Hash  `xml:"hash"`
	URLs   []URL   `xml:"url"`
	Pieces []Piece `xml:"pieces"`
}

type File4

type File4 struct {
	Name string `xml:"name,attr"`
	Size int64  `xml:"size"`
	URLs []URL4 `xml:"url"`
}

type FileMetadata

type FileMetadata struct {
	FileName    string `json:"file_name"`
	Size        int64  `json:"size"`
	SizeHuman   string `json:"size_human"`
	Extension   string `json:"extension"`
	ContentType string `json:"content_type"`
	Resumable   bool   `json:"resumable"`
	Checksum    string `json:"checksum_hint,omitempty"`
	LastMod     string `json:"last_modified,omitempty"`
}

func FetchFileMetadata

func FetchFileMetadata(rawURL string, client *http.Client) (*FileMetadata, error)

type FileStatus

type FileStatus struct {
	Name          string
	URL           string
	Size          int64
	Done          int64
	Total         int64
	Status        string
	StartTime     time.Time
	EndTime       time.Time
	TotalThreads  int
	DoneThreads   int
	ActiveThreads int
	ThreadProg    []int64
	// contains filtered or unexported fields
}

type FileType

type FileType string
const (
	TypeVideo    FileType = "video"
	TypeMusic    FileType = "music"
	TypeImage    FileType = "image"
	TypeDocument FileType = "document"
	TypeArchive  FileType = "archive"
	TypeAll      FileType = "all"
)

type GlobalStatus

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

func NewGlobalStatus

func NewGlobalStatus() *GlobalStatus

func (*GlobalStatus) PauseAllFiles

func (gs *GlobalStatus) PauseAllFiles() int

func (*GlobalStatus) PauseFile

func (gs *GlobalStatus) PauseFile(name string) error

func (*GlobalStatus) PausedFiles

func (gs *GlobalStatus) PausedFiles() []*FileStatus

func (*GlobalStatus) RemoveFile

func (gs *GlobalStatus) RemoveFile(name string) error

func (*GlobalStatus) ResumeFile

func (gs *GlobalStatus) ResumeFile(name string) (rawURL string, size int64, err error)

type HLSDownloader

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

func NewHLSDownloader

func NewHLSDownloader(rawURL, outPath, fileName string, client *http.Client, gs *GlobalStatus, notifier *Notifier) *HLSDownloader

func (*HLSDownloader) Download

func (h *HLSDownloader) Download() error

type Hash

type Hash struct {
	Type string `xml:"type,attr"`
	Data string `xml:",chardata"`
}

type HistoryEntry

type HistoryEntry struct {
	GID       string    `json:"gid"`
	FileName  string    `json:"file_name"`
	Size      int64     `json:"size"`
	SizeHuman string    `json:"size_human"`
	URL       string    `json:"url"`
	Status    string    `json:"status"`
	Added     time.Time `json:"added"`
	Finished  time.Time `json:"finished"`
	AvgSpeed  string    `json:"avg_speed"`
	Duration  string    `json:"duration"`
}

type Logger

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

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

func (*Logger) SetVerbose

func (l *Logger) SetVerbose(v bool)

func (*Logger) Success

func (l *Logger) Success(format string, args ...interface{})

func (*Logger) Warning

func (l *Logger) Warning(format string, args ...interface{})

type MagnetInfo

type MagnetInfo struct {
	InfoHash    string
	DisplayName string
	Trackers    []string
	WebSeeds    []string
}
type Metalink struct {
	XMLName xml.Name `xml:"metalink"`
	Files   []File   `xml:"file"`
}

type Metalink4

type Metalink4 struct {
	XMLName xml.Name `xml:"metalink"`
	Files   []File4  `xml:"file"`
}

type MirrorResult

type MirrorResult struct {
	URL     string
	Latency time.Duration
}

type MirrorTestResult

type MirrorTestResult struct {
	URL        string `json:"url"`
	Latency    int64  `json:"latency_ms"`
	SpeedBps   int64  `json:"speed_bps"`
	SpeedHuman string `json:"speed_human"`
	Reachable  bool   `json:"reachable"`
	Rank       int    `json:"rank"`
}

type Notifier

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

func NewNotifier

func NewNotifier() *Notifier

func (*Notifier) IsEnabled

func (n *Notifier) IsEnabled() bool

func (*Notifier) Send

func (n *Notifier) Send(title, message string)

type Piece

type Piece struct {
	Length int    `xml:"length,attr"`
	Type   string `xml:"type,attr"`
	Hash   string `xml:",chardata"`
}

type PostProcessor

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

func NewPostProcessor

func NewPostProcessor(notifier *Notifier) *PostProcessor

func (*PostProcessor) Run

func (pp *PostProcessor) Run(filePath string)

type QueueItem

type QueueItem struct {
	URL      string
	Priority int
	Added    time.Time
}

type RPCCommand

type RPCCommand struct {
	ID     interface{}            `json:"id"`
	Method string                 `json:"method"`
	Params map[string]interface{} `json:"params"`
}

type RPCError

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type RPCResponse

type RPCResponse struct {
	ID     interface{} `json:"id"`
	Result interface{} `json:"result,omitempty"`
	Error  *RPCError   `json:"error,omitempty"`
}

type RPCServer

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

func NewRPCServer

func NewRPCServer(global *GlobalStatus) *RPCServer

func (*RPCServer) Start

func (rpc *RPCServer) Start(addr string) error

func (*RPCServer) Stop

func (rpc *RPCServer) Stop() error

type RequestLog

type RequestLog struct {
	Method      string            `json:"method"`
	URL         string            `json:"url"`
	Host        string            `json:"host"`
	Path        string            `json:"path"`
	QueryParams map[string]string `json:"query_params,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	Timestamp   time.Time         `json:"timestamp"`
}

type Session

type Session struct {
	URL       string
	Path      string
	Size      int64
	Ranges    [][2]int64
	FileName  string
	Progress  []int64
	Checksum  string
	Algorithm string
	CreatedAt time.Time
	UpdatedAt time.Time
	Mirrors   []string
}

type SessionInfo

type SessionInfo struct {
	File            string    `json:"file"`
	FileName        string    `json:"file_name"`
	URL             string    `json:"url"`
	Size            int64     `json:"size"`
	SizeHuman       string    `json:"size_human"`
	Downloaded      int64     `json:"downloaded"`
	DownloadedHuman string    `json:"downloaded_human"`
	Progress        float64   `json:"progress"`
	Mirrors         int       `json:"mirrors"`
	Checksum        string    `json:"checksum,omitempty"`
	Algorithm       string    `json:"algorithm,omitempty"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type SmartMirrorSelector

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

func NewSmartMirrorSelector

func NewSmartMirrorSelector(urls []string, client *http.Client) *SmartMirrorSelector

func (*SmartMirrorSelector) Best

func (s *SmartMirrorSelector) Best() string

func (*SmartMirrorSelector) ReportFailure

func (s *SmartMirrorSelector) ReportFailure(url string)

func (*SmartMirrorSelector) ShouldRetest

func (s *SmartMirrorSelector) ShouldRetest(url string) bool

func (*SmartMirrorSelector) TestAll

func (s *SmartMirrorSelector) TestAll()

type URL

type URL struct {
	Location string `xml:"location,attr"`
	URL      string `xml:",chardata"`
	Priority int    `xml:"priority,attr"`
}

type URL4

type URL4 struct {
	URL string `xml:",chardata"`
}

type WebDAVDownloader

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

func NewWebDAVDownloader

func NewWebDAVDownloader(baseURL, user, pass string, client *http.Client, gs *GlobalStatus) *WebDAVDownloader

func (*WebDAVDownloader) DownloadAll

func (w *WebDAVDownloader) DownloadAll(path string)

func (*WebDAVDownloader) DownloadFile

func (w *WebDAVDownloader) DownloadFile(path, fileName string, size int64)

func (*WebDAVDownloader) List

func (w *WebDAVDownloader) List(path string) ([]webdavResponse, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址