From 891a952e9b040905123dc4d89d0cd99a6eaf4a9d Mon Sep 17 00:00:00 2001 From: video-prize-ranch Date: Wed, 19 Jul 2023 23:57:00 +0000 Subject: [PATCH] Fix warnings --- api/user.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/api/user.go b/api/user.go index 2b3be47..3af2026 100644 --- a/api/user.go +++ b/api/user.go @@ -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()