diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-11-10 17:50:53 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-11-10 17:50:53 -0800 |
commit | f11605422ea06a83347b72bfa8cb867847cb49cd (patch) | |
tree | df94e511a5aaa1fd72387ecb4a6523198bfc6595 /app/src/main | |
parent | 7347f23ad1039b92f0bbfb1e88a80079e33c866c (diff) | |
download | dsub-f11605422ea06a83347b72bfa8cb867847cb49cd.tar.gz dsub-f11605422ea06a83347b72bfa8cb867847cb49cd.tar.bz2 dsub-f11605422ea06a83347b72bfa8cb867847cb49cd.zip |
Fix cover art, file path, and podcast name for newest podcasts
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java | 15 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java | 27 |
2 files changed, 25 insertions, 17 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java index 1f677597..bdb1e550 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java @@ -35,6 +35,7 @@ import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; import github.daneren2005.dsub.service.OfflineException; import github.daneren2005.dsub.service.ServerTooOldException; +import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.SyncUtil; import github.daneren2005.dsub.util.Constants; @@ -182,6 +183,20 @@ public class SelectPodcastsFragment extends SelectRecyclerFragment<Serializable> if(!Util.isOffline(context) && ServerInfo.hasNewestPodcastEpisodes(context)) { try { newestEpisodes = musicService.getNewestPodcastEpisodes(10, context, listener); + + for(MusicDirectory.Entry entry: newestEpisodes.getChildren()) { + for(PodcastChannel channel: channels) { + if(channel.getId().equals(entry.getParent())) { + PodcastEpisode episode = (PodcastEpisode) entry; + + // Update with information normally done in PodcastEntryParser + episode.setArtist(channel.getName()); + episode.setCoverArt(channel.getCoverArt()); + episode.setPath(FileUtil.getPodcastPath(context, episode)); + break; + } + } + } } catch (Exception e) { Log.e(TAG, "Failed to download newest episodes", e); newestEpisodes = null; diff --git a/app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java b/app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java index ca9b609c..306464b0 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java +++ b/app/src/main/java/github/daneren2005/dsub/service/parser/PodcastEntryParser.java @@ -19,6 +19,8 @@ package github.daneren2005.dsub.service.parser; import android.content.Context; +import android.util.Log; + import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; @@ -43,6 +45,7 @@ public class PodcastEntryParser extends AbstractParser { init(reader); MusicDirectory episodes = new MusicDirectory(); + String coverArt = null; int eventType; boolean valid = false; do { @@ -54,6 +57,7 @@ public class PodcastEntryParser extends AbstractParser { if(id.equals(channel)) { episodes.setId(id); episodes.setName(get("title")); + coverArt = get("coverArt"); valid = true; } else { valid = false; @@ -65,25 +69,10 @@ public class PodcastEntryParser extends AbstractParser { episode.setEpisodeId(get("id")); episode.setId(get("streamId")); episode.setTitle(get("title")); - if(episodes.getName() != null) { + if(episodes.getId() != null) { episode.setArtist(episodes.getName()); episode.setParent(episodes.getId()); } else { - String artist = get("artist"); - String album = get("album"); - - String podcast; - if ("Podcasts".equals(artist)) { - podcast = album; - } else if("Podcast".equals(album)) { - podcast = artist; - } else if(album != null) { - podcast = album; - } else { - podcast = artist; - } - - episode.setArtist(podcast); episode.setParent(get("channelId")); } episode.setAlbum(get("description")); @@ -95,7 +84,11 @@ public class PodcastEntryParser extends AbstractParser { episode.setDate(episode.getDate().replace("T", " ")); } episode.setStatus(get("status")); - episode.setCoverArt(get("coverArt")); + if(coverArt == null) { + episode.setCoverArt(get("coverArt")); + } else { + episode.setCoverArt(coverArt); + } episode.setSize(getLong("size")); episode.setContentType(get("contentType")); episode.setSuffix(get("suffix")); |