small pixel drawing of a pufferfish j3s.sh

feed/feed.go

package feed

import (
	"log"

	"github.com/SlyMarbo/rss"
)

type feeds struct {
	FriendFeeds  []string
	CompanyFeeds []string
	RandomFeeds  []string
}

func GetFeeds() feeds {
	f := feeds{}
	f.FriendFeeds = []string{
		"https://begriffs.com/atom.xml",
		"https://davebucklin.com/feed.xml",
		"https://www.bitquabit.com/index.xml",
		"https://blog.jse.li/index.xml",
		"https://spencerkrum.com/index.xml",
		"https://www.ryanprior.com/posts/index.xml",
		"https://kattraxler.github.io/feed.xml",
		"https://coderanger.net/atom.xml",
		"https://www.namecoin.org/feed.rss",
		"https://sanine.net/rss.xml",
		"https://sequentialread.com/rss",
	}
	f.CompanyFeeds = []string{
		"https://cyberia.club/blog/blog.xml",
		"https://blog.tildes.net/all.atom.xml",
		"https://matrix.org/blog/feed",
		"https://puri.sm/feed",
		"https://sourcehut.org/blog/index.xml",
		"https://frame.work/blog.rss",
	}
	f.RandomFeeds = []string{
		"https://georgerrmartin.com/notablog/feed",
		"https://100r.co/links/rss.xml",
		"https://emersion.fr/blog/rss.xml",
		"https://linuxwit.ch/feed.xml",
		"https://andrewkelley.me/rss.xml",
		"http://antirez.com/rss",
		"https://drewdevault.com/feed.xml",
		"https://emilydamstra.com/feed",
	}
	return f
}

func FetchFriendFeeds() []rss.Feed {
	feeds := GetFeeds()

	var friendFeeds []rss.Feed
	for i, feed := range feeds.FriendFeeds {
		f, err := rss.Fetch(feed)
		if err != nil {
			log.Printf(err.Error())
			continue
		}

		fe := *f
		friendFeeds = append(friendFeeds, fe)
		// todo: make a sort func for []rss.Feed
		log.Printf(string(i))
	}
	return friendFeeds
}