Created
April 21, 2015 11:03
-
-
Save zaltoprofen/c063e24b286d36894b15 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 twitter4j._ | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object Main{ | |
def open(url: String): Unit = { | |
import scala.sys.process.Process | |
Future { Process("open", Seq(url)).! } | |
} | |
def main(args: Array[String]): Unit = { | |
val t = new TwitterStreamFactory().getInstance | |
t.addListener(new UserStreamAdapter { | |
override def onStatus(status: Status): Unit = { | |
val urls = status.getMediaEntities().collect { case e:MediaEntity if e.getType == "photo" => e.getMediaURL } | |
val eurls = status.getExtendedMediaEntities().collect { case e:ExtendedMediaEntity if e.getType == "photo" => e.getMediaURL } | |
(urls ++ eurls).distinct.foreach(open) | |
} | |
}) | |
val q = new FilterQuery().track(Array[String]("寿司", "ラーメン")) | |
t.filter(q) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment