addet sorting

This commit is contained in:
pika 2025-01-02 15:19:55 +01:00
parent 20ab5804c6
commit 27a221318e
4 changed files with 249 additions and 28 deletions

View file

@ -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)
}