diff options
3 files changed, 57 insertions, 8 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 7b6a7261..e91dec41 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -698,7 +698,14 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter // If artist, we want to load the artist info to use later
if(artist && ServerInfo.hasArtistInfo(context) && !Util.isOffline(context)) {
try {
- artistInfo = musicService.getArtistInfo(id, refresh, context, this);
+ String artistId;
+ if(id.indexOf(';') == -1) {
+ artistId = id;
+ } else {
+ artistId = id.substring(0, id.indexOf(';'));
+ }
+
+ artistInfo = musicService.getArtistInfo(artistId, refresh, context, this);
} catch(Exception e) {
Log.w(TAG, "Failed to get Artist Info even though it should be supported");
}
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 86138dbf..7a7eb7af 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -260,14 +260,42 @@ public class RESTMusicService implements MusicService { } } - Reader reader = getReader(context, progressListener, "getMusicDirectory", null, "id", id); - try { - return new MusicDirectoryParser(context, getInstance(context)).parse(name, reader, progressListener); - } finally { - Util.close(reader); - } + MusicDirectory dir = null; + int index, start = 0; + while((index = id.indexOf(';', start)) != -1) { + MusicDirectory extra = getMusicDirectoryImpl(id.substring(start, index), name, refresh, context, progressListener); + if(dir == null) { + dir = extra; + } else { + dir.addChildren(extra.getChildren()); + } + + start = index + 1; + } + MusicDirectory extra = getMusicDirectoryImpl(id.substring(start), name, refresh, context, progressListener); + if(dir == null) { + dir = extra; + } else { + dir.addChildren(extra.getChildren()); + } + + // Apply another sort if we are chaining several together + if(dir != extra) { + dir.sortChildren(context, getInstance(context)); + } + + return dir; } + private MusicDirectory getMusicDirectoryImpl(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception { + Reader reader = getReader(context, progressListener, "getMusicDirectory", null, "id", id); + try { + return new MusicDirectoryParser(context, getInstance(context)).parse(name, reader, progressListener); + } finally { + Util.close(reader); + } + } + @Override public MusicDirectory getArtist(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception { Reader reader = getReader(context, progressListener, "getArtist", null, "id", id); diff --git a/src/github/daneren2005/dsub/service/parser/IndexesParser.java b/src/github/daneren2005/dsub/service/parser/IndexesParser.java index d718a387..0ac86476 100644 --- a/src/github/daneren2005/dsub/service/parser/IndexesParser.java +++ b/src/github/daneren2005/dsub/service/parser/IndexesParser.java @@ -19,8 +19,10 @@ package github.daneren2005.dsub.service.parser; import java.io.Reader; +import java.util.HashMap; import java.util.List; import java.util.ArrayList; +import java.util.Map; import org.xmlpull.v1.XmlPullParser; @@ -57,6 +59,7 @@ public class IndexesParser extends MusicDirectoryEntryParser { String index = "#"; String ignoredArticles = null; boolean changed = false; + Map<String, Artist> artistList = new HashMap<String, Artist>(); do { eventType = nextParseEvent(); @@ -75,7 +78,18 @@ public class IndexesParser extends MusicDirectoryEntryParser { artist.setName(get("name")); artist.setIndex(index); artist.setStarred(get("starred") != null); - artists.add(artist); + + // Combine the id's for the two artists + if(artistList.containsKey(artist.getName())) { + Artist originalArtist = artistList.get(artist.getName()); + if(originalArtist.isStarred()) { + artist.setStarred(true); + } + originalArtist.setId(originalArtist.getId() + ";" + artist.getId()); + } else { + artistList.put(artist.getName(), artist); + artists.add(artist); + } if (artists.size() % 10 == 0) { String msg = getContext().getResources().getString(R.string.parser_artist_count, artists.size()); |