-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed_item.go
36 lines (30 loc) · 867 Bytes
/
feed_item.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package playlist
import (
"strings"
"time"
"github.com/gabe565/transsmute/internal/youtube/tmpl"
"github.com/gorilla/feeds"
"google.golang.org/api/youtube/v3"
)
type Item youtube.PlaylistItemSnippet
func (i Item) FeedItem(disableIframe bool) (*feeds.Item, error) {
published, err := time.Parse(time.RFC3339, i.PublishedAt)
if err != nil {
return nil, err
}
var description strings.Builder
if err := tmpl.DescriptionTmpl.Execute(&description, map[string]any{
"Item": i,
"DisableIframe": disableIframe,
}); err != nil {
return nil, err
}
return &feeds.Item{
Title: i.Title,
Link: &feeds.Link{Href: "https://youtube.com/watch?v=" + i.ResourceId.VideoId},
Author: &feeds.Author{Name: i.ChannelTitle},
Description: description.String(),
Id: i.ResourceId.VideoId,
Created: published,
}, nil
}