hypem-resolver.js
function requestHypemKey(hypemId, callback) {
        var options = {
            method: "GET",
            url: HYPEM_TRACK_URL + hypemId,
            headers: {"Cookie": COOKIE},
            timeout: FIVE_SECONDS_IN_MILLIS
        };

        request(options, function (error, response) {
            if (!error && response.statusCode === 200) {
                var bodyLines = response.body.split('\n');
                _.forIn(bodyLines, function (bodyLine) {
                    if (bodyLine.indexOf('key') !== -1) {
                        // first hit should be the correct one
                        // fix if hypem changes that
                        try {
                            var key = JSON.parse(bodyLine.replace('</script>', '')).tracks[0].key;
                            callback(null, key);
                        } catch (error) {
                            // if an error happen here do nothing and parse
                            // the rest of the document
                        }
                    }
                });
            } else {
                callback(new Error("Nothing found: " + options.url), null);
            }
        });
    }
function requestHypemKey(hypemId, callback) {
        var options = {
            method: "GET",
            url: HYPEM_TRACK_URL + hypemId,
            headers: {"Cookie": COOKIE},
            timeout: FIVE_SECONDS_IN_MILLIS
        };

        request(options, function (error, response) {
            if (!error && response.statusCode === 200) {
                var bodyLines = response.body.split('\n');
                _.forIn(bodyLines, function (bodyLine) {
                    if (bodyLine.indexOf('key') !== -1) {
                        // first hit should be the correct one
                        // fix if hypem changes that
                        try {
                            var key = JSON.parse(bodyLine.replace('</script>', '')).tracks[0].key;
                            callback(null, key);
                        } catch (error) {
                            // if an error happen here do nothing and parse
                            // the rest of the document
                        }
                    }
                });
            } else {
                callback(new Error("Nothing found: " + options.url), null);
            }
        });
    }
function requestHypemKey ( hypemId , callback ) { var options = { method : "GET" , url : HYPEM_TRACK_URL + hypemId , headers : { "Cookie" : COOKIE } , timeout : FIVE_SECONDS_IN_MILLIS } ; request ( options , function ( error , response ) { if ( ! error && response . statusCode === 200 ) { var bodyLines = response . body . split ( '\n' ) ; _ . forIn ( bodyLines , function ( bodyLine ) { if ( bodyLine . indexOf ( 'key' ) !== - 1 ) { // first hit should be the correct one // fix if hypem changes that try { var key = JSON . parse ( bodyLine . replace ( '</script>' , '' ) ) . tracks [ 0 ] . key ; callback ( null , key ) ; } catch ( error ) { // if an error happen here do nothing and parse // the rest of the document } } } ) ; } else { callback ( new Error ( "Nothing found: " + options . url ) , null ) ; } } ) ; }
Get the key for hypem. The key is necessary to request
the hypem serve url which gives us the mp3 url. We dont
need a key if the song is hosted on soundcloud.

@private
@param {string} hypemId the id of the song
@param {Function}[callback] callback function
@param {Error} callback.err null if no error occurred
@param {string} callback.url the key to request a hypem song url
Get the key for hypem . The key is necessary to request the hypem serve url which gives us the mp3 url . We dont need a key if the song is hosted on soundcloud .