private void StartScrobble() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); TraktSettings settings = settingsManager.Load <TraktSettings>(); if (string.IsNullOrEmpty(settings.TraktOAuthToken)) { TraktLogger.Info("0Auth Token not available"); return; } if (!Login(settings.TraktOAuthToken)) { return; } if (_dataMovie.Movie != null && IsMovie(currentPlayingMediaItem)) { _dataMovie.Progress = 0; var response = TraktAPI.StartMovieScrobble(_dataMovie); TraktLogger.LogTraktResponse(response); return; } if (_dataEpisode != null && IsSeries(currentPlayingMediaItem)) { _dataEpisode.Progress = 0; var response = TraktAPI.StartEpisodeScrobble(_dataEpisode); TraktLogger.LogTraktResponse(response); return; } TraktLogger.Info("Can't start scrobble, scrobbledata not available"); }
public void EnterModelContext(NavigationContext oldContext, NavigationContext newContext) { // Load settings TraktSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <TraktSettings>(); IsEnabled = settings.EnableTrakt; Username = settings.Authentication != null ? settings.Authentication.Username : null; Password = settings.Authentication != null ? settings.Authentication.Password : null; TestStatus = string.Empty; BuildBannerUrls(); }
/// <summary> /// Saves the current state to the settings file. /// </summary> public void SaveSettings() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); TraktSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <TraktSettings>(); settings.EnableTrakt = IsEnabled; settings.Authentication = new TraktAuthentication { Username = Username, Password = Password }; // Save settingsManager.Save(settings); }
internal static bool Login(string key) { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); TraktSettings settings = settingsManager.Load <TraktSettings>(); var response = TraktAuth.GetOAuthToken(key); if (response == null || string.IsNullOrEmpty(response.AccessToken)) { TraktLogger.Error("Unable to login to trakt"); return(false); } settings.IsAuthorized = true; settings.TraktOAuthToken = response.RefreshToken; settingsManager.Save(settings); TraktLogger.Info("Successfully logged in"); return(true); }
private bool Login() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); TraktSettings settings = settingsManager.Load <TraktSettings>(); TraktLogger.Info("Exchanging refresh-token for access-token"); var response = TraktAuth.GetOAuthToken(settings.TraktOAuthToken); if (response == null || string.IsNullOrEmpty(response.AccessToken)) { TraktLogger.Error("Unable to login to trakt"); return(false); } settings.TraktOAuthToken = response.RefreshToken; settingsManager.Save(settings); TraktLogger.Info("Successfully logged in"); return(true); }