tesshu 6 years ago committed by Andrew DeMaria
parent 8ea47b71ff
commit 6023d4c0bc
  1. 6
      airsonic-main/src/main/java/org/airsonic/player/ajax/MultiService.java
  2. 11
      airsonic-main/src/main/java/org/airsonic/player/controller/SubsonicRESTController.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<SimilarArtist> similarArtists = getSimilarArtists(mediaFileId, maxSimilarArtists);
ArtistBio artistBio = lastFmService.getArtistBio(mediaFile, userSettings.getLocale());
ArtistBio artistBio = lastFmService.getArtistBio(mediaFile, localeResolver.resolveLocale(request));
List<TopSong> topSongs = getTopSongs(mediaFile, maxTopSongs);
return new ArtistInfo(similarArtists, artistBio, topSongs);

@ -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<BookmarkKey, org.airsonic.player.domain.Bookmark> bookmarkCache = new ConcurrentHashMap<BookmarkKey, org.airsonic.player.domain.Bookmark>();
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."),

Loading…
Cancel
Save