Files
rsser/fixers/opennet_ru.go
T

33 lines
628 B
Go

package fixers
import (
"log/slog"
"strings"
"github.com/mmcdole/gofeed"
"github.com/prodigeris/html2text"
)
func opennetFixer(item *gofeed.Item) (string, string) {
oldBody, err := html2text.FromString(item.Description, html2text.Options{
PrettyTables: true,
})
if err != nil {
slog.Error("Failed to de-HTMLify opennet body!", "error", err.Error())
return item.Title, item.Description
}
newBody := &strings.Builder{}
for line := range strings.Lines(oldBody) {
if strings.HasPrefix(line, "Источник") {
continue
}
_, _ = newBody.WriteString(line)
}
return item.Title, newBody.String()
}