error handling

This commit is contained in:
alexpin
2020-02-25 21:16:57 +02:00
parent 7b9b7688a1
commit 208bffb846
6 changed files with 45 additions and 13 deletions

View File

@@ -3,6 +3,7 @@ package workflows
import (
client "../client"
config "../models/config"
res "../resources"
utils "../utils"
"fmt"
"strings"
@@ -16,7 +17,11 @@ func CanUseDownloadHashtag(url string) bool {
// DownloadHashtag - Download videos marked with given hashtag
func DownloadHashtag(url string) {
uploads := client.GetHashtagUploads(url)
uploads, err := client.GetHashtagUploads(url)
if err != nil {
utils.LogErr(res.ErrorCouldNotGetUserUploads, err.Error())
return
}
uploadCount := len(uploads)
hashtag := utils.GetHashtagFromURL(url)
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, hashtag)
@@ -31,6 +36,10 @@ func DownloadHashtag(url string) {
}
func GetHashtagJson(url string) {
uploads := client.GetHashtagUploads(url)
uploads, err := client.GetHashtagUploads(url)
if err != nil {
utils.LogErr(res.ErrorCouldNotGetUserUploads, err.Error())
return
}
fmt.Printf("%s", uploads)
}

View File

@@ -36,6 +36,10 @@ func DownloadMusic(url string) {
}
func GetMusicJson(url string) {
uploads := client.GetMusicUploadsJson(url)
uploads, err := client.GetMusicUploadsJson(url)
if err != nil {
utils.LogErr(res.ErrorCouldNotGetUserUploads, err.Error())
return
}
fmt.Printf("%s", uploads)
}

View File

@@ -37,6 +37,10 @@ func DownloadUser(username string) {
}
func GetUserVideosJson(username string) {
uploads := client.GetUserUploadsJson(username)
uploads, err := client.GetUserUploadsJson(username)
if err != nil {
utils.LogErr(res.ErrorCouldNotGetUserUploads, err.Error())
return
}
fmt.Printf("%s", uploads)
}