Merge remote-tracking branch 'airsonic/pr/591'

master
Andrew DeMaria 7 years ago
commit 6fc6d90351
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 5
      airsonic-main/src/main/java/org/airsonic/player/ajax/MultiService.java
  2. 7
      airsonic-main/src/main/java/org/airsonic/player/controller/SubsonicRESTController.java
  3. 12
      airsonic-main/src/main/java/org/airsonic/player/service/LastFmService.java

@ -62,9 +62,12 @@ public class MultiService {
private SettingsService settingsService;
public ArtistInfo getArtistInfo(int mediaFileId, int maxSimilarArtists, int maxTopSongs) {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
UserSettings userSettings = settingsService.getUserSettings(securityService.getCurrentUsername(request));
MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
List<SimilarArtist> similarArtists = getSimilarArtists(mediaFileId, maxSimilarArtists);
ArtistBio artistBio = lastFmService.getArtistBio(mediaFile);
ArtistBio artistBio = lastFmService.getArtistBio(mediaFile, userSettings.getLocale());
List<TopSong> topSongs = getTopSongs(mediaFile, maxTopSongs);
return new ArtistInfo(similarArtists, artistBio, topSongs);

@ -431,7 +431,7 @@ public class SubsonicRESTController {
for (MediaFile similarArtist : similarArtists) {
result.getSimilarArtist().add(createJaxbArtist(similarArtist, username));
}
ArtistBio artistBio = lastFmService.getArtistBio(mediaFile);
ArtistBio artistBio = lastFmService.getArtistBio(mediaFile, getUserLocale(request));
if (artistBio != null) {
result.setBiography(artistBio.getBiography());
result.setMusicBrainzId(artistBio.getMusicBrainzId());
@ -468,7 +468,7 @@ public class SubsonicRESTController {
for (org.airsonic.player.domain.Artist similarArtist : similarArtists) {
result.getSimilarArtist().add(createJaxbArtist(new ArtistID3(), similarArtist, username));
}
ArtistBio artistBio = lastFmService.getArtistBio(artist);
ArtistBio artistBio = lastFmService.getArtistBio(artist, getUserLocale(request));
if (artistBio != null) {
result.setBiography(artistBio.getBiography());
result.setMusicBrainzId(artistBio.getMusicBrainzId());
@ -2402,6 +2402,9 @@ public class SubsonicRESTController {
return !players.isEmpty() ? players.get(0).getId() : null;
}
private Locale getUserLocale(HttpServletRequest request) {
return settingsService.getUserSettings(securityService.getCurrentUsername(request)).getLocale();
}
public enum ErrorCode {

@ -223,8 +223,8 @@ public class LastFmService {
* @param mediaFile The media file (song, album or artist).
* @return Artist bio.
*/
public ArtistBio getArtistBio(MediaFile mediaFile) {
return getArtistBio(getCanonicalArtistName(getArtistName(mediaFile)));
public ArtistBio getArtistBio(MediaFile mediaFile, Locale locale) {
return getArtistBio(getCanonicalArtistName(getArtistName(mediaFile)), locale);
}
/**
@ -233,8 +233,8 @@ public class LastFmService {
* @param artist The artist.
* @return Artist bio.
*/
public ArtistBio getArtistBio(org.airsonic.player.domain.Artist artist) {
return getArtistBio(getCanonicalArtistName(artist.getName()));
public ArtistBio getArtistBio(org.airsonic.player.domain.Artist artist, Locale locale) {
return getArtistBio(getCanonicalArtistName(artist.getName()), locale);
}
/**
@ -370,13 +370,13 @@ public class LastFmService {
}
private ArtistBio getArtistBio(String artistName) {
private ArtistBio getArtistBio(String artistName, Locale locale) {
try {
if (artistName == null) {
return null;
}
Artist info = Artist.getInfo(artistName, LAST_FM_KEY);
Artist info = Artist.getInfo(artistName, locale, null /* username */, LAST_FM_KEY);
if (info == null) {
return null;
}

Loading…
Cancel
Save