private void OnCommandLineArgument(string uri, object value, bool isFile) { if (!isFile || String.IsNullOrEmpty(uri)) { return; } // Handle OPML files if (uri.Contains("opml") || uri.EndsWith(".miro") || uri.EndsWith(".democracy")) { try { OpmlParser opml_parser = new OpmlParser(uri, true); foreach (string feed in opml_parser.Feeds) { ServiceManager.Get <DBusCommandService> ().PushFile(feed); } } catch (Exception e) { Log.Exception(e); } } else if (uri.Contains("xml") || uri.Contains("rss") || uri.Contains("feed") || uri.StartsWith("itpc") || uri.StartsWith("pcast")) { if (uri.StartsWith("feed://") || uri.StartsWith("itpc://")) { uri = String.Format("http://{0}", uri.Substring(7)); } else if (uri.StartsWith("pcast://")) { uri = String.Format("http://{0}", uri.Substring(8)); } // TODO replace autodownload w/ actual default preference FeedsManager.Instance.FeedManager.CreateFeed(uri, FeedAutoDownload.None); source.NotifyUser(); } else if (uri.StartsWith("itms://")) { System.Threading.ThreadPool.QueueUserWorkItem(delegate { try { string feed_url = new ItmsPodcast(uri).FeedUrl; if (feed_url != null) { ThreadAssist.ProxyToMain(delegate { FeedsManager.Instance.FeedManager.CreateFeed(feed_url, FeedAutoDownload.None); source.NotifyUser(); }); } } catch (Exception e) { Hyena.Log.Exception(e); } }); } }
private void ProcessFile(string uri, string title) { if (String.IsNullOrEmpty(uri)) { return; } if (uri.Contains("opml") || uri.EndsWith(".miro") || uri.EndsWith(".democracy")) { // Handle OPML files try { OpmlParser opml_parser = new OpmlParser(uri, true); foreach (string feed in opml_parser.Feeds) { ProcessFile(feed, title); } } catch (Exception e) { Log.Exception(e); } } else if (uri.Contains("xml") || uri.Contains("rss") || uri.Contains("feed") || uri.StartsWith("itpc") || uri.StartsWith("pcast")) { // Handle normal XML/RSS URLs if (uri.StartsWith("feed://") || uri.StartsWith("itpc://")) { uri = String.Format("http://{0}", uri.Substring(7)); } else if (uri.StartsWith("pcast://")) { uri = String.Format("http://{0}", uri.Substring(8)); } AddFeed(uri, title); } else if (uri.StartsWith("itms://")) { // Handle iTunes podcast URLs System.Threading.ThreadPool.QueueUserWorkItem(delegate { try { var feed = new ItmsPodcast(uri); if (feed.FeedUrl != null) { ThreadAssist.ProxyToMain(delegate { AddFeed(feed.FeedUrl, feed.Title ?? title); }); } } catch (Exception e) { Hyena.Log.Exception(e); } }); } }
private void ProcessFile (string uri, string title) { if (String.IsNullOrEmpty (uri)) { return; } if (uri.Contains ("opml") || uri.EndsWith (".miro") || uri.EndsWith (".democracy")) { // Handle OPML files try { OpmlParser opml_parser = new OpmlParser (uri, true); foreach (string feed in opml_parser.Feeds) { ProcessFile (feed, title); } } catch (Exception e) { Log.Exception (e); } } else if (uri.Contains ("xml") || uri.Contains ("rss") || uri.Contains ("feed") || uri.StartsWith ("itpc") || uri.StartsWith ("pcast")) { // Handle normal XML/RSS URLs if (uri.StartsWith ("feed://") || uri.StartsWith ("itpc://")) { uri = String.Format ("http://{0}", uri.Substring (7)); } else if (uri.StartsWith ("pcast://")) { uri = String.Format ("http://{0}", uri.Substring (8)); } AddFeed (uri, title); } else if (uri.StartsWith ("itms://")) { // Handle iTunes podcast URLs System.Threading.ThreadPool.QueueUserWorkItem (delegate { try { var feed = new ItmsPodcast (uri); if (feed.FeedUrl != null) { ThreadAssist.ProxyToMain (delegate { AddFeed (feed.FeedUrl, feed.Title ?? title); }); } } catch (Exception e) { Hyena.Log.Exception (e); } }); } }