feat(podcast): parse podcast episode descriptions from HTML to plain text (#351)

This commit is contained in:
brian-doherty
2023-08-14 16:14:13 -05:00
committed by GitHub
parent 09413ea06e
commit 7d2c4fbb5c
3 changed files with 22 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
package spec
import "go.senan.xyz/gonic/db"
import (
"jaytaylor.com/html2text"
"go.senan.xyz/gonic/db"
)
func NewPodcastChannel(p *db.Podcast) *PodcastChannel {
ret := &PodcastChannel{
@@ -23,13 +26,17 @@ func NewPodcastEpisode(e *db.PodcastEpisode) *PodcastEpisode {
if e == nil {
return nil
}
desc, err := html2text.FromString(e.Description, html2text.Options{TextOnly: true})
if (err != nil) {
desc = ""
}
return &PodcastEpisode{
ID: e.SID(),
StreamID: e.SID(),
ContentType: e.MIME(),
ChannelID: e.PodcastSID(),
Title: e.Title,
Description: e.Description,
Description: desc,
Status: string(e.Status),
CoverArt: e.PodcastSID(),
PublishDate: *e.PublishDate,