[rhythmbox] podcast: download all new episodes when auto updating



commit 29058edd64e7337a39910c7a0c9a842cb4c6f0f5
Author: Jonathan Matthew <jonathan d14n org>
Date:   Fri Nov 2 08:12:38 2012 +1000

    podcast: download all new episodes when auto updating
    
    https://bugzilla.gnome.org/show_bug.cgi?id=376372

 podcast/rb-podcast-manager.c |   40 ++++++++++++++++++++++++++++++++--------
 podcast/rb-podcast-source.c  |   12 ++++++------
 2 files changed, 38 insertions(+), 14 deletions(-)
---
diff --git a/podcast/rb-podcast-manager.c b/podcast/rb-podcast-manager.c
index 9e0e49f..ee576b1 100644
--- a/podcast/rb-podcast-manager.c
+++ b/podcast/rb-podcast-manager.c
@@ -1935,9 +1935,14 @@ rb_podcast_manager_add_parsed_feed (RBPodcastManager *pd, RBPodcastChannel *data
 	gulong new_last_post;
 	const char *title;
 	GList *download_entries = NULL;
-	gboolean new_feed, updated, download_last;
+	gboolean new_feed, updated;
 	RhythmDB *db = pd->priv->db;
 	RhythmDBQueryModel *existing_entries = NULL;
+	enum {
+		DOWNLOAD_NONE,
+		DOWNLOAD_NEWEST,
+		DOWNLOAD_NEW
+	} download_mode;
 
 	RhythmDBEntry *entry;
 
@@ -2048,11 +2053,23 @@ rb_podcast_manager_add_parsed_feed (RBPodcastManager *pd, RBPodcastChannel *data
 	rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_PLAYBACK_ERROR, &error_val);
 	g_value_unset (&error_val);
 
+	if (g_settings_get_enum (pd->priv->settings, PODCAST_DOWNLOAD_INTERVAL) == PODCAST_INTERVAL_MANUAL) {
+		/* if automatic updates are disabled, don't download anything */
+		rb_debug ("not downloading any new episodes");
+		download_mode = DOWNLOAD_NONE;
+	} else if (new_feed) {
+		/* don't download the entire backlog for new feeds */
+		rb_debug ("downloading most recent episodes");
+		download_mode = DOWNLOAD_NEWEST;
+	} else {
+		/* download all episodes since the last update for existing feeds */
+		rb_debug ("downloading all new episodes");
+		download_mode = DOWNLOAD_NEW;
+	}
+
 	/* insert episodes */
 	new_last_post = last_post;
-
 	updated = FALSE;
-	download_last = (g_settings_get_enum (pd->priv->settings, PODCAST_DOWNLOAD_INTERVAL) != PODCAST_INTERVAL_MANUAL);
 	for (lst_songs = data->posts; lst_songs != NULL; lst_songs = g_list_next (lst_songs)) {
 		RBPodcastItem *item = (RBPodcastItem *) lst_songs->data;
 		RhythmDBEntry *post_entry;
@@ -2099,16 +2116,23 @@ rb_podcast_manager_add_parsed_feed (RBPodcastManager *pd, RBPodcastChannel *data
 			updated = TRUE;
 
                 if (post_entry && item->pub_date >= new_last_post) {
-			if (item->pub_date > new_last_post) {
-				g_list_free (download_entries);
-				download_entries = NULL;
+			switch (download_mode) {
+			case DOWNLOAD_NEWEST:
+				if (item->pub_date > new_last_post) {
+					g_list_free (download_entries);
+					download_entries = NULL;
+				}
+				new_last_post = item->pub_date;
+				break;
+			case DOWNLOAD_NONE:
+			case DOWNLOAD_NEW:
+				break;
 			}
 			download_entries = g_list_prepend (download_entries, post_entry);
-			new_last_post = item->pub_date;
                 }
 	}
 
-	if (download_last) {
+	if (download_mode != DOWNLOAD_NONE) {
 		GValue status = {0,};
 		GList *t;
 
diff --git a/podcast/rb-podcast-source.c b/podcast/rb-podcast-source.c
index 168ae52..7e8ebf0 100644
--- a/podcast/rb-podcast-source.c
+++ b/podcast/rb-podcast-source.c
@@ -948,9 +948,9 @@ podcast_entry_changed_cb (RhythmDB *db,
 }
 
 static void
-podcast_error_pixbuf_clicked_cb (RBCellRendererPixbuf *renderer,
-				 const char *path_string,
-				 RBPodcastSource *source)
+podcast_status_pixbuf_clicked_cb (RBCellRendererPixbuf *renderer,
+				  const char *path_string,
+				  RBPodcastSource *source)
 {
 	GtkTreePath *path;
 	GtkTreeIter iter;
@@ -1517,7 +1517,7 @@ impl_constructed (GObject *object)
 				       source->priv->base_query);
 	g_object_unref (query_model);
 
-	/* error indicator column */
+	/* status indicator column */
 	column = gtk_tree_view_column_new ();
 	renderer = rb_cell_renderer_pixbuf_new ();
 	gtk_tree_view_column_pack_start (column, renderer, TRUE);
@@ -1531,10 +1531,10 @@ impl_constructed (GObject *object)
 	rb_property_view_append_column_custom (source->priv->feeds, column);
 	g_signal_connect_object (renderer,
 				 "pixbuf-clicked",
-				 G_CALLBACK (podcast_error_pixbuf_clicked_cb),
+				 G_CALLBACK (podcast_status_pixbuf_clicked_cb),
 				 source, 0);
 
-	/* redraw error indicator when errors are set or cleared */
+	/* redraw status when errors are set or cleared */
 	g_signal_connect_object (source->priv->db,
 				 "entry_changed",
 				 G_CALLBACK (podcast_entry_changed_cb),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]