Documentation
¶
Index ¶
- Constants
- func GetDistFS() fs.FS
- type BulkDownloadRequest
- type ConfigRequest
- type ConfigSetRequest
- type DownloadFunc
- type DownloadRequest
- type GenerateTokenRequest
- type HistoryDB
- func (h *HistoryDB) ClearHistory() (int64, error)
- func (h *HistoryDB) Close() error
- func (h *HistoryDB) DeleteRecord(id string) error
- func (h *HistoryDB) GetHistory(limit, offset int) ([]HistoryRecord, int, error)
- func (h *HistoryDB) GetStats() (completed int, failed int, totalBytes int64, err error)
- func (h *HistoryDB) RecordJob(job *Job) error
- type HistoryRecord
- type JWTClaims
- type Job
- type JobQueue
- func (jq *JobQueue) AddFailedJob(rawURL, errorMsg string) *Job
- func (jq *JobQueue) AddJob(rawURL, filename string) (*Job, error)
- func (jq *JobQueue) CancelJob(id string) bool
- func (jq *JobQueue) ClearHistory() int
- func (jq *JobQueue) GetAllJobs() []*Job
- func (jq *JobQueue) GetJob(id string) *Job
- func (jq *JobQueue) RemoveJob(id string) bool
- func (jq *JobQueue) SetHistoryDB(db *HistoryDB)
- func (jq *JobQueue) Start()
- func (jq *JobQueue) Stop()
- type JobStatus
- type PodcastChannel
- type PodcastEpisode
- type PodcastEpisodesRequest
- type PodcastSearchRequest
- type PodcastSearchResult
- type Response
- type Server
- type TorrentAddRequest
- type TorrentConfigRequest
- type TrackRequest
- type WebDAVConfigRequest
- type WebDAVDownloadRequest
- type WebDAVFileInfo
- type WebDAVRemoteInfo
Constants ¶
const ( // SessionCookieName is the name of the session cookie SessionCookieName = "vget_session" // SessionDuration is the duration for session tokens (24 hours) SessionDuration = 24 * time.Hour // APITokenDuration is the duration for API tokens (1 year) APITokenDuration = 365 * 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BulkDownloadRequest ¶ added in v0.11.6
type BulkDownloadRequest struct {
URLs []string `json:"urls" binding:"required"`
}
BulkDownloadRequest is the request body for POST /bulk-download
type ConfigRequest ¶
type ConfigRequest struct {
OutputDir string `json:"output_dir,omitempty"`
}
ConfigRequest is the request body for PUT /config
type ConfigSetRequest ¶ added in v0.8.3
type ConfigSetRequest struct {
Key string `json:"key" binding:"required"`
Value string `json:"value"`
}
ConfigSetRequest is the request body for POST /config
type DownloadFunc ¶
type DownloadFunc func(ctx context.Context, url, outputPath string, progressFn func(downloaded, total int64)) error
DownloadFunc is the function signature for downloading a URL It receives the job context, URL, output path, and a progress callback
type DownloadRequest ¶
type DownloadRequest struct {
URL string `json:"url" binding:"required"`
Filename string `json:"filename,omitempty"`
ReturnFile bool `json:"return_file,omitempty"`
}
DownloadRequest is the request body for POST /download
type GenerateTokenRequest ¶ added in v0.12.13
GenerateTokenRequest is the request body for POST /api/auth/token
type HistoryDB ¶ added in v0.12.16
type HistoryDB struct {
// contains filtered or unexported fields
}
HistoryDB manages SQLite database for download history
func NewHistoryDB ¶ added in v0.12.16
NewHistoryDB creates and initializes the history database
func (*HistoryDB) ClearHistory ¶ added in v0.12.16
ClearHistory deletes all history records
func (*HistoryDB) DeleteRecord ¶ added in v0.12.16
DeleteRecord deletes a single history record
func (*HistoryDB) GetHistory ¶ added in v0.12.16
func (h *HistoryDB) GetHistory(limit, offset int) ([]HistoryRecord, int, error)
GetHistory returns download history with pagination
type HistoryRecord ¶ added in v0.12.16
type HistoryRecord struct {
ID string `json:"id"`
URL string `json:"url"`
Filename string `json:"filename"`
Status string `json:"status"` // "completed" or "failed"
SizeBytes int64 `json:"size_bytes"`
StartedAt int64 `json:"started_at"` // Unix timestamp
CompletedAt int64 `json:"completed_at"` // Unix timestamp
Duration int64 `json:"duration_seconds"`
Error string `json:"error,omitempty"`
}
HistoryRecord represents a completed download in history
type JWTClaims ¶ added in v0.12.13
type JWTClaims struct {
TokenType string `json:"type"` // "session" or "api"
Custom map[string]any `json:"custom,omitempty"`
jwt.RegisteredClaims
}
JWTClaims represents the claims in a JWT token
type Job ¶
type Job struct {
ID string `json:"id"`
URL string `json:"url"`
Filename string `json:"filename,omitempty"`
Status JobStatus `json:"status"`
Progress float64 `json:"progress"`
Downloaded int64 `json:"downloaded"` // bytes downloaded
Total int64 `json:"total"` // total bytes (-1 if unknown)
Error string `json:"error,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// contains filtered or unexported fields
}
Job represents a download job
type JobQueue ¶
type JobQueue struct {
// contains filtered or unexported fields
}
JobQueue manages download jobs with a worker pool
func NewJobQueue ¶
func NewJobQueue(maxConcurrent int, outputDir string, downloadFn DownloadFunc) *JobQueue
NewJobQueue creates a new job queue with the specified concurrency
func (*JobQueue) AddFailedJob ¶ added in v0.11.6
AddFailedJob creates a job that immediately fails with the given error
func (*JobQueue) ClearHistory ¶ added in v0.8.7
ClearHistory removes all completed, failed, and cancelled jobs
func (*JobQueue) RemoveJob ¶ added in v0.8.7
RemoveJob removes a single completed, failed, or cancelled job by ID
func (*JobQueue) SetHistoryDB ¶ added in v0.12.16
SetHistoryDB sets the history database for persisting completed downloads
type PodcastChannel ¶ added in v0.10.2
type PodcastChannel struct {
ID string `json:"id"`
Title string `json:"title"`
Author string `json:"author"`
Description string `json:"description"`
EpisodeCount int `json:"episode_count"`
FeedURL string `json:"feed_url,omitempty"` // iTunes only
Source string `json:"source"` // "xiaoyuzhou" or "itunes"
}
type PodcastEpisode ¶ added in v0.10.2
type PodcastEpisode struct {
ID string `json:"id"`
Title string `json:"title"`
PodcastName string `json:"podcast_name"`
Duration int `json:"duration"` // seconds
PubDate string `json:"pub_date,omitempty"`
DownloadURL string `json:"download_url"`
Source string `json:"source"` // "xiaoyuzhou" or "itunes"
}
type PodcastEpisodesRequest ¶ added in v0.10.2
type PodcastSearchRequest ¶ added in v0.10.2
type PodcastSearchResult ¶ added in v0.10.2
type PodcastSearchResult struct {
Source string `json:"source"` // "xiaoyuzhou" or "itunes"
Podcasts []PodcastChannel `json:"podcasts"` // podcast channels
Episodes []PodcastEpisode `json:"episodes"` // individual episodes
}
type Response ¶
type Response struct {
Code int `json:"code"`
Data any `json:"data"`
Message string `json:"message"`
}
Response is the standard API response structure
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP server for vget
type TorrentAddRequest ¶ added in v0.10.0
type TorrentAddRequest struct {
URL string `json:"url" binding:"required"` // Magnet link or .torrent URL
SavePath string `json:"save_path,omitempty"`
Paused bool `json:"paused,omitempty"`
}
TorrentAddRequest is the request body for POST /torrent
type TorrentConfigRequest ¶ added in v0.10.0
type TorrentConfigRequest struct {
Enabled bool `json:"enabled"`
Client string `json:"client"`
Host string `json:"host"`
Username string `json:"username"`
Password string `json:"password"`
UseHTTPS bool `json:"use_https"`
DefaultSavePath string `json:"default_save_path"`
}
TorrentConfigRequest is the request body for POST /config/torrent
type TrackRequest ¶ added in v0.8.6
type TrackRequest struct {
TrackingNumber string `json:"tracking_number" binding:"required"`
Courier string `json:"courier" binding:"required"`
}
TrackRequest is the request body for POST /kuaidi100
type WebDAVConfigRequest ¶ added in v0.8.3
type WebDAVConfigRequest struct {
Name string `json:"name" binding:"required"`
URL string `json:"url" binding:"required"`
Username string `json:"username"`
Password string `json:"password"`
}
WebDAVConfigRequest is the request body for WebDAV server operations
type WebDAVDownloadRequest ¶ added in v0.10.0
type WebDAVDownloadRequest struct {
Remote string `json:"remote" binding:"required"`
Files []string `json:"files" binding:"required"`
}
WebDAVDownloadRequest is the request body for POST /api/webdav/download
type WebDAVFileInfo ¶ added in v0.10.0
type WebDAVFileInfo struct {
Name string `json:"name"`
Path string `json:"path"`
Size int64 `json:"size"`
IsDir bool `json:"isDir"`
}
WebDAVFileInfo is the response for a single file/directory
type WebDAVRemoteInfo ¶ added in v0.10.0
type WebDAVRemoteInfo struct {
Name string `json:"name"`
URL string `json:"url"`
HasAuth bool `json:"hasAuth"`
}
WebDAVRemoteInfo is the response for a single remote