consolidate external text trimming

This commit is contained in:
sentriz
2023-12-10 18:44:59 +00:00
parent e31e37e366
commit a8333b8afa
4 changed files with 21 additions and 33 deletions

View File

@@ -2,19 +2,14 @@ package spec
import (
"go.senan.xyz/gonic/db"
"jaytaylor.com/html2text"
)
func NewPodcastChannel(p *db.Podcast) *PodcastChannel {
desc, err := html2text.FromString(p.Description, html2text.Options{TextOnly: true})
if err != nil {
desc = ""
}
ret := &PodcastChannel{
ID: p.SID(),
OriginalImageURL: p.ImageURL,
Title: p.Title,
Description: desc,
Description: CleanExternalText(p.Description),
URL: p.URL,
CoverArt: p.SID(),
Status: "skipped",
@@ -30,17 +25,13 @@ func NewPodcastEpisode(pe *db.PodcastEpisode) *PodcastEpisode {
if pe == nil {
return nil
}
desc, err := html2text.FromString(pe.Description, html2text.Options{TextOnly: true})
if err != nil {
desc = ""
}
r := &PodcastEpisode{
ID: pe.SID(),
StreamID: pe.SID(),
ContentType: pe.MIME(),
ChannelID: pe.PodcastSID(),
Title: pe.Title,
Description: desc,
Description: CleanExternalText(pe.Description),
Status: string(pe.Status),
CoverArt: pe.PodcastSID(),
PublishDate: *pe.PublishDate,