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

@@ -7,13 +7,20 @@ import (
)
// GetUserUploads - Get all uploads marked with given hashtag
func GetHashtagUploads(hashtagURL string) []models.Upload {
func GetHashtagUploads(hashtagURL string) ([]models.Upload, error) {
jsMethod := fmt.Sprintf("bootstrapIteratingVideos(%d)", config.Config.Limit)
actionOutput := executeClientAction(hashtagURL, jsMethod)
return models.ParseUploads(actionOutput)
actionOutput, err := executeClientAction(hashtagURL, jsMethod)
if err != nil {
return nil, err
}
return models.ParseUploads(actionOutput), nil
}
func GetHashtagUploadsJson(hashtagURL string) string {
func GetHashtagUploadsJson(hashtagURL string) (string, error) {
jsMethod := fmt.Sprintf("bootstrapIteratingVideos(%d)", config.Config.Limit)
return executeClientAction(hashtagURL, jsMethod)
actionOutput, err := executeClientAction(hashtagURL, jsMethod)
if err != nil {
return "", err
}
return actionOutput, nil
}

View File

@@ -16,7 +16,11 @@ func GetMusicUploads(url string) ([]models.Upload, error) {
return models.ParseUploads(actionOutput), nil
}
func GetMusicUploadsJson(url string) string {
func GetMusicUploadsJson(url string) (string, error) {
jsMethod := fmt.Sprintf("bootstrapIteratingVideos(%d)", config.Config.Limit)
return executeClientAction(url, jsMethod)
actionOutput, err := executeClientAction(url, jsMethod)
if err != nil {
return "", err
}
return actionOutput, nil
}

View File

@@ -16,7 +16,11 @@ func GetUserUploads(username string) ([]models.Upload, error) {
return models.ParseUploads(actionOutput), nil
}
func GetUserUploadsJson(username string) string {
func GetUserUploadsJson(username string) (string, error) {
jsMethod := fmt.Sprintf("bootstrapIteratingVideos(%d)", config.Config.Limit)
return executeClientAction(`https://www.tiktok.com/@`+username, jsMethod)
actionOutput, err := executeClientAction(`https://www.tiktok.com/@`+username, jsMethod)
if err != nil {
return "", err
}
return actionOutput, nil
}