Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Last.fm API returns same "white star" image for all artists

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");
      }
like image 837
Gilian Marques Avatar asked May 03 '19 23:05

Gilian Marques


2 Answers

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...

like image 57
user3067533 Avatar answered Oct 05 '22 14:10

user3067533


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):

  • https://stackoverflow.com/a/28467856/724176
like image 36
Hugo Avatar answered Oct 05 '22 13:10

Hugo