<commit_before>package server

import (
	"log"
	"net/http"
	"strconv"

	"github.com/gorilla/feeds"
	scraper "github.com/mono0x/my-scraper/lib"
	"github.com/mono0x/my-scraper/lib/source/facebook"
	"github.com/mono0x/my-scraper/lib/source/fukokulifeevent"
	"github.com/mono0x/my-scraper/lib/source/googlecalendar"
	"github.com/mono0x/my-scraper/lib/source/harmonylandinfo"
	"github.com/mono0x/my-scraper/lib/source/instagram"
	"github.com/mono0x/my-scraper/lib/source/kittychaninfo"
	"github.com/mono0x/my-scraper/lib/source/prtimes"
	"github.com/mono0x/my-scraper/lib/source/purolandinfo"
	"github.com/mono0x/my-scraper/lib/source/sanrionewsrelease"
	"github.com/mono0x/my-scraper/lib/source/seibuenevent"
	"github.com/mono0x/my-scraper/lib/source/twitter"
	"github.com/mono0x/my-scraper/lib/source/valuepress"
	"github.com/mono0x/my-scraper/lib/source/yuyakekoyakenews"
)

func renderFeed(w http.ResponseWriter, feed *feeds.Feed) {
	w.Header().Set("Content-Type", "application/atom+xml")
	w.Header().Set("Cache-Control", "public, max-age=3600")
	if err := feed.WriteAtom(w); err != nil {
		log.Println(err)
		w.WriteHeader(http.StatusInternalServerError)
		return
	}
}

func sourceRenderer(source scraper.Source) func(http.ResponseWriter, *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		feed, err := source.Scrape()
		if err != nil {
			log.Printf("%+v\n", err)
			w.WriteHeader(http.StatusServiceUnavailable)
			return<commit_msg>Return not found when items is empty<commit_after>package server

import (
	"log"
	"net/http"
	"strconv"

	"github.com/gorilla/feeds"
	scraper "github.com/mono0x/my-scraper/lib"
	"github.com/mono0x/my-scraper/lib/source/facebook"
	"github.com/mono0x/my-scraper/lib/source/fukokulifeevent"
	"github.com/mono0x/my-scraper/lib/source/googlecalendar"
	"github.com/mono0x/my-scraper/lib/source/harmonylandinfo"
	"github.com/mono0x/my-scraper/lib/source/instagram"
	"github.com/mono0x/my-scraper/lib/source/kittychaninfo"
	"github.com/mono0x/my-scraper/lib/source/prtimes"
	"github.com/mono0x/my-scraper/lib/source/purolandinfo"
	"github.com/mono0x/my-scraper/lib/source/sanrionewsrelease"
	"github.com/mono0x/my-scraper/lib/source/seibuenevent"
	"github.com/mono0x/my-scraper/lib/source/twitter"
	"github.com/mono0x/my-scraper/lib/source/valuepress"
	"github.com/mono0x/my-scraper/lib/source/yuyakekoyakenews"
)

func renderFeed(w http.ResponseWriter, feed *feeds.Feed) {
	w.Header().Set("Content-Type", "application/atom+xml")
	w.Header().Set("Cache-Control", "public, max-age=3600")
	if err := feed.WriteAtom(w); err != nil {
		log.Println(err)
		w.WriteHeader(http.StatusInternalServerError)
		return
	}
}

func sourceRenderer(source scraper.Source) func(http.ResponseWriter, *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		feed, err := source.Scrape()
		if err != nil {
			log.Printf("%+v\n", err)
			w.WriteHeader(http.StatusServiceUnavailable)
			return
		}
		if len(feed.Items) == 0 {
			w.WriteHeader(http.StatusNotFound)
			return
{'fraction_non_alphanumeric': 0.15876698707325157, 'fraction_numerical': 0.012263838249917136, 'mean_word_length': 4.89453125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '727674', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1268, 'n_words': 130}