Skip to content

Instantly share code, notes, and snippets.

@josephpconley
Last active January 4, 2016 09:49
Show Gist options
  • Save josephpconley/8605053 to your computer and use it in GitHub Desktop.
Save josephpconley/8605053 to your computer and use it in GitHub Desktop.
import controllers.RSS
import java.io.{PrintWriter, File}
import play.api._
import play.api.libs.concurrent.Akka
import play.api.mvc.{Results, RequestHeader}
import play.api.libs.concurrent.Execution.Implicits._
import scala.concurrent.duration._
import play.api.Play.current
import scalax.io.Resource
object Global extends GlobalSettings {
val feeds = Seq(NewEBookFeed.delco, NewEBookFeed.philly)
override def onStart (app: Application){
//update RSS feeds every 12 hours
Akka.system.scheduler.schedule(0 seconds, 12 hours){
Logger.info("Updating feeds")
RSS.feeds.foreach{ f =>
Logger.info("Updating feed " + f.name)
val writer: PrintWriter = new PrintWriter(new File("public/feeds/" + f.name + ".xml"))
scala.xml.XML.write(writer, f.xml, "utf-8", true, null)
writer.flush
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment