Extract getEntriesForFeed
Create a new function to get the entries for the feed.
This commit is contained in:
parent
610fe53787
commit
9dd00d29fd
28
main.go
28
main.go
|
@ -21,18 +21,7 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := http.Get(u.String())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
log.Fatalf("Status is not 200, but %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
md := microformats.Parse(resp.Body, u)
|
||||
items := jf2.SimplifyMicroformatDataItems(md)
|
||||
items := getEntriesForFeed(u)
|
||||
|
||||
items = filterEntriesAfter(items, now.With(time.Now()).Monday())
|
||||
|
||||
|
@ -47,6 +36,21 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func getEntriesForFeed(u *url.URL) []microsub.Item {
|
||||
resp, err := http.Get(u.String())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
log.Fatalf("Status is not 200, but %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
md := microformats.Parse(resp.Body, u)
|
||||
items := jf2.SimplifyMicroformatDataItems(md)
|
||||
return items
|
||||
}
|
||||
|
||||
func filterEntriesAfter(items []microsub.Item, from time.Time) []microsub.Item {
|
||||
var result []microsub.Item
|
||||
for _, item := range items {
|
||||
|
|
Loading…
Reference in New Issue
Block a user