public StationEditor(LastfmSource lastfm, StationSource source) { this.lastfm = lastfm; this.source = source; Initialize(); Title = Catalog.GetString("Edit Station"); Arg = source.Arg; }
public StationSource(LastfmSource lastfm, string name, string type, string arg) : base(generic_name, name, 150) { this.lastfm = lastfm; Type = StationType.FindByName(type); Arg = arg; Station = Type.GetStationFor(arg); Save(); StationInitialize(); }
// For StationSources that already exist in the db protected StationSource(LastfmSource lastfm, int dbId, string name, string type, string arg, int playCount) : base(generic_name, name, 150, dbId.ToString()) { this.lastfm = lastfm; dbid = dbId; Type = StationType.FindByName(type); Arg = arg; PlayCount = playCount; Station = Type.GetStationFor(arg); StationInitialize(); }
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); }
public static List <StationSource> LoadAll(LastfmSource lastfm, string creator) { List <StationSource> stations = new List <StationSource> (); HyenaSqliteCommand command = new HyenaSqliteCommand( "SELECT StationID, Name, Type, Arg, PlayCount FROM LastfmStations WHERE Creator = ?", creator ); using (IDataReader reader = ServiceManager.DbConnection.Query(command)) { while (reader.Read()) { try { stations.Add(new StationSource(lastfm, Convert.ToInt32(reader[0]), reader[1] as string, reader[2] as string, reader[3] as string, Convert.ToInt32(reader[4]) )); } catch (Exception e) { Log.Warning("Error Loading Last.fm Station", e.ToString(), false); } } } // Create some default stations if the user has none if (stations.Count == 0) { stations.Add(new StationSource(lastfm, Catalog.GetString("Recommended"), "Recommended", creator)); stations.Add(new StationSource(lastfm, Catalog.GetString("Personal"), "Personal", creator)); stations.Add(new StationSource(lastfm, Catalog.GetString("Mix"), "Mix", creator)); stations.Add(new StationSource(lastfm, Catalog.GetString("Banshee Group"), "Group", "Banshee")); stations.Add(new StationSource(lastfm, Catalog.GetString("Neighbors"), "Neighbor", creator)); stations.Add(new StationSource(lastfm, Catalog.GetString("Creative Commons"), "Tag", "creative commons")); } return(stations); }
private bool ServiceStartup() { if (lastfm_source != null) { return(true); } foreach (var src in ServiceManager.SourceManager.FindSources <LastfmSource> ()) { lastfm_source = src; break; } if (lastfm_source == null) { return(false); } lastfm_source.ClearChildSources(); lastfm_source.SetChildSortTypes(station_sort_types); //lastfm_source.PauseSorting (); foreach (StationSource child in StationSource.LoadAll(lastfm_source, lastfm_source.Account.UserName)) { lastfm_source.AddChildSource(child); } //lastfm_source.ResumeSorting (); lastfm_source.SortChildSources(); lastfm_source.Properties.SetString("ActiveSourceUIResource", "ActiveSourceUI.xml"); lastfm_source.Properties.Set <bool> ("ActiveSourceUIResourcePropagate", true); lastfm_source.Properties.Set <System.Reflection.Assembly> ("ActiveSourceUIResource.Assembly", typeof(StationSource).Assembly); lastfm_source.Properties.SetString("SortChildrenActionLabel", Catalog.GetString("Sort Stations by")); actions = new LastfmStreamingActions(lastfm_source); return(true); }
public LastfmStreamingActions(LastfmSource lastfm) : base(ServiceManager.Get <InterfaceActionService> (), "LastfmStreaming") { this.lastfm = lastfm; AddImportant( new ActionEntry( "LastfmAddAction", Stock.Add, Catalog.GetString("_Add Station..."), null, Catalog.GetString("Add a new Last.fm radio station"), OnAddStation ) ); Add(new ActionEntry [] { new ActionEntry( "RefreshSourceAction", Stock.Refresh, Catalog.GetString("Refresh"), null, String.Empty, OnRefreshSource ) }); // Translators: {0} is a type of Last.fm station, eg "Fans of" or "Similar to". string listen_to = Catalog.GetString("Listen to {0} Station"); // Translators: {0} is a type of Last.fm station, eg "Fans of" or "Similar to". string listen_to_long = Catalog.GetString("Listen to the Last.fm {0} station for this artist"); // Artist actions Add(new ActionEntry [] { new ActionEntry("LastfmArtistPlayFanRadioAction", StationType.Fan.IconName, String.Format(listen_to, String.Format("'{0}'", Catalog.GetString("Fans of"))), null, String.Format(listen_to_long, String.Format("'{0}'", Catalog.GetString("Fans of"))), OnArtistPlayFanRadio), new ActionEntry("LastfmArtistPlaySimilarRadioAction", StationType.Similar.IconName, String.Format(listen_to, String.Format("'{0}'", Catalog.GetString("Similar to"))), null, String.Format(listen_to_long, String.Format("'{0}'", Catalog.GetString("Similar to"))), OnArtistPlaySimilarRadio) }); // Track actions Add(new ActionEntry [] { new ActionEntry( "LastfmLoveAction", null, Catalog.GetString("Love Track"), null, Catalog.GetString("Mark current track as loved"), OnLoved), new ActionEntry( "LastfmHateAction", null, Catalog.GetString("Ban Track"), null, Catalog.GetString("Mark current track as banned"), OnHated) }); this["LastfmLoveAction"].IconName = "face-smile"; this["LastfmHateAction"].IconName = "face-sad"; this["LastfmLoveAction"].IsImportant = true; this["LastfmHateAction"].IsImportant = true; actions_id = Actions.UIManager.AddUiFromResource("GlobalUI.xml"); Actions.AddActionGroup(this); lastfm.Connection.StateChanged += HandleConnectionStateChanged; Actions.SourceActions ["SourcePropertiesAction"].Activated += OnSourceProperties; ServiceManager.PlaybackController.SourceChanged += OnPlaybackSourceChanged; ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent, PlayerEvent.StartOfStream | PlayerEvent.EndOfStream); UpdateActions(); }
public StationEditor(LastfmSource lastfm) { this.lastfm = lastfm; Initialize(); Title = Catalog.GetString("New Station"); }