addet sorting
This commit is contained in:
parent
20ab5804c6
commit
27a221318e
4 changed files with 249 additions and 28 deletions
|
@ -23,6 +23,7 @@ type Video struct {
|
|||
Views string
|
||||
Thumbnail string
|
||||
UploadDate string
|
||||
ParsedDate time.Time
|
||||
}
|
||||
|
||||
func formatViews(count uint64) string {
|
||||
|
@ -145,6 +146,13 @@ func FetchVideos(query string) ([]Video, error) {
|
|||
Thumbnail: item.Snippet.Thumbnails.Default.Url,
|
||||
UploadDate: item.Snippet.PublishedAt,
|
||||
}
|
||||
|
||||
// Parse the upload date and store it
|
||||
parsedDate, err := time.Parse(time.RFC3339, video.UploadDate)
|
||||
if err == nil {
|
||||
video.ParsedDate = parsedDate
|
||||
}
|
||||
|
||||
videos = append(videos, video)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue