aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-11-22 16:59:45 -0800
committerdaneren2005 <daneren2005@gmail.com>2013-11-22 16:59:45 -0800
commitcc447a8331335fa98003c57c439865c76b6ec2d2 (patch)
treec902d01493b90bd8e75f39d4a72a581d56d6b450 /src
parent30c6d3853e1d971a86f83604f8f898a291efa9e0 (diff)
downloaddsub-cc447a8331335fa98003c57c439865c76b6ec2d2.tar.gz
dsub-cc447a8331335fa98003c57c439865c76b6ec2d2.tar.bz2
dsub-cc447a8331335fa98003c57c439865c76b6ec2d2.zip
Added basic podcast sync logic
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
index 9a312900..6de7c74e 100644
--- a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
@@ -26,12 +26,16 @@ import android.content.ContentProviderClient;
import android.content.Context;
import android.content.SyncResult;
import android.os.Bundle;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.domain.Playlist;
+import github.daneren2005.dsub.service.DownloadFile;
+import github.daneren2005.dsub.util.Util;
/**
* Created by Scott on 8/28/13.
*/
-public class PodcastSyncAdapter extends AbstractThreadedSyncAdapter {
+public class PodcastSyncAdapter extends SubsonicSyncAdapter {
public PodcastSyncAdapter(Context context, boolean autoInitialize) {
super(context, autoInitialize);
}
@@ -40,8 +44,22 @@ public class PodcastSyncAdapter extends AbstractThreadedSyncAdapter {
super(context, autoInitialize, allowParallelSyncs);
}
- @Override
- public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
-
+ @Override
+ public void onExecuteSync(Context context, int instance) {
+ String serverName = Util.getServerName(context, instance);
+ String podcastListFile = "sync-podcast-" + (Util.getRestUrl(context, null, instance)).hasCode() + ".ser";
+ List<Integer> podcastList = FileUtil.deserialize(context, podcastListFile, ArrayList.class);
+ for(int i = 0; i < podcastList.size(); i++) {
+ String id = Integer.toString(podcastList.get(i));
+ List<PodcastChannel> podcasts = musicService.getPodcastEpisodes(true, id, context, null);
+
+ // TODO: Only grab most recent podcasts!
+ for(PodcastChannel entry: podcasts) {
+ DownloadFile file = new DownloadFile(context, entry, true);
+ while(!file.isSaved() && !file.isFailedMax()) {
+ file.downloadNow();
+ }
+ }
+ }
}
}