From 6023d4c0bccacea60dae4e11e2f1cdc6791d044d Mon Sep 17 00:00:00 2001 From: tesshu Date: Sun, 5 Aug 2018 02:03:40 +0900 Subject: [PATCH] fix #748 --- .../java/org/airsonic/player/ajax/MultiService.java | 6 ++++-- .../player/controller/SubsonicRESTController.java | 11 +++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/ajax/MultiService.java b/airsonic-main/src/main/java/org/airsonic/player/ajax/MultiService.java index 82e5bba3..2545d1f1 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/ajax/MultiService.java +++ b/airsonic-main/src/main/java/org/airsonic/player/ajax/MultiService.java @@ -23,6 +23,7 @@ import org.airsonic.player.domain.ArtistBio; import org.airsonic.player.domain.MediaFile; import org.airsonic.player.domain.MusicFolder; import org.airsonic.player.domain.UserSettings; +import org.airsonic.player.i18n.LocaleResolver; import org.airsonic.player.service.LastFmService; import org.airsonic.player.service.MediaFileService; import org.airsonic.player.service.SecurityService; @@ -60,14 +61,15 @@ public class MultiService { private SecurityService securityService; @Autowired private SettingsService settingsService; + @Autowired + private LocaleResolver localeResolver; 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 similarArtists = getSimilarArtists(mediaFileId, maxSimilarArtists); - ArtistBio artistBio = lastFmService.getArtistBio(mediaFile, userSettings.getLocale()); + ArtistBio artistBio = lastFmService.getArtistBio(mediaFile, localeResolver.resolveLocale(request)); List topSongs = getTopSongs(mediaFile, maxTopSongs); return new ArtistInfo(similarArtists, artistBio, topSongs); diff --git a/airsonic-main/src/main/java/org/airsonic/player/controller/SubsonicRESTController.java b/airsonic-main/src/main/java/org/airsonic/player/controller/SubsonicRESTController.java index ee193430..0bb22639 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/controller/SubsonicRESTController.java +++ b/airsonic-main/src/main/java/org/airsonic/player/controller/SubsonicRESTController.java @@ -30,6 +30,7 @@ import org.airsonic.player.dao.PlayQueueDao; import org.airsonic.player.domain.*; import org.airsonic.player.domain.Bookmark; import org.airsonic.player.domain.PlayQueue; +import org.airsonic.player.i18n.LocaleResolver; import org.airsonic.player.service.*; import org.airsonic.player.util.Pair; import org.airsonic.player.util.StringUtil; @@ -135,6 +136,8 @@ public class SubsonicRESTController { private PlayQueueDao playQueueDao; @Autowired private MediaScannerService mediaScannerService; + @Autowired + private LocaleResolver localeResolver; private final Map bookmarkCache = new ConcurrentHashMap(); private final JAXBWriter jaxbWriter = new JAXBWriter(); @@ -431,7 +434,7 @@ public class SubsonicRESTController { for (MediaFile similarArtist : similarArtists) { result.getSimilarArtist().add(createJaxbArtist(similarArtist, username)); } - ArtistBio artistBio = lastFmService.getArtistBio(mediaFile, getUserLocale(request)); + ArtistBio artistBio = lastFmService.getArtistBio(mediaFile, localeResolver.resolveLocale(request)); if (artistBio != null) { result.setBiography(artistBio.getBiography()); result.setMusicBrainzId(artistBio.getMusicBrainzId()); @@ -468,7 +471,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, getUserLocale(request)); + ArtistBio artistBio = lastFmService.getArtistBio(artist, localeResolver.resolveLocale(request)); if (artistBio != null) { result.setBiography(artistBio.getBiography()); result.setMusicBrainzId(artistBio.getMusicBrainzId()); @@ -2402,10 +2405,6 @@ public class SubsonicRESTController { return !players.isEmpty() ? String.valueOf(players.get(0).getId()) : null; } - private Locale getUserLocale(HttpServletRequest request) { - return settingsService.getUserSettings(securityService.getCurrentUsername(request)).getLocale(); - } - public enum ErrorCode { GENERIC(0, "A generic error."),