soundcloudnodejs.js
function resolveUri(options) {
    return new Promise(function (resolve, reject) {
        if (!options.client_id) {
            reject(new Error('Error resolveUri options.client_id is required but is null'));
        } else {

            if (!options.uri) {
                throw new Error('Error resolveUri options.uri is required and is: ' + options.uri);
            } else {
                var uri = 'http://api.soundcloud.com/resolve.json?url=' + options.uri + '&client_id=' + options.client_id;
                request.getAsync(uri, {timeout: 10000}).spread(function (response) {

                    if (!response.body || response.body.indexOf('404') !== -1) {
                        if (DEBUG_MODE_ON) {
                            console.log('Error while resolveUri track: ');
                        }
                        reject(new Error('Error while resolveUri track: '));

                    } else {
                        if (DEBUG_MODE_ON) {
                            console.log('resolveUri successful');
                        }
                        try {
                            resolve(JSON.parse(response.body.toString('utf8')));
                        } catch (e) {
                            if (DEBUG_MODE_ON) {
                                console.log('Error while resolveUri track: ' + e);
                            }
                            reject(new Error('Error while resolveUri track: ' + e));
                        }

                    }
                }).catch(function (e) {
                    if (DEBUG_MODE_ON) {
                        console.log('Error while resolveUri track: ', e);
                    }
                    reject(e);
                });
            }
        }
    });
}
function resolveUri(options) {
    return new Promise(function (resolve, reject) {
        if (!options.client_id) {
            reject(new Error('Error resolveUri options.client_id is required but is null'));
        } else {

            if (!options.uri) {
                throw new Error('Error resolveUri options.uri is required and is: ' + options.uri);
            } else {
                var uri = 'http://api.soundcloud.com/resolve.json?url=' + options.uri + '&client_id=' + options.client_id;
                request.getAsync(uri, {timeout: 10000}).spread(function (response) {

                    if (!response.body || response.body.indexOf('404') !== -1) {
                        if (DEBUG_MODE_ON) {
                            console.log('Error while resolveUri track: ');
                        }
                        reject(new Error('Error while resolveUri track: '));

                    } else {
                        if (DEBUG_MODE_ON) {
                            console.log('resolveUri successful');
                        }
                        try {
                            resolve(JSON.parse(response.body.toString('utf8')));
                        } catch (e) {
                            if (DEBUG_MODE_ON) {
                                console.log('Error while resolveUri track: ' + e);
                            }
                            reject(new Error('Error while resolveUri track: ' + e));
                        }

                    }
                }).catch(function (e) {
                    if (DEBUG_MODE_ON) {
                        console.log('Error while resolveUri track: ', e);
                    }
                    reject(e);
                });
            }
        }
    });
}
function resolveUri ( options ) { return new Promise ( function ( resolve , reject ) { if ( ! options . client_id ) { reject ( new Error ( 'Error resolveUri options.client_id is required but is null' ) ) ; } else { if ( ! options . uri ) { throw new Error ( 'Error resolveUri options.uri is required and is: ' + options . uri ) ; } else { var uri = 'http://api.soundcloud.com/resolve.json?url=' + options . uri + '&client_id=' + options . client_id ; request . getAsync ( uri , { timeout : 10000 } ) . spread ( function ( response ) { if ( ! response . body || response . body . indexOf ( '404' ) !== - 1 ) { if ( DEBUG_MODE_ON ) { console . log ( 'Error while resolveUri track: ' ) ; } reject ( new Error ( 'Error while resolveUri track: ' ) ) ; } else { if ( DEBUG_MODE_ON ) { console . log ( 'resolveUri successful' ) ; } try { resolve ( JSON . parse ( response . body . toString ( 'utf8' ) ) ) ; } catch ( e ) { if ( DEBUG_MODE_ON ) { console . log ( 'Error while resolveUri track: ' + e ) ; } reject ( new Error ( 'Error while resolveUri track: ' + e ) ) ; } } } ) . catch ( function ( e ) { if ( DEBUG_MODE_ON ) { console . log ( 'Error while resolveUri track: ' , e ) ; } reject ( e ) ; } ) ; } } } ) ; }
Resolve a URI
@param options
@returns {bluebird|exports|module.exports}
Resolve a URI