This commit is contained in:
video-prize-ranch
2022-01-18 18:05:06 -05:00
parent 87c8618cf5
commit 4a1309e0dc
13 changed files with 251 additions and 19 deletions

View File

@@ -4,9 +4,9 @@ import (
"io"
"net/http"
"strings"
"time"
"codeberg.org/video-prize-ranch/rimgo/types"
"codeberg.org/video-prize-ranch/rimgo/utils"
"github.com/spf13/viper"
"github.com/tidwall/gjson"
)
@@ -35,8 +35,8 @@ func FetchAlbum(albumID string) (types.Album, error) {
media = append(media, types.Media{
Id: value.Get("id").String(),
Name: value.Get("name").String(),
MimeType: value.Get("mime_type").String(),
Type: value.Get("type").String(),
MimeType: value.Get("mime_type").String(),
Type: value.Get("type").String(),
Title: value.Get("metadata.title").String(),
Description: value.Get("metadata.description").String(),
Url: url,
@@ -46,7 +46,7 @@ func FetchAlbum(albumID string) (types.Album, error) {
},
)
createdAt, err := time.Parse("2006-01-02T15:04:05Z", data.Get("created_at").String())
createdAt, err := utils.FormatDate(data.Get("created_at").String())
if err != nil {
return types.Album{}, err
}
@@ -55,7 +55,10 @@ func FetchAlbum(albumID string) (types.Album, error) {
Id: data.Get("id").String(),
Title: data.Get("title").String(),
Views: data.Get("view_count").Int(),
CreatedAt: createdAt.Format("January 2, 2006 3:04 PM"),
Upvotes: data.Get("upvote_count").Int(),
Downvotes: data.Get("downvote_count").Int(),
Comments: data.Get("comment_count").Int(),
CreatedAt: createdAt,
Media: media,
}, nil
}