tiktok-dl/models/upload.go
Pijus Kamandulis 69574dcb7e Initial commit
2020-01-19 04:11:53 +02:00

26 lines
485 B
Go

package models
import (
"encoding/json"
"strings"
)
// Upload - Upload object
type Upload struct {
ShareLink string `json:"shareLink"`
URL string `json:"url"`
}
// ParseUploads - Parses json uploads array
func ParseUploads(str string) []Upload {
var uploads []Upload
json.Unmarshal([]byte(str), &uploads)
return uploads
}
// GetUploadID - Returns upload id
func (u Upload) GetUploadID() string {
parts := strings.Split(u.ShareLink, "/")
return parts[len(parts)-1]
}