code cleanup
This commit is contained in:
parent
917be1687f
commit
5336968e05
34 changed files with 193 additions and 115 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"govd/util"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -125,7 +126,7 @@ func GetPostData(postID string) (*Post, error) {
|
|||
}
|
||||
|
||||
if response.Data == nil || response.Data.Post == nil {
|
||||
return nil, fmt.Errorf("no post data found")
|
||||
return nil, errors.New("no post data found")
|
||||
}
|
||||
|
||||
return response.Data.Post, nil
|
||||
|
|
|
@ -25,17 +25,13 @@ type Media struct {
|
|||
}
|
||||
|
||||
type Post struct {
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
Nsfw int `json:"nsfw"`
|
||||
CreationTs int `json:"creationTs"`
|
||||
GamFlagged bool `json:"gamFlagged"`
|
||||
IsVoteMasked int `json:"isVoteMasked"`
|
||||
HasLongPostCover int `json:"hasLongPostCover"`
|
||||
Images map[string]*Media `json:"images"`
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Type string `json:"type"`
|
||||
Nsfw int `json:"nsfw"`
|
||||
Images map[string]*Media `json:"images"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
|
||||
"govd/enums"
|
||||
"govd/models"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func FindBestPhoto(
|
||||
|
@ -25,7 +27,7 @@ func FindBestPhoto(
|
|||
}
|
||||
|
||||
if bestPhoto == nil {
|
||||
return nil, fmt.Errorf("no photo found in post")
|
||||
return nil, errors.New("no photo found in post")
|
||||
}
|
||||
|
||||
return bestPhoto, nil
|
||||
|
@ -47,7 +49,7 @@ func ParseVideoFormats(
|
|||
}
|
||||
}
|
||||
if video == nil {
|
||||
return nil, fmt.Errorf("no video found in post")
|
||||
return nil, errors.New("no video found in post")
|
||||
}
|
||||
|
||||
codecMapping := map[string]struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue