Last.fm API 为所有艺术家返回相同的“白星”图像

Gil*_*ues 9 android last.fm

最近我在使用 Last.fm API 时遇到了一个问题,我有一个功能齐全的代码,该代码在 2/3 天前工作,但今天每次尝试从 API 获取艺术家图片都会返回一个数组,该数组在所有艺术家的所有图像大小上都具有相同的 url。灰色背景白色星形图像。我尝试使用新的 API 密钥创建另一个帐户,以检查自上次更新 API 相关代码后的几个月后我的密钥是否有问题,但没有成功。

这是代码

    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");
      }
Run Code Online (Sandbox Code Playgroud)

小智 5

我只能提供一个无用的“我也是”。希望这只是一个错误,而不是 LFM 某些灾难性公告的前兆......


Hug*_*ugo 5

不幸的是,这是Last.fm 方面故意更改

根据我们的 API 使用条款,我们对 API 进行了更改,以限制滥用并为每个人改进服务。

虽然我们允许 API 用户通过 API 访问大量数据,但第三方使用音频、视听、图像或艺术作品始终违反我们的 API 使用条款。在某些情况下,某些数据可能已通过少量 API 调用间接访问,因此作为最近 API 清理的一部分,我们已更正该异常。

如果您的应用程序受到影响,请参阅我们的 API 使用条款以确保您的合规性。

艺术家图像的替代 API 来自 MusicBrainz。如果您正在处理 Last.fm 数据,您可能已经拥有艺术家的 MBID,您可以像这样查询(JavaScript 示例):