Esempio n. 1
0
SoundCloudSearcher.prototype._init = function() {
  SoundCloud.init({
    id: Constants.API.SOUND_CLOUD_API_CLIENT_ID,
    secret: Constants.API.SOUND_CLOUD_API_CLIENT_SECRET,
    uri: ''
  });
};
Esempio n. 2
0
 module.initialize = function() {
   SC.init({
     id: config.clientId,
     secret: config.clientSecret,
     uri: config.redirectUri,
   });
 };
    // --- Initialization
    constructor(clientId, clientSecret, redirectUri) {
        this._handleUserUpdateComplete = function(){};

        SC.init({
            id: clientId,
            secret: clientSecret,
            uri: redirectUri
        });
    }
Esempio n. 4
0
 var initSC = new Promise(function(resolve, reject){
     if(!soundcloudAccessToken){
         console.log("no access token");
         SC.init({
                 id: SOUNDCLOUD_CLIENT_ID,
                 secret: SOUNDCLOUD_CLIENT_SECRET,
                 uri: SOUNDCLOUD_URI,
                 scope: SOUNDCLOUD_SCOPE
         })
     } else {
         console.log("access token available");
         SC.init({
                 id: SOUNDCLOUD_CLIENT_ID,
                 secret: SOUNDCLOUD_CLIENT_SECRET,
                 uri: SOUNDCLOUD_URI,
                 accessToken: soundcloudAccessToken,
                 scope: SOUNDCLOUD_SCOPE
         })
     }
     resolve();
 });
Esempio n. 5
0
router.get('/', (req, res, next) => {
	SC.init({
		id: 'your SoundCloud client ID',
		secret: 'your SoundCloud client secret',
		uri: 'your SoundCloud redirect URI',
		accessToken: 'your existing access token'
	});
	initOAuth(res, res);
	// SC.get('/tracks/276882056', function(err, track) {
	// 	if ( err ) {
	// 		throw err;
	// 	} else {
	// 		console.log('track retrieved:', track);
	// 	}
	// });
});
Esempio n. 6
0
function SoundCloudSearcher(config) {
  config = config || {};
  var clientId = config.clientId;
  var clientSecret = config.clientSecret;

  if (!clientId || !clientSecret) {
    throw new Error('no passed clientId or clientSecret');
  }

  this._clientId = clientId;
  this._clientSecret = clientSecret;

  // this library is designed to be used as singleton
  SoundCloud.init({
    id: this._clientId,
    secret: this._clientSecret,
    uri: ''
  });
}
Esempio n. 7
0
    request = require('request')

//connect to db
mongoose.connect('mongodb://soundseeker:sound1@ds059524.mongolab.com:59524/soundseeker', function(err){
  if(err) return console.log('Cannot connect :(')
  console.log('Connected to MongoDB!')
})

// ejs configuration
app.set('view engine', 'ejs')
app.use(ejsLayouts)

//init soundcloud client
SC.init({
  id: '7ce0c4a7238f05f3fada1cdcff5b489c',
  secret: 'a2039f8373bab2514ae7e6f796e95033',
  uri: 'http://localhost:3000/',
  accessToken: 'https://api.soundcloud.com/oauth2/token'
})

// middleware
app.use(logger('dev'))
app.use(cookieParser())
app.use(bodyParser.urlencoded({extended: true}))
app.use(bodyParser.json())

app.use(session({
  secret: "boomchakalaka",
  cookie:{_expires : 60000000}
}))

app.use(passport.initialize())
Esempio n. 8
0
// soundcloud.js
// require soundcloud package on server side
const SC = require('node-soundcloud');
const config = require('../config/config.js');

const headers = {
  'access-control-allow-origin': '*',
  'access-control-allow-methods': 'GET, POST, PUT, DELETE, OPTIONS',
  'access-control-allow-headers': 'content-type, accept',
  'access-control-max-age': 10, // Seconds.
};

// initialize soundcloud api
SC.init({
  id: config.SCId,
});


