I am following the guidelines here https://github.com/soundcloud/soundcloud-python (built around Python requests), and I am trying to list all the tracks in my soundcloud account (https://developers.soundcloud.com/docs/api/reference#tracks), with their correspoding metrics such as plays, likes, etc.
# create client object with app and user credentials
client = soundcloud.Client(client_id=client_id,
client_secret=client_secret,
username=username,
password=password)
# print authenticated user's username
name = client.get('/me').username
track_count = client.get('/me').track_count
tracks = client.get('/tracks')
print name, track_count
I can get the values in the print statement, but if I try to do this (taken from the example)
for track in tracks.collection:
print track.title
I get this error:
AttributeError: 'ResourceList' object has no attribute 'collection'
Any idea how to fix this? Thanks
Try:
for track in tracks:
print track.title
You could also try to define tracks as follows:
tracks = client.get('/tracks.json')