feat(podcast): parse podcast episode descriptions from HTML to plain text (#351)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user