Exemplo n.º 1
0
func main() {
	startTime := time.Now()
	helper.LogInfo("start")
	allgames := make([]*interfaces.Game, 0)
	seasonRaw := interfaces.DownloadHTMLData("http://www.kickern-hamburg.de/liga-tool/mannschaftswettbewerbe")
	seasonDoc := interfaces.GenerateDocument(seasonRaw)
	seasonIds := interfaces.FindSeasons(seasonDoc)
	for _, seasonId := range seasonIds {
		helper.LogInfo("seasonid :" + seasonId)
		seasonRaw := interfaces.DownloadSeason(seasonId)
		seasonDoc := interfaces.GenerateDocument(seasonRaw)
		ligaLinks := interfaces.FindLigaLinks(seasonDoc)
		for _, ligaLink := range ligaLinks {
			helper.LogInfo("ligaLink: " + ligaLink)
			matchesRaw := interfaces.DownloadHTMLData(ligaLink)
			matchesDoc := interfaces.GenerateDocument(matchesRaw)
			matchLinks := interfaces.FindMatchLinks(matchesDoc)
			for _, matchLink := range matchLinks {
				helper.LogInfo("matchLink: " + matchLink)
				gamesRaw := interfaces.DownloadHTMLData(matchLink)
				gamesDoc := interfaces.GenerateDocument(gamesRaw)
				games := interfaces.ParseGames(gamesDoc)
				allgames = append(allgames, games...)
			}
		}
	}

	interfaces.StoreGamesInCSVFile("allGames.csv", allgames)
	duration := time.Since(startTime)
	helper.LogInfo("duration: " + duration.String())
}
Exemplo n.º 2
0
func (this *Config) Log() {
	helper.LogInfo("config for updateinterval: " + strconv.Itoa(this.Updateinterval))
	helper.LogInfo("config for listen port: " + strconv.Itoa(this.ListenPort))
	helper.LogInfo("config for listen path: " + this.ListenPath)
	helper.LogInfo("config for dbhost: " + this.Dbhost)
	helper.LogInfo("config for dbname: " + this.Dbname)
	helper.LogInfo("config for dbport: " + this.Dbport)
	helper.LogInfo("config for forum user: " + this.ForumUser)
}
Exemplo n.º 3
0
func main() {
	config := interfaces.CreateNewConfigurator().LoadConfig()
	newsRepo := domain.CreateCouchDbRepo(config.Dbhost, config.Dbport, config.Dbname, config.Dbuser, config.Dbpassword)
	interactor := usecases.CreateNewMessageInteractor(newsRepo)
	forumReader := interfaces.CreateNewForumReader(config.ForumUser, config.ForumPasswd)
	parser := interfaces.CreateNewParser()
	feedUpdaterBatch := interfaces.CreateNewFeedUpdater(config.Updateinterval, interactor, forumReader, parser)
	feedBuilder := interfaces.CreateNewFeedBuilder(config.Updateinterval)
	webservice := interfaces.CreateNewWebservice(interactor, feedBuilder, config.ListenPort, config.ListenPath)

	config.Log()
	feedUpdaterBatch.Start()
	helper.LogInfo("--> feed update batch started.")
	webservice.Start()
	helper.LogInfo("--> rssfeed online.")

	shutdownChannel := make(chan os.Signal)
	signal.Notify(shutdownChannel, syscall.SIGINT, syscall.SIGTERM)

	<-shutdownChannel

	helper.LogInfo("--> shutting down feed.")
	webservice.Stop()
	helper.LogInfo("--> stopping webservice.")
	feedUpdaterBatch.Stop()
	helper.LogInfo("--> stopping update batch.")
	helper.LogInfo("--> rssfeed stopped.")
}