Skip to content

Instantly share code, notes, and snippets.

@gclaramunt
Created June 27, 2011 16:37
Show Gist options
  • Save gclaramunt/1049234 to your computer and use it in GitHub Desktop.
Save gclaramunt/1049234 to your computer and use it in GitHub Desktop.
ER to extract subsonic data
object Ingester {
/**
* [2011-06-09 20:19:59,288] INFO PlaylistInputStream - guillermo.mackinnon listening to "(1984) Ride The Lightning/07 - Creeping Death.mp3"
* [2011-06-09 20:26:35,536] INFO PlaylistInputStream - guillermo.mackinnon listening to "(1984) Ride The Lightning/08 - The Call Of Ktulu.mp3"
*/
val regxp="""\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}\] INFO PlaylistInputStream - (\S+) listening to \"(.+).mp3"""".r
val sample= """[2011-06-06 12:10:45,109] INFO PlaylistInputStream - alejandro.nieto listening to "Elephant [2003]/the white stripes - elephant - 01 - seven nation army.mp3""""
def ingest(s:String):Option[(String,String)] = {
s match {
case regxp(name,song) => Some(name,song);
case _ => None;
}
}
def main(args: Array[String]) {
//fromFile(args(0)).getLines.map(line => println (ingest(line)));
for ( line <- lines ; (usr,song) <- ingest(line) ) println (usr+","+song)
println(ingest(Console.readLine()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment