diff options
| author | siddharth ravikumar <s@ricketyspace.net> | 2026-04-01 21:02:28 -0400 |
|---|---|---|
| committer | siddharth ravikumar <s@ricketyspace.net> | 2026-04-01 21:02:28 -0400 |
| commit | f8fcf16d891f92554978778bcffbdfa6745d9366 (patch) | |
| tree | 4a4cf502a5d13c96525002a3df9363183a68fe43 | |
| parent | e513a7c567e5d8eab7cead3b6905f4106be91fba (diff) | |
schema: update YoutubeEntry
Change Link source.
| -rw-r--r-- | schema/schema.go | 20 | ||||
| -rw-r--r-- | schema/schema_test.go | 7 |
2 files changed, 17 insertions, 10 deletions
diff --git a/schema/schema.go b/schema/schema.go index 4cc79af..e2efade 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -40,21 +40,21 @@ type NPRFeed struct { Entries []NPREntry `xml:"channel>item"` } -// Represents the link a YouTube video. -type YouTubeLink struct { - XMLName xml.Name `xml:"content"` - Url string `xml:"url,attr"` +// YoutubeLink represents the link to a YouTube video. +type YoutubeLink struct { + XMLName xml.Name `xml:"link"` + Url string `xml:"href,attr"` } // Represents an entry in the YouTube feed. type YouTubeEntry struct { - XMLName xml.Name `xml:"entry"` - Id string `xml:"id"` - Title string `xml:"group>title"` - Desc string `xml:"group>description"` - Pub string `xml:"published"` // RFC3339 + XMLName xml.Name `xml:"entry"` + Id string `xml:"id"` + Title string `xml:"group>title"` + Link YoutubeLink `xml:"link"` + Desc string `xml:"group>description"` + Pub string `xml:"published"` // RFC3339 PubTime time.Time - Link YouTubeLink `xml:"group>content"` } // Represents a YouTube feed. diff --git a/schema/schema_test.go b/schema/schema_test.go index 5dc00d1..d3e095b 100644 --- a/schema/schema_test.go +++ b/schema/schema_test.go @@ -6,6 +6,7 @@ package schema import ( "encoding/xml" "net/url" + "strings" "testing" "time" @@ -110,6 +111,12 @@ func TestYoutubeFeed(t *testing.T) { t.Errorf("entry link: %v", err) return } + if !strings.HasPrefix(entry.Link.Url, "https://www.youtube.com") { + t.Errorf("entry link: %s: expected prefix '%s'", + "https://www.youtube.com/watch", + entry.Link.Url, + ) + } } } } |
