Better tracking (Size and failure reason) #35
1 changed files with 6 additions and 6 deletions
|
@ -123,11 +123,11 @@ func (v *YoutubeVideo) download() error {
|
||||||
|
|
||||||
var downloadedFile *os.File
|
var downloadedFile *os.File
|
||||||
downloadedFile, err = os.Create(videoPath)
|
downloadedFile, err = os.Create(videoPath)
|
||||||
|
defer downloadedFile.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer downloadedFile.Close()
|
|
||||||
return videoInfo.Download(videoInfo.Formats.Best(ytdl.FormatAudioEncodingKey)[1], downloadedFile)
|
return videoInfo.Download(videoInfo.Formats.Best(ytdl.FormatAudioEncodingKey)[1], downloadedFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,17 +171,17 @@ func (v *YoutubeVideo) triggerThumbnailSave() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var decoded struct {
|
var decoded struct {
|
||||||
error int `json:"error"`
|
Error int `json:"error"`
|
||||||
url string `json:"url,omitempty"`
|
Url string `json:"url,omitempty"`
|
||||||
message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(contents, &decoded)
|
err = json.Unmarshal(contents, &decoded)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if decoded.error != 0 {
|
if decoded.Error != 0 {
|
||||||
return errors.Err("error creating thumbnail: " + decoded.message)
|
return errors.Err("error creating thumbnail: " + decoded.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue