I'm trying to get the list of labels present in 1991 using Discogs API but if I set the number of results above 7 (for example 9, 10 or 20..) I am always given a maximum of 7 results
LOG
PS C:\Users\admin\Desktop\SCRIPT\43_discogs> python label.py
Enter the label name: Box 52
How many results do you want to see for the label? 3
Results for the label:
1. Box 52
2. Po Box 52
3. Box 52 Records
Choose a label by entering the corresponding number: 1
Enter the year for the releases of the selected label: 1991
How many results do you want to see for label releases 'Box 52' in the year 1991? 8
Debug information:
Search URL: https://api.discogs.com/database/search?type=release&label=Box%2052&year=1991&token=++++++++jVomMEKXGydCvZkS&per_page=8
API response: {'pagination': {'page': 1, 'pages': 1, 'per_page': 8, 'items': 7, 'urls': {}}, 'results': ........
Results by label and year:
1. Zeitia Massiah* - (Homegirl) Sing The Blues (1991) - Label: Box 52
2. Paul Luke Pepper - A Different Song (For You) (1991) - Label: Box 52
3. Paul Luke Pepper - A Different Song (For You) (1991) - Label: BOX 52
4. Zeitia Massiah* - (Homegirl) Sing The Blues (1991) - Label: Box 52
5. Zeitia Massiah* - (Homegirl) Sing The Blues (1991) - Label: Box 52
6. Order From Chaos (2) - Evolutionary Element (1991) - Label: Box 52
7. Zeitia Massiah* - (Homegirl) Sing The Blues (1991) - Label: Box 52
PS C:\Users\admin\Desktop\SCRIPT\43_discogs>
My code is this
import requests
from urllib.parse import quote
user_token = '*********kz*******'
label_name = input("Inserisci il nome dell'etichetta: ")
num_label_results = int(input("How many results do you want to see for the label? "))
response = requests.get(f'https://api.discogs.com/database/search?type=label&q={quote(label_name)}&token={user_token}&per_page={num_label_results}')
label_results = response.json()['results']
print("Results for the label:")
for i, label_result in enumerate(label_results):
print(f"{i+1}. {label_result['title']}")
label_choice = int(input("Choose a label by entering the corresponding number: ")) - 1
selected_label = label_results[label_choice]
year = input("Enter the year for the releases of the selected label: ")
# Ask how many results they want to see for the label's releases in the specified year
num_year_results = int(input(f"How many results do you want to see for label releases '{selected_label['title']}' in the year {year}? "))
response = requests.get(f'https://api.discogs.com/database/search?type=release&label={quote(selected_label["title"])}&year={year}&token={user_token}&per_page={num_year_results}')
year_results = response.json()['results']
print("Debug information:")
print("Search URL:", response.url)
print("API response:", response.json())
print("Results by label and year:")
for i, year_result in enumerate(year_results):
# Get release details
response = requests.get(f'https://api.discogs.com/releases/{year_result["id"]}?token={user_token}')
release_details = response.json()
# Get the year of release and record label, if available
release_year = release_details.get('year', 'N/A')
labels = ', '.join(label['name'] for label in release_details.get('labels', []))
print(f"{i+1}. {year_result['title']} ({release_year}) - Label: {labels}")
Basically the important part is where the user can choose the number of results to display. I would also like to understand if the empty spaces in the label are correctly managed