MomasVII
MomasVII

Reputation: 5071

Getting soundcloud images

I have been following this code: http://runnable.com/UuiMCfATvMMkAAAS/get-a-tracks-artwork-on-soundcloud-in-javascript

So to my understanding the url goes soundcloud.com/ARTISTID/TRACKID and I need to add those 2 details to the code: var PATH = "/users/ARTISTID/tracks/TRACKID "; or is there an easier way?

Anyway what if a URL is "https://soundcloud.com/krewella/sets/enjoy-the-ride-the-remixes" with "sets" included instead of track name?

Thanks

Upvotes: 0

Views: 308

Answers (1)

AnandKumar Patel
AnandKumar Patel

Reputation: 1020

you can find information about how the URL's are formatted at soundcloud's API reference site
http://developers.soundcloud.com/docs/api/reference
there are a few ways you can modify the PATH variable.

A "set" is actually called a "playlist" in soundcloud API. From the docs: "A SoundCloud Set is internally called playlists due to some naming restrictions." For a "set" API entry point you will use a path like this:

PATH="/playlists/PLAYLISTID"

where PLAYLISTID of the link you provided is 25422993. This will return all the information you need about that playlist (artwork, tracks, ...). Here is the JSON returned from that PATH query:

{
  "kind": "playlist",
  "id": 25422993,
  "created_at": "2014/03/03 20:06:31 +0000",
  "user_id": 4562420,
  "duration": 658451,
  "sharing": "public",
  "tag_list": "Enjoy the ride remixes armin van buuren vicetone electro house trance krewella",
  "permalink": "enjoy-the-ride-the-remixes",
  "track_count": 2,
  "streamable": true,
  "downloadable": false,
  "embeddable_by": "all",
  "purchase_url": "http://www.beatport.com/release/enjoy-the-ride/1255654",
  "label_id": null,
  "type": "",
  "playlist_type": "",
  "ean": "",
  "description": "",
  "genre": "",
  "release": "",
  "purchase_title": "BUY NOW ON BEATPORT",
  "label_name": "",
  "title": "Enjoy The Ride (The Remixes)",
  "release_year": null,
  "release_month": null,
  "release_day": null,
  "license": "all-rights-reserved",
  "uri": "https://api.soundcloud.com/playlists/25422993",
  "permalink_url": "http://soundcloud.com/krewella/sets/enjoy-the-ride-the-remixes",
  "artwork_url": "https://i1.sndcdn.com/artworks-000072616236-tz5ol2-large.jpg?435a760",
  "user":  {
    "id": 4562420,
    "kind": "user",
    "permalink": "krewella",
    "username": "Krewella",
    "uri": "https://api.soundcloud.com/users/4562420",
    "permalink_url": "http://soundcloud.com/krewella",
    "avatar_url": "https://i1.sndcdn.com/avatars-000013271556-x3q1d7-large.jpg?435a760"
  },
  "tracks":  [
     {
      "kind": "track",
      "id": 137740360,
      "created_at": "2014/03/03 19:41:39 +0000",
      "user_id": 4562420,
      "duration": 367446,
      "commentable": true,
      "state": "finished",
      "original_content_size": 64800466,
      "sharing": "public",
      "tag_list": ""enjoy the ride" "armin van buuren" remix trance",
      "permalink": "enjoy-the-ride-armin-van-buuren-remix",
      "streamable": true,
      "embeddable_by": "all",
      "downloadable": false,
      "purchase_url": "http://www.beatport.com/release/enjoy-the-ride/1255654",
      "label_id": null,
      "purchase_title": "BUY ON BEATPORT",
      "genre": "krewella",
      "title": "Enjoy The Ride (Armin Van Buuren Remix)",
      "description": "",
      "label_name": "",
      "release": "",
      "track_type": "",
      "key_signature": "",
      "isrc": "",
      "video_url": null,
      "bpm": null,
      "release_year": null,
      "release_month": null,
      "release_day": null,
      "original_format": "wav",
      "license": "all-rights-reserved",
      "uri": "https://api.soundcloud.com/tracks/137740360",
      "user":  {
        "id": 4562420,
        "kind": "user",
        "permalink": "krewella",
        "username": "Krewella",
        "uri": "https://api.soundcloud.com/users/4562420",
        "permalink_url": "http://soundcloud.com/krewella",
        "avatar_url": "https://i1.sndcdn.com/avatars-000013271556-x3q1d7-large.jpg?435a760"
      },
      "permalink_url": "http://soundcloud.com/krewella/enjoy-the-ride-armin-van-buuren-remix",
      "artwork_url": "https://i1.sndcdn.com/artworks-000072484399-f2sdhs-large.jpg?435a760",
      "waveform_url": "https://w1.sndcdn.com/EIFcGdIgM3QG_m.png",
      "stream_url": "https://api.soundcloud.com/tracks/137740360/stream",
      "playback_count": 208363,
      "download_count": 0,
      "favoritings_count": 9058,
      "comment_count": 467,
      "attachments_uri": "https://api.soundcloud.com/tracks/137740360/attachments"
    },
     {
      "kind": "track",
      "id": 137740647,
      "created_at": "2014/03/03 19:43:12 +0000",
      "user_id": 4562420,
      "duration": 291005,
      "commentable": true,
      "state": "finished",
      "original_content_size": 11638342,
      "sharing": "public",
      "tag_list": ""enjoy the ride" Electro house remix vicetone",
      "permalink": "enjoy-the-ride-vicetone-remix",
      "streamable": true,
      "embeddable_by": "all",
      "downloadable": false,
      "purchase_url": "http://www.beatport.com/release/enjoy-the-ride/1255654",
      "label_id": null,
      "purchase_title": "BUY NOW ON BEATPORT",
      "genre": "krewella",
      "title": "Enjoy The Ride (Vicetone Remix)",
      "description": "",
      "label_name": "",
      "release": "",
      "track_type": "",
      "key_signature": "",
      "isrc": "",
      "video_url": null,
      "bpm": null,
      "release_year": null,
      "release_month": null,
      "release_day": null,
      "original_format": "mp3",
      "license": "all-rights-reserved",
      "uri": "https://api.soundcloud.com/tracks/137740647",
      "user":  {
        "id": 4562420,
        "kind": "user",
        "permalink": "krewella",
        "username": "Krewella",
        "uri": "https://api.soundcloud.com/users/4562420",
        "permalink_url": "http://soundcloud.com/krewella",
        "avatar_url": "https://i1.sndcdn.com/avatars-000013271556-x3q1d7-large.jpg?435a760"
      },
      "permalink_url": "http://soundcloud.com/krewella/enjoy-the-ride-vicetone-remix",
      "artwork_url": "https://i1.sndcdn.com/artworks-000072484512-3laoie-large.jpg?435a760",
      "waveform_url": "https://w1.sndcdn.com/IEJtUQs75W9u_m.png",
      "stream_url": "https://api.soundcloud.com/tracks/137740647/stream",
      "playback_count": 216405,
      "download_count": 0,
      "favoritings_count": 9925,
      "comment_count": 455,
      "attachments_uri": "https://api.soundcloud.com/tracks/137740647/attachments"
    }
  ],
  "created_with":  {
    "id": 46941,
    "kind": "app",
    "name": "SoundCloud.com",
    "uri": "https://api.soundcloud.com/apps/46941",
    "permalink_url": "http://soundcloud.com/apps/v2-on-https-soundcloud-com",
    "external_url": "",
    "creator": "spadgos"
  }
}

If you know the numerical track id (which you can get via the API call we made above) you can use that to play that specifc track.

PATH="/tracks/TRACKID"

If you want to get tracks of a user

PATH="users/USERID/tracks"

hope that helps!

Upvotes: 1

Related Questions