Last active
January 4, 2016 09:49
-
-
Save josephpconley/8605053 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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