Is it possible to use the created_at filter as part of a query in Python? I added it into my query filters, trying several different ways, but it seems to ignore that particular filter. The results that come back contain everything from last week to 3 years ago, and I'm only looking for recent tracks. I have to believe this is doable somehow...
stamp = "2013/07/01 09:24:50 +0000"
tracks = client.get('/tracks', q='Metallica', genre='', duration={
'from': 1800000
}, created_at={
'from': stamp
}, limit='5', tags='Metal')
I've also tried just entering the datetime stamp directly instead of as a variable, with the same results. Am I just botching the code somewhere here? Or can you really not specify the created_at date for your query results?
Yes! It is possible to use the created_at filter as part of a query in Python.
I do not know how the SoundCloud API prioritizes each of the filters, so it is possible that adding more filters may lead to unexpected results.
Limiting the filters simply to the filters {query, created_at} yield your desired result.
# https://github.com/soundcloud/soundcloud-python
import soundcloud
# Authentication
CLIENT_ID = 'insert_client_id_here'
client = soundcloud.Client(client_id=CLIENT_ID)
# Call GET request with parameters
# excludes: {genres,tags,duration}
# includes: {order,limit} for organization
stamp = "2013/07/01 09:24:50 +0000"
tracks = client.get('/tracks',
q='Metallica',
created_at= {'from': stamp},
order='created_at',
limit=5,
)
# Print the results
for i, v in enumerate(tracks):
print i, v.title, v.created_at