diff options
author | siddharth <s@ricketyspace.net> | 2021-11-27 18:58:33 -0500 |
---|---|---|
committer | siddharth <s@ricketyspace.net> | 2021-11-27 18:58:33 -0500 |
commit | 3047b9266833f61ad112fefc9169efd199daaa54 (patch) | |
tree | 34dae41b1eb9bdc752d954cdf02e7204aefa0c0e | |
parent | a3703d923b5516da967164c41f49aa9e2f8a57d7 (diff) |
feed: add youtubeUnmarshal
Unmarshler for a YouTube Feed.
-rw-r--r-- | feed/feed.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/feed/feed.go b/feed/feed.go index b20a281..3f82096 100644 --- a/feed/feed.go +++ b/feed/feed.go @@ -105,3 +105,20 @@ func nprUnmarshal(bs []byte) (schema.NPRFeed, error) { return *nprFeed, nil } +// Unmarshal a YouTube feed. +func youtubeUnmarshal(bs []byte) (schema.YouTubeFeed, error) { + ytFeed := new(schema.YouTubeFeed) + err := xml.Unmarshal(bs, ytFeed) + if err != nil { + return *ytFeed, err + } + + // Parse time for all entries. + for i, entry := range ytFeed.Entries { + ytFeed.Entries[i].PubTime, err = time.Parse(time.RFC3339, entry.Pub) + if err != nil { + return *ytFeed, err + } + } + return *ytFeed, nil +} |