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

2

10

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");
      }
Tarnetgaronne answered 3/5, 2019 at 23:41 Comment(5)
Experiencing the same thing, not sure what's going onTeetotaler
Related: getsatisfaction.com/lastfm/topics/… and getsatisfaction.com/lastfm/topics/new-api-problems-urgentEld
This is ridiculous, looks like they won't bring the funcionality any time soonCharity
@Charity I've migrated to spotify API, Last.fm is dead to meTarnetgaronne
@GilianMarques this might be not a bad ideaCharity
M
7

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

Marzipan answered 30/12, 2019 at 10:58 Comment(1)
Hugo, in your JavaScript Example, the image gets fetched if MusicBrainz returns a relation containing an image URL from Wikimedia Commons. It does not return the image URL for many artists even though their images are available on Wikimedia Commons Page. Can you suggest any way to overcome this issue?Liven
E
5

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

Encroachment answered 4/5, 2019 at 4:43 Comment(3)
Add a comment to the question then rather than an answer.Ephemerality
Tankyou for share with us. It seems we'll have to find another source of metadata since the last update on last.fm's API blocks us to download images. tanks to @MorrisonChang to point to the API Announcement. As it's clear that it isn't about a bug on my code or even on API code and all this trouble is due to the API changes I'll set my quistion as answeredTarnetgaronne
This is a real shame. Their API was a real joy to use (can't say that very often). The whole method signature was a bit sloppy, but other than that, it was my favorite interface on the block. Without artist images, it just seems incomplete.Encroachment

© 2022 - 2024 — McMap. All rights reserved.