Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

11 lines (10 sloc) 0.4 kB
fs = require 'fs'
module.exports = (Mf) ->
(req, res, next) ->
res.on 'body', ->
if res.headers["content-type"] == 'audio/mpeg'
fileName = req.path.replace(/^[a-zA-Z]/, '').split('.')[0]
path = "#{process.env["HOME"]}/Downloads/soundcloud#{fileName}.mp3"
fs.writeFile path, res.body, ->
console.log "Saved #{res.body.length} bytes to #{path}"
next()
Jump to Line
Something went wrong with that request. Please try again.