예제 #1
0
func fetch_entries(feds []meta.Feed, done chan<- int) {
	fmt.Println("fetch entries", len(feds))
	curl := d.DefaultCurl()
	for _, feed := range feds {
		rsfile, _, _, err := curl.Download(feed.Link)
		fmt.Println(rsfile, err)
		if err != nil {
			fmt.Println(err)
			continue
		}
		f, entries, err := feeds.NewFeed(rsfile, feed.Link)
		if err != nil {
			fmt.Println(feed.Link, len(entries), err)
			feeds.NewFeedOperator().Disable(feed.Link, true)
		} else {
			fmt.Println(f.Title, len(entries))
		}

		if err == nil {
			ins, _ := feeds.NewEntryOperator().Save2(entries)
			fmt.Println(len(ins), feed.Link)
		}

	}
	done <- 0
}
예제 #2
0
func main() {
	flag.Parse()
	if *uri == "" {
		fmt.Println("opml-parser --uri http://diggreader/opml.xml")
	}
	tf, _, _, _ := d.DefaultCurl().Download(*uri)
	ols, _ := opml.NewOpml(tf)
	feeds.NewFeedOperator().Save(ols)
	fmt.Println(ols)
}
예제 #3
0
func main() {
	defer catch_panic()
	flag.Parse()
	if len(*uri) == 0 {
		panic(errors.New("usage: subscribe --uri http://xome.rss2.xml"))
	}
	rsfile, _, _, _ := d.DefaultCurl().Download(*uri) //document.FetchUrl2(*uri)
	log.Println(rsfile)
	ch, _, _ := feeds.NewFeed(rsfile, *uri)
	log.Println(ch)
	feeds.NewFeedOperator().Upsert(ch)
}
예제 #4
0
func main() {
	fds, _ := feeds.NewFeedOperator().AllFeeds()
	capl := (len(fds) + cocurrents - 1) / cocurrents
	if capl == 0 {
		return
	}
	cnt := (len(fds) + capl - 1) / capl
	done := make(chan int, cnt)
	split_task(fds, capl, done)
	for cnt > 0 {
		<-done
		cnt--
	}
}
예제 #5
0
func main() {
	c, items, _ := feeds.NewFeed(rssfile, base_url)
	fmt.Println(c)
	for _, item := range items {
		fmt.Println(item.Title)
	}
	fo := feeds.NewFeedOperator()
	fo.Upsert(c)
	x, _ := fo.Find("http://fulltextrssfeed.com/www.infzm.com/rss/home/rss2.0.xml")
	fmt.Println(x)

	eo := feeds.NewEntryOperator()
	eo.Save(items)
	//	feeds.InsertChannel(c)
	//	test_db(items)
}
예제 #6
0
func subscribe_rss2(w http.ResponseWriter, r *http.Request) {
	defer func() {
		if err := recover(); err != nil {
			http.Error(w, err.(error).Error(), http.StatusBadGateway)
			fmt.Println(err)
		}
	}()

	r.ParseForm()
	url := r.FormValue("url")
	fmt.Println("fetching ", url)
	rss_file, _, _, _ := htmldoc.DefaultCurl().Download(url)
	fmt.Println("rss-file", rss_file)
	channel, _, _ := feeds.NewFeed(rss_file, url)
	feeds.NewFeedOperator().Upsert(channel)

	write_json(w, channel)
}