2026-08-05 12:06:46 +05:00
|
|
|
package fixers
|
|
|
|
|
|
2026-08-09 07:27:19 +05:00
|
|
|
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
|
|
|
|
|
}
|
2026-08-05 12:06:46 +05:00
|
|
|
|
|
|
|
|
newBody := &strings.Builder{}
|
|
|
|
|
|
2026-08-09 07:27:19 +05:00
|
|
|
for line := range strings.Lines(oldBody) {
|
2026-08-05 12:06:46 +05:00
|
|
|
if strings.HasPrefix(line, "Источник") {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, _ = newBody.WriteString(line)
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-09 07:27:19 +05:00
|
|
|
return item.Title, newBody.String()
|
2026-08-05 12:06:46 +05:00
|
|
|
}
|