diff --git a/downloader/downloader.go b/downloader/downloader.go index 100e5ce2e..383274fb6 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -466,11 +466,6 @@ func mergeMultiPart(filepath string, parts []*FilePartMeta) error { // Download download urls func Download(v Data, refer string, chunkSizeMB int) error { v.genSortedStreams() - if config.ExtractedData { - jsonData, _ := json.MarshalIndent(v, "", " ") - fmt.Printf("%s\n", jsonData) - return nil - } var ( title string stream string diff --git a/main.go b/main.go index 6661e74d5..1b9e38cf9 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "flag" "fmt" "io/ioutil" @@ -175,6 +176,17 @@ func download(videoURL string) bool { return false } var isErr bool + + if config.ExtractedData { + jsonData, err := json.MarshalIndent(data, "", "\t") + if err != nil { + fmt.Printf("%s", err) + return isErr + } + fmt.Printf("%s\n", jsonData) + return !isErr + } + for _, item := range data { if item.Err != nil { // if this error occurs, the preparation step is normal, but the data extraction is wrong.