Blog

Integration 101: SoundCloud favorites straight to Dropbox

April 16, 2013 / Posted By: wotio team

Integration 101 is an ongoing series where I’ll describe some of the useful workflows that can be created with the Bipio API in a few easy steps. A basic understanding of RESTful API’s and SaaS is assumed, and if you have experience with graphs and graph traversals that’s helpful too but not necessary. If there’s anything you’d like to see, let me know. Otherwise it’s onward and upward with some crazy experiments!



I’m a lazy (busy?) SoundCloud music consumer, why click favorite > download > have a cup of tea > find in downloads > drag to Dropbox folder when I can just click ‘like’ instead and let a robot do the legwork?



Here’s a little assembly for doing just that with Bipio. It takes 2 Channels (soundcloud.getfavorites and dropbox.savefile) and 1 trigger bip to fire a message into the hub. Less clicks, more consumption.


SoundCloud

  
POST /rest/channel

{
  "action" : "soundcloud.get_favorites",
  "name" : "Get All The Favorites!"
}

Response

201 Created  
{
  "id": "23bb1de5-c950-c448-fbbf-000056c1eed6",
  ... more attributes here
}



Dropbox

  
POST /rest/channel

{
  "action" : "dropbox.save_file",
  "name" : "Save to SoundCloud Folder",
  "config" : {
     "base_dir" : "/soundcloud"
  }
}

Response

201 Created  
{
  "id": "5d2de02d-a70c-4ffd-ac15-9a97f6cb3d0f",
  ... more attributes here 
}




So armed with those two id’s, creating the bip is easy, ‘get_favorites’ is an emitter, meaning it generates its own content periodically (in this case, mp3 files and metadata). We can capture these files with a ‘trigger bip’, and process the files with an edge pointing to the Dropbox Channel.

  
{  
  "config": {
    "channel_id": "23bb1de5-c950-c448-fbbf-000056c1eed6"
  },  
  "end_life": {
    "time": 0,
    "imp": 0
  },
  "hub": {
    "source": {
      "annotation": "SoundCloud > Dropbox",
      "edges": [
        "5d2de02d-a70c-4ffd-ac15-9a97f6cb3d0f"
      ]
    }
  },
  "name": "SoundCloud to Dropbox",
  "type": "trigger"
}



Synced, just like that. There’s no need to transform any content unless its really necessary. Files that appear to a bip from an external service are simply carried across the hub incase channels need them. So, for this basic sync, we know that a file is appearing from SoundCloud, and whatever that file is, gets saved to DropBox.


Extra Credit

ok ok, so that assembly just ends up in big amorphous glob of music in the /soundcloud folder, so of course we should probably template the destination path a little better. Lets re-work the hub in that bip and add a transform to file it by Genre and Artist, which are two of the exports the soundcloud.getfavorites action already provides.

 
"hub": { "source": { "annotation": "SoundCloud > Dropbox", "edges": [ "5d2de02d-a70c-4ffd-ac15-9a97f6cb3d0f" ], "transforms" : { "5d2de02d-a70c-4ffd-ac15-9a97f6cb3d0f" : { "/soundcloud/[%genre%]/[%artist%]" : "basedir" } } } }

Now isn’t that better?