public async void Init() { if (Settings.LastFmEnabled) { try { await LoginToLastFm(); } catch (TaskCanceledException) { Settings.LastFmEnabled = false; } } if (Settings.TwitterEnabled) { try { await LoginToTwitter(); } catch (TaskCanceledException) { Settings.TwitterEnabled = false; } } if (session?.Authenticated == true) { connection = new Connection(session); manager = new Lastfm.Scrobbling.ScrobbleManager(connection); } }
public void LogOut() { session = null; connection = null; manager = null; Api.Utility.SetSecured("last.fm", "", ApiConstants.LastFmApiKey); }
public async void Init() { if (Settings.LastFmEnabled) { await LoginToLastFm(); } if (session?.Authenticated == true) { connection = new Connection(session); manager = new Lastfm.Scrobbling.ScrobbleManager(connection); } }
public bool Login(string username, string password) { this.username = username; this.password = password; Session.Authenticate(this.username, Lastfm.Utilities.MD5(this.password)); if (Session.Authenticated) { connection = new Lastfm.Scrobbling.Connection("mpm", Assembly.GetEntryAssembly().GetName().Version.ToString(), this.username, Session); manager = new Lastfm.Scrobbling.ScrobbleManager(connection); IsLoged = true; return true; } return false; }
public bool Login(string username, string password) { this.username = username; this.password = password; Session.Authenticate(this.username, Lastfm.Utilities.MD5(this.password)); if (Session.Authenticated) { connection = new Lastfm.Scrobbling.Connection("mpm", Assembly.GetEntryAssembly().GetName().Version.ToString(), this.username, Session); manager = new Lastfm.Scrobbling.ScrobbleManager(connection); IsLoged = true; return(true); } return(false); }
public void Initialize(Configuration configuration) { Trace.WriteLine("Initializing..."); try { session = GetSession(configuration); scrobbleManager = GetScrobbleManager(configuration, session); } catch (Exception ex) { var lastfmServiceException = ex as ServiceException; if (lastfmServiceException != null) { if (lastfmServiceException.Type == ServiceExceptionType.AuthenticationFailed) { // Wrap exception in AuthenticationException class. throw new AuthenticationException(ex.Message, ex); } } throw; } feedUrl = GetFeedUrl(); this.configuration = configuration; Trace.WriteLine("Initialized"); }
private void LoadSettings() { if (System.IO.File.Exists("settings.mpc")) { try { XmlDocument settingsXml = new XmlDocument(); settingsXml.Load("settings.mpc"); XmlNode MsnEnabledNode = settingsXml.GetElementsByTagName("msnenabled")[0]; if (MsnEnabledNode.InnerText == "true") msnEnabled = true; else msnEnabled = false; // Check for Last.FM scrobbling XmlNode scrobblingNode = settingsXml.GetElementsByTagName("scrobble")[0]; XmlNodeList scrobblingChildren = scrobblingNode.ChildNodes; foreach (XmlNode node in scrobblingChildren) { if (node.Name == "enabled") { if (node.InnerText == "true") scrobblingEnabled = true; else scrobblingEnabled = false; } } // If scrobbling is enabled, authentican with last.fm if (scrobblingEnabled) { if (!session.Authenticated) { // Grab username and password for last.fm auth string md5Password = Lastfm.Utilities.md5(settingsXml.GetElementsByTagName("password")[0].InnerText); session.Authenticate(settingsXml.GetElementsByTagName("username")[0].InnerText, md5Password); if (session.Authenticated) { Connection connection = new Connection("mpc", "1.0", settingsXml.GetElementsByTagName("username")[0].InnerText, session); scrobbleManager = new ScrobbleManager(connection, "../cache/"); Console.WriteLine("Authenticated!"); } } } else { Console.WriteLine("Scrobbling not enabled"); } } catch (XmlException xe) { Console.WriteLine(xe.ToString()); } } }