small pixel drawing of a pufferfish vore

remove custom reaper func
Jes Olson j3s@c3f.net
Sat, 25 Mar 2023 14:03:33 -0700
commit

8c1eec122b2371f80db8bc8f7188019ece60833b

parent

9a99f5d72ee0e17d1f316369233e49827cd9a4bd

1 files changed, 2 insertions(+), 38 deletions(-)

jump to
M reaper/reaper.goreaper/reaper.go

@@ -2,10 +2,7 @@ package reaper

import ( "fmt" - "io" - "net/http" "sort" - "strings" "sync" "time"

@@ -91,7 +88,7 @@

// updateFeed triggers a fetch on the given feed, // and sets a fetch error in the db if there is one. func (r *Reaper) refreshFeed(f *rss.Feed) { - err := f.UpdateByFunc(reaperFetchFunc) + err := f.Update() if err != nil { fmt.Printf("[err] reaper: fetch failure '%s': %s\n", f.UpdateURL, err) r.db.SetFeedFetchError(f.UpdateURL, err.Error())

@@ -145,43 +142,10 @@ })

return posts } -var reaperFetchFunc = func(url string) (*http.Response, error) { - client := http.DefaultClient - resp, err := client.Get(url) - if err != nil { - return nil, err - } - bodyBytes, err := io.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - // escape un-parseable HTML elements - body := string(bodyBytes) - body = strings.ReplaceAll(body, "–", "") - // body = strings.ReplaceAll(body, "&&", "–") - - // body = strings.ReplaceAll(body, "®", "") - // fmt.Println(b.String()) - // if err != nil { - // return nil, err - // } - // body := html.UnescapeString(string(bodyBytes)) - - // re-encode as XML - // err = xml.EscapeText(&b, []byte(body)) - - // overwrite the body - resp.Body.Close() - resp.Body = io.NopCloser(strings.NewReader(body)) - - return resp, nil -} - // FetchFeed attempts to fetch a feed from a given url, marshal // it into a feed object, and add it to Reaper. func (r *Reaper) Fetch(url string) error { - feed, err := rss.FetchByFunc(reaperFetchFunc, url) + feed, err := rss.Fetch(url) if err != nil { return err }