I am playing about with the Discogs API for a personal project, and I want a Python workflow where I can search for a string (could be song or artist) and retrieve all the releases/master records where that title occurs, BUT for certain years and those results with no year (if there are any).
So, in other words, I want (a) to pre-filter results by year of release within a certain range, e.g. 1991-1994, INCLUDING those records with no year of release, and (b) output the master/release IDs to a csv so I can iterate/filter them further afterwards by various attributes (country, genre, etc etc). I know how to output the IDs to csv, but I can't do (a), filter initially by years (or, crucially, no years!).
To establish connection and search generally I use the following, which returns a lot of paginated results, and the following prints the first page...
import discogs_client
import time
d = discogs_client.Client('my_user_agent/1.0', user_token='MYTOKENISHERE')
results = d.search('My Special Love Song')
print(len(results))
print(results.page(1))
That'll give you thousands of pages of results, starting with printing page 1...
[<Master 117350 'LaToya Jackson* - My Special Love'>, <Master 368326 'Charlie Rich - Very Special Love Songs'>, <Release 2315998 'LaToya Jackson* - My Special Love'>, <Release 3104531 'Charlie Rich - Very Special Love Songs'>, <Master 889231 'Percy Sledge - My Special Prayer / Pledging My Love'>, <Release 1434850 'Percy Sledge - My Special Prayer / Pledging My Love'>, <Master 258256 'Extreme (2) - Song For Love'>, <Master 506555 'Special Delivery - Special Delivery'>, <Release 2394297 'LaToya Jackson* - My Special Love'>, <Release 13779043 'LaToya Jackson* - My Special Love'>, <Release 2026440 'Special Delivery - Special Delivery'>, <Release 1826434 'LaToya Jackson* - My Special Love'>, <Release 2960819 'LaToya Jackson* - My Special Love'>, <Release 2495100 'Malik (3) / Special Force (5) - My Love / A Pretty Song For You'>, <Master 878003 'Jim Nabors - A Very Special Love Song'>, <Release 2062115 'Jim Nabors - A Very Special Love Song'>, <Release 3900553 'Charlie Rich - Very Special Love Songs'>, <Release 16073124 'Labi Siffre - Remember My Song'>, <Release 2338491 'Extreme (2) - Song For Love'>, <Release 11331156 'LaToya Jackson* - My Special Love'>, ...
My questions here are:
1.a) Is there a way to pre-filter the results so that I am only searching for results within a certain range (e.g. all results 1991-1994 AND those with no year)?
1.b) Is there a way to filter as well for those with no year of release? (if that's actually possible)
- If not, do I need to first save ALL those IDs and then query them individually for their details? That seems potentially very usage heavy as I'll have to iterate over them all and make thousands of queries?
Thanks!