From e9be0f303545f40576758bd788ba171d47da9805 Mon Sep 17 00:00:00 2001 From: ma6254 <9a6c5609806a@gmail.com> Date: Fri, 6 Mar 2020 00:20:58 +0800 Subject: [PATCH] fix #621 --- downloader/downloader.go | 5 ----- main.go | 12 ++++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) 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.