From f8baa8956a2bebcf3e536124cd3d38ee79f563be Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 10 Jul 2013 20:01:23 -0700 Subject: Fix for when path isn't pre-defined for podcasts --- .../src/github/daneren2005/dsub/service/parser/AbstractParser.java | 2 +- .../github/daneren2005/dsub/service/parser/PodcastEntryParser.java | 6 ++++-- subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/AbstractParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/AbstractParser.java index 188d4a21..1a457754 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/AbstractParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/AbstractParser.java @@ -34,7 +34,7 @@ import github.daneren2005.dsub.util.Util; */ public abstract class AbstractParser { - private final Context context; + protected final Context context; private XmlPullParser parser; private boolean rootElementFound; diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java index 2af3b970..408b1b7a 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java @@ -22,10 +22,9 @@ import android.content.Context; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PodcastEpisode; +import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.ProgressListener; import java.io.Reader; -import java.util.ArrayList; -import java.util.List; import org.xmlpull.v1.XmlPullParser; /** @@ -76,6 +75,9 @@ public class PodcastEntryParser extends AbstractParser { episode.setDuration(getInteger("duration")); episode.setBitRate(getInteger("bitRate")); episode.setPath(get("path")); + if(episode.getPath() == null) { + episode.setPath(FileUtil.getPodcastPath(context, episode)); + } if("error".equals(episode.getStatus()) || "skipped".equals(episode.getStatus())) { episode.setId(String.valueOf(bogusId)); diff --git a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java index 44be1921..a8a6d480 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java @@ -38,6 +38,7 @@ import android.util.Log; import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PodcastChannel; +import github.daneren2005.dsub.domain.PodcastEpisode; /** * @author Sindre Mehus @@ -152,6 +153,9 @@ public class FileUtil { return dir; } + public static String getPodcastPath(Context context, PodcastEpisode episode) { + return getMusicDirectory(context).getPath() + "/" + fileSystemSafe(episode.getArtist()) + "/" + fileSystemSafe(episode.getTitle()); + } public static File getPodcastFile(Context context, String server) { File dir = getPodcastDirectory(context); return new File(dir.getPath() + "/" + fileSystemSafe(server)); -- cgit v1.2.3