问题
Another question about using the API with Soundcloud (I'm using PHP).
I'll be uploading a large collection of sounds, some of which were recorded back in 1994 or so. I'd like to be able to use the search API to retrieve files with this date.
I can see that the track resource has [release_day] , [release_month] and [release_year] - but these fields do not appear to be available as filters in a query, correct?
So if I cannot search by the date using those fields, the only other option I can think of is to use the [created_at] field, as this can be used in a search.
Only - I have tried but I do not seem to be able to modify that piece of data using the API. I successfully modify other parts of metadata, but, for example (using PHP snippet):
$client->put('tracks/' . $track->id, array(
'track[created_at]' => "1994/03/14 07:35:57 +0000",
'track[description]' => 'This track was recorded in Berlin'
));
This has no effect, which I presume means that I cannot do what I need to do?
How could I get around this, and allow users on my site to search for sound files that were recorded back in 1994 or similar?
Thanks very much.
回答1:
First, querying a track, per the documentation, by:
created_at[from] date (yyyy-mm-dd hh:mm:ss) return tracks created at this date or later
created_at[to] date (yyyy-mm-dd hh:mm:ss) return tracks created at this date or earlier
does not currently work, as with many of the other queries on SoundCloud.
Aside from it being broken as a query, the created_at timestamp is added when the track is uploaded and is not modifiable. The only way to search by release parameters would be to search first by one of its subresources such as:
GET /users/{id}/tracks list of tracks of the user
GET /users/{id}/playlists list of playlists (sets) of the user
GET /tracks/{id}/comments comments for the track
GET /tracks/{id}/comments/{comment-id} a comment for the track
GET /tracks/{id}/favoriters users who favorited the track
GET /tracks/{id}/favoriters/{user-id} a user who has favorited to the track
GET /tracks/{id}/shared-to/users users who have access to the track
GET /tracks/{id}/shared-to/emails email addresses who are invited to the track
and then to filter the results based on the release property of the track. So for example you could search by /users/{id}/playlists, then filter the results of the tracks on that playlist by the release dates.
来源:https://stackoverflow.com/questions/15421002/dates-in-soundcloud-api