 
 exports.Parser = class Parser
         constructor: (@log) ->
-                @filenamePerLine = new FilenamePerLineParser()
-                @audaciousPlaylist = new AudaciousPlaylistParser()
+                @parsers = [
+                        new FilenamePerLineParser(),
+                        new AudaciousPlaylistParser(),
+                        ]
 
         parse: (filename, callback) =>
                 @log.info "Reading song database file: '#{filename}'."
-                if _s.endsWith filename, ".txt"
-                        @filenamePerLine.parse filename, callback
-                else if _s.endsWith filename, ".audpl"
-                        @audaciousPlaylist.parse filename, callback
-                else
+                parsed = false
+                for parser in @parsers
+                        if _s.endsWith filename, parser.postfix
+                                parsed = true
+                                parser.parse filename, callback
+                                break
+                if not parsed
                         callback "Failed to recognize format for file '#{filename}'"

                                        uri: value
                                if _s.startsWith value, "file://"
                                        currentItem.filename = value.substring "file://".length
                        else if value
                                currentItem[option] = value


crypto = require "crypto"
fs = require "fs"
lazy = require "lazy"
_s = require "underscore.string"

exports.AudaciousPlaylistParser = class AudaciousPlaylistParser
        postfix: ".audpl"

        parse: (file, callback) =>
                filereader = new lazy fs.createReadStream(file)
                result = []
