问题
I'm experimenting a bit with the soundcloud api... Cool stuff, however:
It looks like when I try to apply a filter to search for tracks, the api ignores the duration...
See code snipper below. The purpose is to search for (10) trance tracks in the last 2 months, ordered by popularity, that have a duration of more than an hour.... As far as I know, the duration has to be specified in milliseconds (hence the * 100) Btw, The soundcloud object is SC, initialised with my API key
Am I doing something wrong, because then I look at the console, most tracks are less then an hour?
Thanks!
Sander
Soundcloud.get("/tracks", {
genres: "Trance,trance",
order: "hotness",
limit: 10,
created_at: {
from: moment().subtract(2, 'months').format("YYYY-MM-DD")
},
duration: {
from: 3600 * 1000 // seconds * 1000
}
}, function(tracks) {
console.log('tracks', tracks);
});
回答1:
I'd recommend you to use "duration[from]"
instead of your object definition. It's what I use and SoundCloud gives me consistently matching results.
Secondly, change your format in the created_at
param to .format("YYYY-MM-DD HH:mm:ss")
.
来源:https://stackoverflow.com/questions/27024747/soundcloud-search-api-ignoring-duration-filter