From c01b4cdcdd68d72653ad9a3b9eab6c5a5ef148bc Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Mon, 30 Sep 2024 22:05:31 -0400 Subject: [PATCH] Send a useragent in the request header to MB. MusicBrainz desires an identifying header in the requests made to its API. This is now included. --- api_calls.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api_calls.py b/api_calls.py index fbe7e09..aa1bcbd 100644 --- a/api_calls.py +++ b/api_calls.py @@ -3,8 +3,9 @@ import os def get_mb_id(artist_name, mb_confidence): artist_name = artist_name.strip('_') - mb_url = f'https://musicbrainz.org/ws/2/artist?query=artist:%22{artist_name}%22&fmt=json' - response = requests.get(mb_url) + mb_url = f'https://musicbrainz.org/ws/2/artist?query=artist:"{artist_name}"&fmt=json' + header = {'User-Agent': 'get_artist_art.py/1.0'} + response = requests.get(mb_url, headers=header) if response.status_code == 200: mb_data = response.json() if mb_data['count'] > 0: