-
Notifications
You must be signed in to change notification settings - Fork 1
/
adapter_config.go
52 lines (38 loc) · 1.03 KB
/
adapter_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package articler
import (
"gopkg.in/yaml.v2"
"net/url"
"time"
)
type AdapterConfig struct {
Host string `yaml:"host,omitempty"`
Scheme string
Name string
FeedUri string
FeedType string //html or rss
FeedUriGenerate FeedUriGenerateFunc
FeedExtract FeedExtractFunc
//FeedType must be html
//this is link's selector, like "main a"
FeedSelector string
ArticleUriRegex string
ParseFunc ExtractArticleFunc
TitleSelector string
TitleExtractFunc ExtractFunc
BodySelector string
BodyExtractFunc ExtractFunc
DateSelector string
DateFormat string
DateRegex string
DateExtractFunc ExtractTimeFunc
}
func ParseAdapterConfig(in []byte) (*AdapterConfig, error) {
ac := &AdapterConfig{}
err := yaml.Unmarshal(in, &ac)
return ac, err
}
type ExtractFunc func([]byte) ([]byte, error)
type ExtractTimeFunc func([]byte) (time.Time, error)
type ExtractArticleFunc func([]byte) (*Article, error)
type FeedUriGenerateFunc func() *url.URL
type FeedExtractFunc func([]byte) ([]*url.URL, error)