Advertisement
ronkrtdev

Untitled

Apr 3rd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var credentials = {
  2.      client_id : '',
  3.      client_secret : '',
  4.      username : '',
  5.      password : ''
  6.     };
  7.     var jsonfile = require('jsonfile')
  8.     var crawlerconfig = [
  9.       '14859705', // SoundPosition
  10.       '4182848', // Rouviere
  11.       '83205644' // thecypherfunks
  12.     ]
  13.  
  14.     SC = require('soundcloud-nodejs-api-wrapper');
  15.     var sc = new SC(credentials);
  16.  
  17. // this client object will be explained more later on
  18. var client = sc.client();
  19.  
  20. client.exchange_token(function(err, result) {
  21.  
  22.   var access_token = arguments[3].access_token;
  23.  
  24.   console.log('Full API auth response was:');
  25.   console.log(arguments);
  26.  
  27.   // we need to create a new client object which will use the access token now
  28.   var clientnew = sc.client({access_token : access_token});
  29.  
  30.       // Get Users Profile comments
  31.   clientnew.get('/users/' + crawlerconfig + '/comments', {limit : 10000000}, function(err, result) {
  32.     if (err) console.error(err); // check for an error
  33.     var file = './users/' + crawlerconfig + '-profile-comments.json' // create a profile comments json file
  34.     var obj = result; // set the results to be placed into created json file
  35.     jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  36.     console.log(crawlerconfig);
  37.   });
  38.  
  39.     // Get list of users Tracks
  40.   clientnew.get('/users/14859705/tracks', {limit : 10000000}, function(err, result) {
  41.     if (err) console.error(err); // check for an error
  42.     var file = './users/14859705-tracks.json' // create a profile comments json file
  43.     var obj = result; // set the results to be placed into created json file
  44.     jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  45.   });
  46.  
  47.     // Get Comments from all Tracks found (Temp Hard Coded In)
  48. clientnew.get('/tracks/251259713/comments', {limit : 10000000}, function(err, result) {
  49.   if (err) console.error(err); // check for an error
  50.   var file = './tracks/251259713-comments.json' // create a profile comments json file
  51.   var obj = result; // set the results to be placed into created json file
  52.   jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  53. });
  54.  
  55. clientnew.get('/tracks/237179318/comments', {limit : 10000000}, function(err, result) {
  56.   if (err) console.error(err); // check for an error
  57.   var file = './tracks/237179318-comments.json' // create a profile comments json file
  58.   var obj = result; // set the results to be placed into created json file
  59.   jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  60. });
  61.  
  62. clientnew.get('/tracks/251259740/comments', {limit : 10000000}, function(err, result) {
  63.   if (err) console.error(err); // check for an error
  64.   var file = './tracks/251259740-comments.json' // create a profile comments json file
  65.   var obj = result; // set the results to be placed into created json file
  66.   jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  67. });
  68.  
  69. clientnew.get('/tracks/218685053/comments', {limit : 10000000}, function(err, result) {
  70.   if (err) console.error(err); // check for an error
  71.   var file = './tracks/218685053-comments.json' // create a profile comments json file
  72.   var obj = result; // set the results to be placed into created json file
  73.   jsonfile.writeFileSync(file, obj, {spaces: 2}) // Write the file to disk with json Spacing of 2
  74. });
  75.  
  76.   // EXAMPLE OF POSTING TO :: lets try to create a new empty playlist
  77.   //var jsonString = '{"playlist":{"title":"JommysList"}}';
  78.   //clientnew.post('/playlists', jsonString, function(err, result) {
  79.   //  if (err) console.error(err);
  80.   //  console.log(result); // should show the json object of our new playlist
  81.   //});
  82.  
  83. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement