Rework fixers to decide what to use and move dehtmlify process in them.
Added githubv fixer.
This commit is contained in:
+7
-4
@@ -1,17 +1,20 @@
|
||||
package fixers
|
||||
|
||||
type fixerFunc func(title, body string) (string, string)
|
||||
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, title, body string) (string, string) {
|
||||
func Fix(domain string, feedItem *gofeed.Item) (string, string) {
|
||||
fixer, found := fixers[domain]
|
||||
if !found {
|
||||
return title, body
|
||||
return feedItem.Title, feedItem.Description
|
||||
}
|
||||
|
||||
return fixer(title, body)
|
||||
return fixer(feedItem)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user