[banshee] [InternetArchive] Add ability to subscribe to searches



commit 7d413b73306aa3f9ee21e5bdb3447a34efe6a77e
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Nov 5 16:43:35 2010 -0500

    [InternetArchive] Add ability to subscribe to searches
    
    So as new items are added that match your search, they'll show up in
    your Podcasts.

 .../Banshee.InternetArchive/Actions.cs             |   17 ++++++++++++++-
 .../InternetArchive/Search.cs                      |    9 ++++++++
 .../Resources/SearchSourceActiveUI.xml             |    1 +
 .../Banshee.Podcasting/PodcastService.cs           |   22 +++++++++++++++----
 src/Hyena                                          |    2 +-
 5 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
index d2ad85b..deffeb0 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
@@ -33,6 +33,9 @@ using System.Linq;
 using Mono.Unix;
 using Gtk;
 
+using Hyena;
+using Banshee.Base;
+using Banshee.ServiceStack;
 using IA=InternetArchive;
 
 namespace Banshee.InternetArchive
@@ -75,7 +78,19 @@ namespace Banshee.InternetArchive
             AddImportant (
                 new ActionEntry ("VisitInternetArchive", Stock.JumpTo, Catalog.GetString ("Visit Archive.org"), null, null, (o, a) => {
                     Banshee.Web.Browser.Open ("http://archive.org";);
-                })
+                }),
+                new ActionEntry ("SubscribeToIASearch", Stock.Add,
+                    Catalog.GetString ("Subscribe"), null,
+                    Catalog.GetString ("Subscribe to this search as a podcast"), (o, a) => {
+                        var desc = source.SearchSource.SearchDescription;
+                        var podcast = new Hyena.Json.JsonObject ();
+                        podcast["uri"] = source.SearchSource.Search.RssUrl;
+                        podcast["name"] = String.Format (Catalog.GetString ("Internet Archive: {0}"), desc.Name ?? desc.Query);
+                        Log.DebugFormat ("InternetArchive: subscribing to search: {0} ({1})", podcast["name"], podcast["uri"]);
+
+                        ServiceManager.Get<DBusCommandService> ().PushArgument ("podcast", podcast.ToString ());
+                    }
+                )
             );
 
             AddUiFromFile ("GlobalUI.xml");
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Search.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Search.cs
index f9670a7..df46842 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/Search.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Search.cs
@@ -78,6 +78,15 @@ namespace InternetArchive
             return sb.ToString ();
         }
 
+        public string RssUrl {
+            get {
+                return String.Format (
+                    "http://www.archive.org/services/collection-rss.php?query={0}";,
+                    System.Web.HttpUtility.UrlEncode (Query)
+                );
+            }
+        }
+
         public SearchResults GetResults ()
         {
             HttpWebResponse response = null;
diff --git a/src/Extensions/Banshee.InternetArchive/Resources/SearchSourceActiveUI.xml b/src/Extensions/Banshee.InternetArchive/Resources/SearchSourceActiveUI.xml
index 780c682..ee4e18c 100644
--- a/src/Extensions/Banshee.InternetArchive/Resources/SearchSourceActiveUI.xml
+++ b/src/Extensions/Banshee.InternetArchive/Resources/SearchSourceActiveUI.xml
@@ -2,6 +2,7 @@
   <toolbar name="HeaderToolbar">
     <placeholder name="SourceActions">
         <toolitem action="VisitInternetArchive" />
+        <toolitem action="SubscribeToIASearch" />
     </placeholder>
   </toolbar>
 
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
index 85e04ed..8710ddc 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
@@ -345,9 +345,21 @@ namespace Banshee.Podcasting
             return true;
         }
 
-        private void OnCommandLineArgument (string uri, object value, bool isFile)
+        private void OnCommandLineArgument (string argument, object value, bool isFile)
+        {
+            if (isFile) {
+                ProcessFile (argument, null);
+            } else if (argument == "podcast") {
+                var podcast = Hyena.Json.JsonObject.FromString (value as string);
+                if (podcast != null) {
+                    ProcessFile ((string)podcast["uri"], (string)podcast["name"]);
+                }
+            }
+        }
+
+        private void ProcessFile (string uri, string title)
         {
-            if (!isFile || String.IsNullOrEmpty (uri)) {
+            if (String.IsNullOrEmpty (uri)) {
                 return;
             }
 
@@ -356,7 +368,7 @@ namespace Banshee.Podcasting
                 try {
                     OpmlParser opml_parser = new OpmlParser (uri, true);
                     foreach (string feed in opml_parser.Feeds) {
-                        ServiceManager.Get<DBusCommandService> ().PushFile (feed);
+                        ProcessFile (feed, title);
                     }
                 } catch (Exception e) {
                     Log.Exception (e);
@@ -369,7 +381,7 @@ namespace Banshee.Podcasting
                     uri = String.Format ("http://{0}";, uri.Substring (8));
                 }
 
-                AddFeed (uri, null);
+                AddFeed (uri, title);
             } else if (uri.StartsWith ("itms://")) {
                 // Handle iTunes podcast URLs
                 System.Threading.ThreadPool.QueueUserWorkItem (delegate {
@@ -377,7 +389,7 @@ namespace Banshee.Podcasting
                         var feed = new ItmsPodcast (uri);
                         if (feed.FeedUrl != null) {
                             ThreadAssist.ProxyToMain (delegate {
-                                AddFeed (feed.FeedUrl, feed.Title);
+                                AddFeed (feed.FeedUrl, feed.Title ?? title);
                             });
                         }
                     } catch (Exception e) {
diff --git a/src/Hyena b/src/Hyena
index d88b025..1154965 160000
--- a/src/Hyena
+++ b/src/Hyena
@@ -1 +1 @@
-Subproject commit d88b0251880b960b701326cae4c6c82253cdd00c
+Subproject commit 115496594e2709b0abba0b518963b19eabd26eca



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