// I set up the data inside the server for now
// so we can check the input keyword from the client side
// in our server url: /server
let data = {};
module.exports.get = (req, res) => {
  data = req.body;
  SC.get('/tracks', {
    q: req.body.keyword,
    limit: 50,
    streamable: true,
  }, (error, tracks) => {
    if (error) {
      console.log(error);
Esempio n. 9
0
//Readline for taking user input
const readline = require('readline');

//SoundCirrus client_id so I don't have to type it
var client_id = '4121ea32e43d031fbfba8e2a17821bae';

//Initialize configuration file with nconf
nconf.argv()
    .file({ file: 'config.json' });

//Initialize with SoundCloud confirming client ID and secret...
//Insures that it is the SoundCirrus application requesting data. Validates against file hosted on server.
SC.init({
    id: client_id,
    secret: '04bca05ec426c656dd5eaf92f489b30c',
    uri: 'https://matthewkelsey.com/soundcirrus/callback.html'
});

//Initialize OAuth2 and validate with the callback page on server
var initOAuth = function(req, res) {
    var url = SC.getConnectUrl();
    res.writeHead(301, url);
    res.end();
};

//Follow redirects through authorization
var redirectHandler = function(req, res) {
    var code = req.query.code;
    SC.authorize(code, function(err, accessToken) {
        if ( err ) {
Esempio n. 10
0
var SC_USER_ID = process.env.SOUNDCLOUD_USER;
var SC_CLIENT_ID = process.env.SOUNDCLOUD_CLIENT;
var SC_USERNAME = process.env.SOUNDCLOUD_USERNAME;
var resolve_url = 'https://api.soundcloud.com/resolve?url=';

var PLAYLIST_MAP = {
    odesza: "odesza-no-sleep",
    galimatias: "2619526011",
    songs: "songs",
    ChetFaker: "15690151",
    Flume: "165797011",
    TaKu: "11055981"
};

SC.init({
    client_id: SC_CLIENT_ID
});

var SoundCloudPlay = function(){
  AlexaSkill.call(this, APP_ID)
};

SoundCloudPlay.prototype = Object.create(AlexaSkill.prototype);
SoundCloudPlay.prototype.constructor = SoundCloudPlay;
SoundCloudPlay.prototype.eventHandlers.onSessionStarted = function(sessionStartedRequest, session){
  console.log("onSessionStarted requestId: " + sessionStartedRequest.requestId
      + ", sessionId: " + session.sessionId)
};

SoundCloudPlay.prototype.eventHandlers.onLaunch = function(launchRequest, session, response){
  var output = 'Hello from Sound Cloud. ' +
Esempio n. 11
0
var
  express= require('express'),
  apiRouter = express.Router(),
  bodyParser= require('body-parser'),
  SC= require('node-soundcloud'),
  path = require('path'),
  app= express()

  //Initializing node-soundcloud with env variables
  SC.init({
    id: '030341538cff3ba796885fa35911cb51',
    secret: '030341538cff3ba796885fa35911cb51',
   })


  app.use(express.static(path.join(__dirname, '/public')))
  app.use(bodyParser.json())

  //recieving the widget player from the front end
  app.get('/', function(req, res){
  res.sendFile('index.html')
  })


  //go into the test route and recieve the data in the params artist from a user input in the url
  app.get('/test/:artist', function(req, res){
    //Soundcloud requests tracks under this artist
    SC.get('/tracks', {q: req.params.artist}, function(err, track) {
  if ( err ) {
    throw err;
  } else {
var SC = require("node-soundcloud");
SC.init({
	id: "8cc5ee91d9e6015109dc93302c43e99c"
});
var async = require("async");
const History = require("./history-model.js");


exports.register = function(server, options, next) {


	server.route({
		method: "GET",
		path: "/history",
		handler: function(request, reply) {
			History.find({
				"user_id": request.query.user_id
			}).then(function(tracks) {
				async.map(tracks,
					function(item, callback) {
						SC.get("/tracks/" + item.track_id, function merge(err, track) {
							callback(err, {
								sc: track,
								sn: item
							});
						});
					},
					function(err, result) {
						reply({
							tracks: result
						});
'use strict';

const SC = require('node-soundcloud');

SC.init({
    id: process.env.SC_CLIENT_ID,
    secret: process.env.SC_CLIENT_SECRET,
    uri: "http://www.coffeehousecoworkers.com/redirect"
});

SC.get('/playlists/47565276', function(err, playlist) {
	if(err){
		done(err);
	}
	else {

		let elapsedTime = 3622471;

		for(let i = 0; i < playlist.tracks.length; i++){
			let trackDuration = playlist.tracks[i].duration;
			if(trackDuration > elapsedTime){
				console.log(elapsedTime);
				console.log(playlist.tracks[i].id);
				break;
			}
			elapsedTime = elapsedTime - trackDuration;
		}
	}
});
Esempio n. 14
0
var SC = require('node-soundcloud');
var botkit = require('botkit');
var spotify = require('spotify');
var YouTube = require('youtube-node');
var scSearch = require('soundcloud-search-node');


var client_id = "fd11f5b302d3cbdb73e88788f8d30056";
var client_secret = "121a099d3633117c55f263adde0d9073";
var redirect_uri = "http://localhost:3000/callback.html";

// Initialize client 
SC.init({
  id: client_id,
  secret: client_secret,
  uri: redirect_uri
});
 
// Connect user to authorize application 
var initOAuth = function(req, res) {
  var url = SC.getConnectUrl();
  res.writeHead(301, url);
  res.end();
};
 
// Get OAuth token (example endpoint discussed in the next section) 

var redirectHandler = function(req, res) {
  var code = req.query.code;
 
  SC.authorize(code, function(err, accessToken) {
Esempio n. 15
0
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

var mongoose = require('mongoose');
var passport = require('passport');

var Post = mongoose.model('Post');
var Comment = mongoose.model('Comment');
var User = mongoose.model('User');

var SC = require('node-soundcloud');
// Initialize client 
SC.init({
  id: 'd2608224bcfc62f56f072dea63df4bdf',
  secret: 'ea4cd243f5780ff679b203179e477b93',
  uri: 'http://www.millsblog.com'
});

router.post('/register', function(req, res, next) {
  if (!req.body.username || !req.body.password) {
    return res.status(400).json({ message: 'Please provide a username & password'});
  }

  var user = new User();
  user.username = req.body.username;
  user.setPassword(req.body.password);

  user.save(function(err) {
    if (err) { return next(err); }
    return res.json( { token: user.generateJWT() } );
Esempio n. 16
0
import Promise from 'bluebird';
import storage from '../storage/storage';

let sc = require('node-soundcloud');
sc = Promise.promisifyAll(sc);

sc.init({
  id: storage.data.scClientId,
  secret: storage.data.scSecret,
  //uri: 'your SoundCloud redirect URI'
});

const SEARCH_LIMIT = 200;
const NOTFOUND = 'SC:NotFound';

let handleData = (result) => {
  if (!Array.isArray(result) || result.length === 0) throw new Error(NOTFOUND);

  return result.filter(obj => obj.stream_url && obj.title).map(obj => {
    obj.source = 'sc';
    if (obj.title.indexOf('-') !== -1) {
      obj.artist = obj.title.split('-')[0];
      obj.title = obj.title.substring(obj.title.indexOf('-') + 1);
    } else {
      obj.artist = obj.user.username.replace(/&amp;/g, '&');
      obj.title = obj.title.replace(/&amp;/g, '&');
    }
    obj.artist = obj.artist.trim();
    obj.title = obj.title.trim();
    obj.url = obj.stream_url + '?client_id=' + storage.data.scClientId;
    // obj.url = function() {
Esempio n. 17
0
import React, {Component} from 'react';
import ReactDOM from 'react-dom'
import ProgressSoundPlayer from './components/ProgressSoundPlayer'
import SC from 'node-soundcloud'
import Loading from 'react-loading';

var client_id = 'YOUR SOUNDCLOUD APP ID';

SC.init({
  id: client_id
});

class Main extends Component {

	constructor(props){
		super(props)

		this.state = {
			query: '',
			hasResults: false,
			searchResults: [],
			isLoading: false
		};
	}

	handleTextChange(event){
		this.setState({
			query: event.target.value
		});
		if(event.key == 'Enter'){
			this.search.call(this);
Esempio n. 18
0
var express = require('express');
var SC = require('node-soundcloud');
var keys = require('./config');
var bodyParser = require('body-parser');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var mongoose = require('mongoose');
var Track = require('./tracks/trackModel.js');
var User = require('./users/userModel.js')

SC.init({
  id: keys.clientID,
  secret: keys.clientSecret
})

mongoose.connect('mongodb://localhost/hearrit');

var app = express();

app.listen(8000);
app.use(express.static('client'));
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(session({
  secret: 'THIS IS A SECRET.'
}));

app.get('/', function(req, res) {
  res.render('index');
});