Fix warnings

This commit is contained in:
video-prize-ranch 2023-07-19 23:57:00 +00:00
parent 4ea167fde0
commit 891a952e9b
No known key found for this signature in database
1 changed files with 6 additions and 11 deletions

View File

@ -3,7 +3,6 @@ package api
import (
"io"
"net/http"
"regexp"
"strings"
"sync"
"time"
@ -35,8 +34,6 @@ type Submission struct {
IsAlbum bool
}
var imgurRe = regexp.MustCompile(`https?://i?\.?imgur\.com`)
func (client *Client) FetchUser(username string) (User, error) {
cacheData, found := client.Cache.Get(username + "-user")
if found {
@ -93,7 +90,12 @@ func (client *Client) FetchSubmissions(username string, sort string, page string
defer wg.Done()
coverData := value.Get("images.#(id==\"" + value.Get("cover").String() + "\")")
cover := Media{}
cover := Media{
Id: value.Get("id").String(),
Description: value.Get("description").String(),
Type: strings.Split(value.Get("type").String(), "/")[0],
Url: strings.ReplaceAll(value.Get("link").String(), "https://i.imgur.com", ""),
}
if coverData.Exists() {
cover = Media{
Id: coverData.Get("id").String(),
@ -101,13 +103,6 @@ func (client *Client) FetchSubmissions(username string, sort string, page string
Type: strings.Split(coverData.Get("type").String(), "/")[0],
Url: strings.ReplaceAll(coverData.Get("link").String(), "https://i.imgur.com", ""),
}
} else {
cover = Media{
Id: value.Get("id").String(),
Description: value.Get("description").String(),
Type: strings.Split(value.Get("type").String(), "/")[0],
Url: strings.ReplaceAll(value.Get("link").String(), "https://i.imgur.com", ""),
}
}
id := value.Get("id").String()