--- /dev/null
+Setup
+=====
+
+1. You'll need to save your auth credentials to ~/.libre.fm-cmus.auth:
+
+ unset HISTFILE
+ coffee -e "require('./auth.coffee').save_auth 'USERNAME','PASSWORD'"
+
+ (Substituting your libre.fm username and password of course.) The first
+ line disables history saving in bash, and perhaps other shells.
--- /dev/null
+fs = require 'fs'
+crypto = require 'crypto'
+
+md5 = (str) ->
+ sum = crypto.createHash 'md5'
+ sum.update str
+ return sum.digest 'hex'
+
+new_auth_token = (user, pass) -> md5(user + md5(pass))
+
+save_auth = (user, pass, callback) ->
+ token = new_auth_token(user, pass)
+ text = JSON.stringify user: user, token: new_auth_token(user, pass)
+ fs.writeFile "#{process.env.HOME}/.libre.fm-cmus.auth", text, 'utf8', callback
+ return token
+
+exports.new_auth_token = new_auth_token
+exports.save_auth = save_auth