allow url arry
This commit is contained in:
parent
92be9919e3
commit
30340200d3
12
app/app.go
12
app/app.go
@ -68,17 +68,21 @@ func ProcessFeed(feed *FeedCfg, scheduler Scheduler, dbDir string, tgram telegra
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := Download(feed.Url, feed.Proxy)
|
var entries []parser.FeedEntry
|
||||||
|
for _, url := range feed.Url {
|
||||||
|
data, err := Download(url, feed.Proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("download failed", "feed", feed.Name, "url", feed.Url, "proxy", feed.Proxy, "error", err)
|
log.Error("download failed", "feed", feed.Name, "url", url, "proxy", feed.Proxy, "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
entries, err := parser.ParseFeed(feed.Type, data)
|
currentEntries, err := parser.ParseFeed(feed.Type, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("feed parsing failed", "feed", feed.Name, "data", data, "error", err)
|
log.Error("feed parsing failed", "feed", feed.Name, "url", url, "data", data, "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
entries = append(entries, currentEntries...)
|
||||||
|
}
|
||||||
|
|
||||||
scheduler.Good(feed.Name)
|
scheduler.Good(feed.Name)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
@ -12,11 +13,13 @@ type FeedLimit int
|
|||||||
|
|
||||||
const NoLimit FeedLimit = -1
|
const NoLimit FeedLimit = -1
|
||||||
|
|
||||||
|
type FeedURL []string
|
||||||
|
|
||||||
type FeedCfg struct {
|
type FeedCfg struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Channel string `yaml:"channel"`
|
Channel string `yaml:"channel"`
|
||||||
Rhash string `yaml:"rhash"`
|
Rhash string `yaml:"rhash"`
|
||||||
Url string `yaml:"url"`
|
Url FeedURL `yaml:"url"`
|
||||||
Cron string `yaml:"cron"`
|
Cron string `yaml:"cron"`
|
||||||
Proxy string `yaml:"proxy"`
|
Proxy string `yaml:"proxy"`
|
||||||
Type parser.FeedType `yaml:"type"`
|
Type parser.FeedType `yaml:"type"`
|
||||||
@ -105,3 +108,14 @@ func ParseConfig(configPath string) (*Config, error) {
|
|||||||
|
|
||||||
return &c, nil
|
return &c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fu *FeedURL) UnmarshalYAML(node *yaml.Node) error {
|
||||||
|
*fu = []string{""}
|
||||||
|
switch node.Kind {
|
||||||
|
case yaml.SequenceNode:
|
||||||
|
return node.Decode((*[]string)(fu))
|
||||||
|
case yaml.ScalarNode:
|
||||||
|
return node.Decode(&(*fu)[0])
|
||||||
|
}
|
||||||
|
return fmt.Errorf("unexpected node type: %s, at %d:%d", node.ShortTag(), node.Line, node.Column)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user