Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 views
in Technique[技术] by (71.8m points)

javascript - soundcloud API - JSON track count does not match profile track count

I'm building a web app using the soundcloud JavaScript SDK that should only return profiles that contain one or more tracks.

My GET request returns an array of user profiles, each including the track_count property and associated value, as expected.

However, when I follow the link to each profile, the number of tracks is often different from the value listed in the JSON (see example in images below). Crucially, in relation to my purpose, this means that it sometimes returns profiles with 0 tracks.

From my tests so far, I've found that if the values are different then the profile track count is always less than in the JSON. Could this mean that's it's including tracks that have been deleted or removed (e.g. because of copyright infringement)?

I would really appreciate if someone could shed some light on this.

Thanks!

$(document).ready(function() {
          SC.initialize({
            client_id: 'xxxx',
            redirect_uri: 'http://localhost/callback.html'
          });

          SC.get('/users/12490371/followers', {

            limit: page_size,
            linked_partitioning: 1

          }).then(function(followers) {

            $(followers.collection).each(function(i) {
              //console.log(followers.collection[i].track_count)

              if (followers.collection[i].track_count > 10 && followers.collection[i].followers_count < 500) {
                $("#list").append(
                  "<ul>" +
                  "<li class='username'>" + this.username + "</li>" +
                  "<li>" + this.followers_count + "</li>" +
                  "<li>" + this.track_count + "</li>" +
                  "<li><a href='" + this.permalink_url + "' target='_blank'>GO</a>" + "</li>" +
                  "</ul>"
                );
              }

            });
          });
        });
<div id="list">
  <ul>
    <li class='username'>Username</li>
    <li>Followers</li>
    <li>Track count</li>
    <li>Profile</li>
  </ul>
</div>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To answer your question, it definitely seems that the SoundCloud API returns all tracks from the artist, no matter what state those tracks are in (public, private, etc.).

As far as the rest goes, Sound Cloud is notorious for being strict with how artists' content is handled in terms of embedding or having it used on other sites. It is usually up to the artist from my understanding, but in general, they want artists' content to be protected, especially if they are under a contract with a record company or something.

As for your web app, you'll either have to work around it or just ditch it completely, unless you can create some sort of scraper that can get more relevant info. If your site wants to play music directly from the site, however, you may be at a loss.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...