lastfm bio fetch to fallback to english if not found in user locale

custom
Ondřej Hruška 5 years ago
parent 66f7773598
commit b5f06c7d5d
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 18
      airsonic-main/src/main/java/org/airsonic/player/service/LastFmService.java

@ -244,7 +244,23 @@ public class LastFmService {
if (info == null) {
return null;
}
return new ArtistBio(processWikiText(info.getWikiSummary()),
String wiki = info.getWikiSummary().trim();
boolean isEnglish = locale.getLanguage().equals(Locale.ENGLISH.getLanguage());
// try to detect empty bio
if (!isEnglish && (wiki.length() < 250 &&
wiki.startsWith("<a href=\"https://www.last.fm/music/") && wiki.endsWith("on Last.fm</a>"))
) {
LOG.debug("Got empty bio for " + artistName + ", retry English");
Artist info1 = Artist.getInfo(artistName, Locale.ENGLISH, null /* username */, LAST_FM_KEY);
if (info1 != null) {
// ensure we do not replace non-null with null & NPE...
info = info1;
wiki = info.getWikiSummary().trim();
}
}
return new ArtistBio(processWikiText(wiki),
info.getMbid(),
info.getUrl(),
info.getImageURL(ImageSize.MEDIUM),

Loading…
Cancel
Save