27 lines
629 B
Go
27 lines
629 B
Go
package fixers
|
|
|
|
import "github.com/mmcdole/gofeed"
|
|
|
|
type fixerFunc func(feedItem *gofeed.Item) (string, string)
|
|
|
|
var fixers = map[string]fixerFunc{
|
|
"github.com": githubFixer,
|
|
"www.opennet.ru": opennetFixer,
|
|
}
|
|
|
|
// Fix fixes title and body depending on site parsed.
|
|
func Fix(domain string, feedItem *gofeed.Item) (string, string) {
|
|
fixer, found := fixers[domain]
|
|
if found {
|
|
return fixer(feedItem)
|
|
}
|
|
|
|
// We should check WHAT IS LONGER - description or content.
|
|
bodyData := feedItem.Description
|
|
if len(feedItem.Content) > len(feedItem.Description) {
|
|
bodyData = feedItem.Content
|
|
}
|
|
|
|
return feedItem.Title, bodyData
|
|
}
|