discogs / discogs_client

DEPRECATED - Official Python Client for the Discogs API
http://www.discogs.com/developers
Other
479 stars 132 forks source link

How to list all releases in each collection's folders? #76

Closed mezklador closed 7 years ago

mezklador commented 7 years ago

Hi,

I'm struggling a lot on your API to find out this issue. I didn't find anything about this on your documentation. Maybe it's because it's a TODO topic in class CollectionItemInstance(PrimaryAPIObject)? Anyway, let me know if I missed something and congrats for this job!

rodneykeeling commented 7 years ago

Hi @mezklador,

Each CollectionFolder has a releases attribute you can call to get a paginated list of releases. If you want to list all releases, I suggest looking at the All folder.

Here's an example:

> import discogs_client as dc
> my_token = 'abc123'
> ds = dc.Client('my_user_agent', my_token)
> 
> me = ds.identity()
> all_folder = me.collection_folders[0] # The `All` folder is the 0th index in this list
> all_folder.releases
<discogs_client.models.PaginatedList at 0x123abc456>
> all_folder.releases.page(0)
[<CollectionItemInstance 5147152 'Paris 1969'>,
 <CollectionItemInstance 2997914 "Monk's Dream">,
 <CollectionItemInstance 2960176 'Miles & Monk At Newport'>,
 <CollectionItemInstance 1751204 'Monk.'>,
 <CollectionItemInstance 3127571 'Solo Monk'>,
 <CollectionItemInstance 1467550 'Thelonious Monk / Sonny Rollins'>,
 <CollectionItemInstance 572468 "Monk's Music">]
> [cii.release for cii in foldr.releases.page(0)]
[<Release 5147152 'Paris 1969'>,
 <Release 2997914 "Monk's Dream">,
 <Release 2960176 'Miles & Monk At Newport'>,
 <Release 1751204 'Monk.'>,
 <Release 3127571 'Solo Monk'>,
 <Release 1467550 'Thelonious Monk / Sonny Rollins'>,
 <Release 572468 "Monk's Music">]
mezklador commented 7 years ago

Ok,

Thank you. It could be awesome to write a documentation about this API, don't you think?

Anyway, I works fine with All but I've done some folders in my personal collection, as I have a store on Discogs. So I've made sold items in a distinct collection... And then, for a personal website, I wanted to list all releases in particular folders. Do you think it's possible in the same manner as you describe below? Regards,