Recently i'm getting a poblem with Last.fm API, I have a fully functional code that worked 2/3 days ago but today each attempt to get artists pics from API returns an array with same url on all image sizes for all artists. A gray background white star image. I've tried to create another account with a new API key to check if it was a problem with my key once there's months since last time i updated the API related code but no succsses.
Here's the code
private static final String BASE_URL = "http://ws.audioscrobbler.com/2.0/";
private static final String API_KEY = "123456789";
@Nullable
public static String fetchJson(String url) {
HttpURLConnection urlConnection = null;
StringBuilder mStringBuilder = new StringBuilder();
try {
urlConnection = (HttpURLConnection) new URL(url).openConnection();
InputStream mInputStream = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader mReader = new BufferedReader(new InputStreamReader(mInputStream));
String line;
while ((line = mReader.readLine()) != null) {
mStringBuilder.append(line);
}
return mStringBuilder.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (urlConnection != null) urlConnection.disconnect();
}
}
public static String createArtistURL(String artistName) {
artistName = artistName.replace("&", "%26");
// TODO: 03/05/2019 testar isso URLEncoder.encode(artistName,UTF?);
return BASE_URL.concat("?method=artist.getinfo")
.concat("&artist=").concat(artistName)
.concat("&lang=").concat(Locale.getDefault().getLanguage())
.concat("&api_key=").concat(API_KEY)
.concat("&format=json");
}
I can offer nothing but a useless "me too". Hopefully this is just a bug and not a precursor to some disastrous announcement from LFM...
Unfortunately this is an intentional change on Last.fm's side:
We’ve made changes to our API in order to limit abuse and improve the service for everyone, in line with our API Terms of Use.
While we allow API users to have access to a lot of data through the API, it has always been against our API Terms of Use for third parties to use audio, audiovisual, images or artwork. In some instances, some data may have been indirectly accessible through a small number of API calls, and so as part of the recent API clean-up, we have corrected that anomaly.
If your application is affected, please refer to our API Terms of Use to ensure your compliance.
An alternative API for artist images is from MusicBrainz. If you're dealing with Last.fm data, you may already have the MBID for the artist, which you query like this (JavaScript example):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With