code cleanup

This commit is contained in:
2026-02-10 21:59:30 -05:00
parent 6ae35ec636
commit 4f34872f10
5 changed files with 97 additions and 91 deletions

View File

@@ -8,42 +8,6 @@ import (
"github.com/lrstanley/go-ytdlp"
)
type DownloadOptions struct {
EmbedThumbnail bool
IncludeSubtitles bool
VideoFormatID string
AudioFormatID string
}
type VideoOption struct {
Height *int `json:"height,omitempty"`
Resolution string `json:"resolution,omitempty"`
FormatID string `json:"format_id"`
Ext string `json:"ext"`
TBR *float64 `json:"tbr,omitempty"`
}
type AudioOption struct {
Format string `json:"format"`
FormatID string `json:"format_id"`
Ext string `json:"ext"`
TBR *float64 `json:"tbr,omitempty"`
Language *string `json:"language,omitempty"`
}
type FormatOptions struct {
VideoOptions []VideoOption `json:"video_options"`
AudioOptions []AudioOption `json:"audio_options"`
}
type ProgressUpdate struct {
Status ytdlp.ProgressStatus
Percent string
ETA time.Duration
Filename string
Phase string
}
func GetFormats(url string) (*FormatOptions, error) {
dl := ytdlp.New().
SkipDownload().
@@ -127,7 +91,7 @@ func GetFormats(url string) (*FormatOptions, error) {
return formatOpts, nil
}
func downloadVideo(out_dir, url string, opts DownloadOptions, progressChan chan<- ProgressUpdate) {
func DownloadVideo(out_dir, url string, opts DownloadOptions, progressChan chan<- ProgressUpdate) {
defer close(progressChan)
var lastPhase string