Skip to content

Commit

Permalink
feat(youtube): Set feed created and updated dates
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jul 11, 2024
1 parent 0ad3f4f commit cbba513
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/youtube/playlist/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/url"
"slices"
"time"

"github.com/gorilla/feeds"
"google.golang.org/api/youtube/v3"
Expand Down Expand Up @@ -49,6 +50,11 @@ func (p Playlist) Feed(ctx context.Context) (*feeds.Feed, error) {
return nil, err
}

created, err := time.Parse(time.RFC3339, meta.PublishedAt)
if err != nil {
return nil, err
}

u := url.URL{
Scheme: "https",
Host: "youtube.com",
Expand All @@ -63,13 +69,18 @@ func (p Playlist) Feed(ctx context.Context) (*feeds.Feed, error) {
Author: &feeds.Author{
Name: meta.ChannelTitle,
},
Created: created,
}

feed.Items, err = p.FeedItems(ctx)
if err != nil {
return feed, err
}

if len(feed.Items) != 0 {
feed.Updated = feed.Items[0].Created
}

return feed, nil
}

Expand Down

0 comments on commit cbba513

Please sign in to comment.