From f8fcf16d891f92554978778bcffbdfa6745d9366 Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Wed, 1 Apr 2026 21:02:28 -0400 Subject: schema: update YoutubeEntry Change Link source. --- schema/schema.go | 20 ++++++++++---------- schema/schema_test.go | 7 +++++++ 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'schema') 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, + ) + } } } } -- cgit v1.2.3