banshee r4022 - in trunk/banshee: . src/Clients/Halie/Halie src/Core/Banshee.Core/Banshee.Base src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio src/Extensions/Banshee.Podcasting/Banshee.Podcasting
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4022 - in trunk/banshee: . src/Clients/Halie/Halie src/Core/Banshee.Core/Banshee.Base src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio src/Extensions/Banshee.Podcasting/Banshee.Podcasting
- Date: Thu, 29 May 2008 06:53:10 +0000 (UTC)
Author: gburt
Date: Thu May 29 06:53:10 2008
New Revision: 4022
URL: http://svn.gnome.org/viewvc/banshee?rev=4022&view=rev
Log:
2008-05-29 Gabriel Burt <gabriel burt gmail com>
* src/Clients/Halie/Halie/Client.cs: Don't turn strings that start with
*:// into local file paths.
* src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs: Add
method for creating a station given a lastfm:// url.
* src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs:
Listen for command line file arguments starting in lastfm:// and try to
create new stations for them.
* src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs:
Handle feed:// command line files, subscribing to them.
* src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs: Add TODO
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Clients/Halie/Halie/Client.cs
trunk/banshee/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs
trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
Modified: trunk/banshee/src/Clients/Halie/Halie/Client.cs
==============================================================================
--- trunk/banshee/src/Clients/Halie/Halie/Client.cs (original)
+++ trunk/banshee/src/Clients/Halie/Halie/Client.cs Thu May 29 06:53:10 2008
@@ -98,7 +98,13 @@
private static void HandleFiles ()
{
foreach (string file in ApplicationContext.CommandLine.Files) {
- command.PushFile (Path.GetFullPath (file));
+ // If it looks like a URI with a protocol, leave it as is
+ Console.WriteLine ("got file '{0}'", file);
+ if (System.Text.RegularExpressions.Regex.IsMatch (file, "^\\w+\\:\\/")) {
+ command.PushFile (file);
+ } else {
+ command.PushFile (Path.GetFullPath (file));
+ }
}
}
Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs (original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Base/CoverArtSpec.cs Thu May 29 06:53:10 2008
@@ -87,6 +87,7 @@
part = part.Substring (0, lp_index);
}
+ // TODO compile regex
return Regex.Replace (part, @"[^A-Za-z0-9]*", "").ToLower ();
}
Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs Thu May 29 06:53:10 2008
@@ -112,10 +112,13 @@
actions = new LastfmActions (this);
ServiceManager.SourceManager.AddSource (this);
+
+ ServiceManager.Get<DBusCommandService> ().ArgumentPushed += OnCommandLineArgument;
}
public void Dispose ()
{
+ ServiceManager.Get<DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
Connection.StateChanged -= HandleConnectionStateChanged;
Connection.Dispose ();
actions.Dispose ();
@@ -125,6 +128,18 @@
account = null;
}
+ private void OnCommandLineArgument (string uri, object value, bool isFile)
+ {
+ if (!isFile || String.IsNullOrEmpty (uri)) {
+ return;
+ }
+
+ // Handle lastfm:// URIs
+ if (uri.StartsWith ("lastfm://")) {
+ StationSource.CreateFromUrl (this, uri);
+ }
+ }
+
/*public override void AddChildSource (ChildSource source)
{
base.AddChildSource (source);
Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/StationSource.cs Thu May 29 06:53:10 2008
@@ -29,6 +29,7 @@
using System;
using System.Data;
using System.IO;
+using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading;
using Mono.Unix;
@@ -54,6 +55,22 @@
public class StationSource : Source, ITrackModelSource, IUnmapableSource, IDisposable, IBasicPlaybackController
{
private static string generic_name = Catalog.GetString ("Last.fm Station");
+
+ public static StationSource CreateFromUrl (LastfmSource lastfm, string url)
+ {
+ foreach (StationType type in StationType.Types) {
+ string regex = Regex.Escape (type.GetStationFor ("XXX")).Replace ("XXX", "([^\\/]+)");
+ Match match = Regex.Match (url, regex);
+ if (match.Groups.Count == 2 && match.Groups[0].Captures.Count > 0) {
+ Log.DebugFormat ("Creating last.fm station from url {0}", url);
+ string arg = match.Groups[1].Captures[0].Value;
+ StationSource station = new StationSource (lastfm, arg, type.Name, arg);
+ lastfm.AddChildSource (station);
+ station.NotifyUser ();
+ }
+ }
+ return null;
+ }
private MemoryTrackListModel track_model;
Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs Thu May 29 06:53:10 2008
@@ -228,13 +228,21 @@
}
}
- private void OnCommandLineArgument (string argument, object value, bool isFile)
+ private void OnCommandLineArgument (string uri, object value, bool isFile)
{
- if (!isFile) {
+ if (!isFile || String.IsNullOrEmpty (uri)) {
return;
}
- // TODO: Handle podcast URIs
+ // Handle podcast URIs
+ if (uri.StartsWith ("feed://")) {
+ string url = String.Format ("http://{0}", uri.Substring (7));
+ Log.DebugFormat ("Subscribing to podcast at {0}", url);
+
+ // TODO replace autodownload w/ actual default preference
+ FeedsManager.Instance.FeedManager.CreateFeed (url, FeedAutoDownload.None);
+ source.NotifyUser ();
+ }
}
private void RefreshArtworkFor (Feed feed)
@@ -281,6 +289,7 @@
private void OnFeedsChanged (object o, EventArgs args)
{
source.Reload ();
+ source.NotifyUser ();
}
/*private void OnFeedAddedHandler (object sender, FeedEventArgs args)
@@ -338,6 +347,7 @@
PodcastTrackInfo pi = new PodcastTrackInfo (item);
pi.PrimarySource = source;
pi.Save (true);
+ source.NotifyUser ();
} else {
item.Delete (false);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]