code cleanup
This commit is contained in:
38
app/ytdlp.go
38
app/ytdlp.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user