Created
June 27, 2011 16:37
-
-
Save gclaramunt/1049234 to your computer and use it in GitHub Desktop.
ER to extract subsonic data
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
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