package main import ( "github.com/iawia002/lux/downloader" "github.com/iawia002/lux/extractors" ) func download(videoURL string, wantPlaylist bool, outputPath string) bool { data, err := extractors.Extract(videoURL, extractors.Options{ Playlist: wantPlaylist, }) if err != nil { // if this error occurs, it means that an error occurred before actually starting to extract data // (there is an error in the preparation step), and the data list is empty. printError(videoURL, err) return false } var isErr bool for _, item := range data { if item.Err != nil { // if this error occurs, the preparation step is normal, but the data extraction is wrong. // the data is an empty struct. printError(item.URL, item.Err) isErr = true continue } err = downloader.New(downloader.Options{ OutputPath: outputPath, }).Download(item) if err != nil { printError(item.URL, err) isErr = true } } return !isErr }