Exemplo n.º 1
0
        private void ParseCommandLine(string[] args)
        {
            if (args == null)
            {
                return;
            }

            foreach (var argument in args)
            {
                switch (argument.ToLower().TrimStart('-'))
                {
                case "silentmode":
                    SilentMode = true;
                    break;

                case "sync":
                    AutoSync = true;
                    break;

                case "closeaftersync":
                    AutoCloseAfterSync = true;
                    break;
                }
            }

            TraktLogger.Info("Command Line Options Set, SilentMode = '{0}', AutoSync = '{1}', CloseAfterSync = '{2}'", SilentMode, AutoSync, AutoCloseAfterSync);
        }
        private void btnAuthoriseApplication_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TraktSettings.UserAccessToken))
            {
                var AuthDialog = new AuthorizationPopup();

                AuthDialog.ShowDialog(this);
                if (AuthDialog.DialogResult == DialogResult.OK)
                {
                    lblAuthorizeApplication.Visible = false;
                    btnAuthoriseApplication.Text    = "Revoke Access";
                    TraktSettings.SaveSettings(false);
                }
                else
                {
                    btnAuthoriseApplication.Text = "Authorize Application...";
                    ClearAuthorisationProperties();
                }
            }
            else
            {
                TraktLogger.Info("Revoking application access to trakt.tv account");

                TraktAPI.TraktAPI.RevokeToken();
                ClearAuthorisationProperties();

                TraktLogger.Info("Application access has now been revoked from using trakt.tv account");
            }
        }
Exemplo n.º 3
0
 private void AuthorizationPopup_FormClosing(object sender, FormClosingEventArgs e)
 {
     // Check if background worker is doing anything and send a cancellation if it is
     if (AuthWorker.IsBusy)
     {
         TraktLogger.Info("Authorization process cancelled");
         TraktAPI.TraktAPI.AuthorisationCancelled = true;
         AuthWorker.CancelAsync();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Logs the result of Trakt api call
        /// </summary>
        /// <typeparam name="T">Response Type of message</typeparam>
        /// <param name="response">The response object holding the message to log</param>
        internal static bool LogTraktResponse <T>(T response)
        {
            try
            {
                if (response == null || (response as TraktResponse).Status == null)
                {
                    // server is probably temporarily unavailable
                    // return true even though it failed, so we can try again
                    // currently the return value is only being used in livetv/recordings
                    TraktLogger.Error("Response from server was unexpected.");
                    return(true);
                }

                // check response error status
                if ((response as TraktResponse).Status != "success")
                {
                    if ((response as TraktResponse).Error == "The remote server returned an error: (401) Unauthorized.")
                    {
                        TraktLogger.Error("401 Unauthorized, Please check your Username and Password");
                    }
                    else
                    {
                        TraktLogger.Error((response as TraktResponse).Error);
                    }

                    return(false);
                }
                else
                {
                    // success
                    if (!string.IsNullOrEmpty((response as TraktResponse).Message))
                    {
                        TraktLogger.Info("Response: {0}", (response as TraktResponse).Message);
                    }
                    else
                    {
                        // no message returned on movie sync success
                        if ((response is TraktSyncResponse))
                        {
                            string message = "Response: Items Inserted: {0}, Items Already Exist: {1}, Items Skipped: {2}";
                            TraktLogger.Info(message, (response as TraktSyncResponse).Inserted, (response as TraktSyncResponse).AlreadyExist, (response as TraktSyncResponse).Skipped);
                        }
                    }
                    return(true);
                }
            }
            catch (Exception)
            {
                TraktLogger.Info("Response: {0}", "Failed to interpret response from server");
                return(false);
            }
        }
        private void Extensions_OnSettingsChanged(string guid)
        {
            // settings change occured
            if (guid == TraktSettings.cGuid)
            {
                TraktLogger.Info("Settings updated externally");

                // re-load settings
                TraktSettings.loadSettings();

                // re-initialize sync Interval
                TraktPlugin.ChangeSyncTimer(TraktSettings.SyncTimerLength, TraktSettings.SyncTimerLength);

                // update any internal plugin settings required
                TraktSettings.UpdateInternalPluginSettings();
            }
        }
Exemplo n.º 6
0
        private void AuthWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            #region Get Device Code
            TraktLogger.Info("Getting device code from trakt.tv");

            var code = TraktAPI.TraktAPI.GetDeviceCode();
            if (code == null || string.IsNullOrEmpty(code.DeviceCode))
            {
                AuthWorker.CancelAsync();
                Close();
            }
            else if (AuthWorker.CancellationPending)
            {
                return;
            }

            lblUserCode.Text = code.UserCode;
            #endregion

            #region Poll for Access Token
            TraktLogger.Info("Successfully got device code from trakt.tv, presenting code '{0}' to user for activation at '{1}'. Code expires in '{2}' secs", code.UserCode, code.VerificationUrl, code.ExpiresIn);
            TraktLogger.Info("Polling trakt.tv for authorization token every '{0}' secs until user enters code", code.Interval);

            var authToken = TraktAPI.TraktAPI.GetAuthenticationToken(code);
            if (authToken != null && !AuthWorker.CancellationPending)
            {
                TraktSettings.UserRefreshToken      = authToken.RefreshToken;
                TraktSettings.UserAccessToken       = authToken.AccessToken;
                TraktSettings.UserAccessTokenExpiry = DateTime.UtcNow.AddSeconds(authToken.ExpiresIn).ToString();

                TraktLogger.Info("Authorization to use trakt.tv account has been successfull");

                lblUserCode.Text      = "SUCCESS";
                lblUserCode.ForeColor = Color.Green;
                Thread.Sleep(3000);
            }
            else
            {
                lblUserCode.Text      = "ERROR";
                lblUserCode.ForeColor = Color.Red;
                Thread.Sleep(10000);
            }
            #endregion
        }
Exemplo n.º 7
0
        /// <summary>
        /// Get the slugs for each list selected by a user in the Multi-Select dialog
        /// </summary>
        /// <param name="username">username of user</param>
        /// <param name="lists">List of lists created by user</param>
        public static List <string> GetUserListSelections(List <TraktUserList> lists)
        {
            if (lists.Count == 0)
            {
                if (!GUIUtils.ShowYesNoDialog(Translation.Lists, Translation.NoListsFound, true))
                {
                    // nothing to do, return
                    return(null);
                }
                TraktList list = new TraktList();
                if (TraktLists.GetListDetailsFromUser(ref list))
                {
                    TraktLogger.Info("Creating new '{0}' list '{1}'", list.Privacy, list.Name);
                    TraktAddListResponse response = TraktAPI.TraktAPI.ListAdd(list);
                    TraktAPI.TraktAPI.LogTraktResponse <TraktResponse>(response);
                    if (response.Status == "success")
                    {
                        ClearCache(TraktSettings.Username);
                        return(new List <string> {
                            response.Slug
                        });
                    }
                }
                return(null);
            }

            List <MultiSelectionItem> selectedItems = GUIUtils.ShowMultiSelectionDialog(Translation.SelectLists, GetMultiSelectItems(lists));

            if (selectedItems == null)
            {
                return(null);
            }

            List <string> slugs = new List <string>();

            foreach (var item in selectedItems.Where(l => l.Selected == true))
            {
                slugs.Add(item.ItemID);
            }
            return(slugs);
        }
Exemplo n.º 8
0
        private void CloseConfig()
        {
            if (TraktSettings.KeepTraktLibraryClean && (TraktSettings.MoviePluginCount > 1 || TraktSettings.TvShowPluginCount > 1))
            {
                // warn and disable clean library
                string message = "You can not have 'Clean Library' option enabled with more than one movie or show plugin enabled. Option will be disabled.";
                MessageBox.Show(message, "trakt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TraktSettings.KeepTraktLibraryClean = false;
            }

            // disable parental controls if not pin code not entered
            if (txtPinCode.TextLength < 4)
            {
                TraktSettings.ParentalControlsEnabled = false;
            }

            TraktSettings.SaveSettings(false);

            TraktLogger.Info("Exiting Configuration");
            this.Close();
        }
        public void Init()
        {
            Thread hookThread = new Thread(delegate()
            {
                try
                {
                    TraktLogger.Info("Adding hooks to MPEI Settings");
                    AddHooksIntoMPEISettings();
                }
                catch
                {
                    TraktLogger.Warning("Unable to add hooks into MPEI Settings, Extensions plugin not installed or out of date!");
                }
            })
            {
                Name         = "Settings",
                IsBackground = true
            };

            hookThread.Start();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Get the ids for each list selected by a user in the Multi-Select dialog
        /// </summary>
        public static List <int> GetUserListSelections(List <TraktListDetail> lists)
        {
            if (lists.Count == 0)
            {
                if (!GUIUtils.ShowYesNoDialog(Translation.Lists, Translation.NoListsFound, true))
                {
                    // nothing to do, return
                    return(null);
                }
                var list = new TraktListDetail();
                if (TraktLists.GetListDetailsFromUser(ref list))
                {
                    TraktLogger.Info("Creating new list for user online. Privacy = '{0}', Name = '{1}'", list.Privacy, list.Name);
                    var response = TraktAPI.TraktAPI.CreateCustomList(list);
                    if (response != null)
                    {
                        ClearListCache(TraktSettings.Username);
                        return(new List <int> {
                            (int)response.Ids.Trakt
                        });
                    }
                }
                return(null);
            }

            List <MultiSelectionItem> selectedItems = GUIUtils.ShowMultiSelectionDialog(Translation.SelectLists, GetMultiSelectItems(lists));

            if (selectedItems == null)
            {
                return(null);
            }

            var listIds = new List <int>();

            foreach (var item in selectedItems.Where(l => l.Selected == true))
            {
                listIds.Add(int.Parse(item.ItemID));
            }
            return(listIds);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Logs the result of Trakt api call
        /// </summary>
        /// <typeparam name="T">Response Type of message</typeparam>
        /// <param name="response">The response object holding the message to log</param>
        internal static bool LogTraktResponse <T>(T response)
        {
            if (response == null)
            {
                // we already log errors which would normally not be able to be deserialised
                // currently the return value is only being used in livetv/recordings
                return(true);
            }

            try
            {
                // only log the response if we don't have debug logging enabled
                // we already log all responses in debug level
                if (TraktSettings.LogLevel < 3)
                {
                    if ((response is TraktSyncResponse))
                    {
                        TraktLogger.Info("Sync Response: {0}", (response as TraktSyncResponse).ToJSON());
                    }
                    else if ((response is TraktScrobbleResponse))
                    {
                        // status code will be greater than 0 if we caught an error
                        // we already log errors so we can supress the scrobble log result
                        var scrobbleResponse = response as TraktScrobbleResponse;
                        if (scrobbleResponse != null && scrobbleResponse.Code == 0)
                        {
                            TraktLogger.Info("Scrobble Response: {0}", scrobbleResponse.ToJSON());
                        }
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                TraktLogger.Info("Response: Failed to interpret response from server");
                return(false);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Clears our library on Trakt as best as the api lets us
        /// </summary>
        /// <param name="mode">What to remove from Trakt</param>
        private void ClearLibrary(TraktClearingModes mode, ProgressDialog progressDialog, bool clearSeen)
        {
            progressDialog.Title         = "Clearing Library";
            progressDialog.CancelMessage = "Attempting to Cancel";
            progressDialog.Maximum       = 100;
            progressDialog.Value         = 0;
            progressDialog.Line1         = "Clearing your Trakt Library";
            progressDialog.ShowDialog(ProgressDialog.PROGDLG.Modal, ProgressDialog.PROGDLG.NoMinimize, ProgressDialog.PROGDLG.NoTime);

            //Movies
            if (mode == TraktClearingModes.all || mode == TraktClearingModes.movies)
            {
                TraktLogger.Info("Removing Movies from Trakt");
                TraktLogger.Info("NOTE: WILL NOT REMOVE SCROBBLED MOVIES DUE TO API LIMITATION");
                progressDialog.Line2 = "Getting movies for user";

                TraktLogger.Info("Getting user {0}'s movies from trakt", TraktSettings.Username);
                var movies = TraktAPI.TraktAPI.GetAllMoviesForUser(TraktSettings.Username).ToList();

                var           syncData = TraktHandlers.BasicHandler.CreateMovieSyncData(movies);
                TraktResponse response = null;

                if (clearSeen)
                {
                    TraktLogger.Info("First removing movies from seen");
                    progressDialog.Line2 = "Setting seen movies as unseen";
                    response             = TraktAPI.TraktAPI.SyncMovieLibrary(syncData, TraktSyncModes.unseen);
                    TraktLogger.LogTraktResponse(response);
                }

                TraktLogger.Info("Now removing movies from library");
                progressDialog.Line2 = "Removing movies from library";
                response             = TraktAPI.TraktAPI.SyncMovieLibrary(syncData, TraktSyncModes.unlibrary);
                TraktLogger.LogTraktResponse(response);

                TraktLogger.Info("Removed all movies possible, some manual clean up may be required");
            }
            if (mode == TraktClearingModes.all)
            {
                progressDialog.Value = 15;
            }
            if (progressDialog.HasUserCancelled)
            {
                TraktLogger.Info("Cancelling Library Clearing");
                progressDialog.CloseDialog();
                return;
            }
            //Episodes
            if (mode == TraktClearingModes.all || mode == TraktClearingModes.episodes)
            {
                TraktLogger.Info("Removing Shows from Trakt");
                TraktLogger.Info("NOTE: WILL NOT REMOVE SCROBBLED SHOWS DUE TO API LIMITATION");

                if (clearSeen)
                {
                    TraktLogger.Info("First removing shows from seen");
                    progressDialog.Line2 = "Getting Watched Episodes from Trakt";

                    TraktLogger.Info("Getting user {0}'s 'watched/seen' episodes from trakt", TraktSettings.Username);
                    var watchedEpisodes = TraktAPI.TraktAPI.GetWatchedEpisodesForUser(TraktSettings.Username);
                    if (watchedEpisodes != null)
                    {
                        foreach (var series in watchedEpisodes.ToList())
                        {
                            TraktLogger.Info("Removing '{0}' from seen", series.ToString());
                            progressDialog.Line2 = string.Format("Setting {0} as unseen", series.ToString());
                            var response = TraktAPI.TraktAPI.SyncEpisodeLibrary(TraktHandlers.BasicHandler.CreateEpisodeSyncData(series), TraktSyncModes.unseen);
                            TraktLogger.LogTraktResponse(response);
                            System.Threading.Thread.Sleep(500);
                            if (progressDialog.HasUserCancelled)
                            {
                                TraktLogger.Info("Cancelling Library Clearing");
                                progressDialog.CloseDialog();
                                return;
                            }
                        }
                    }
                }
                progressDialog.Value = 85;
                TraktLogger.Info("Now removing shows from library");
                progressDialog.Line2 = "Getting Library Episodes from Trakt";

                TraktLogger.Info("Getting user {0}'s 'library' episodes from trakt", TraktSettings.Username);
                var libraryEpisodes = TraktAPI.TraktAPI.GetLibraryEpisodesForUser(TraktSettings.Username);
                if (libraryEpisodes != null)
                {
                    foreach (var series in libraryEpisodes.ToList())
                    {
                        TraktLogger.Info("Removing '{0}' from library", series.ToString());
                        progressDialog.Line2 = string.Format("Removing {0} from library", series.ToString());
                        var response = TraktAPI.TraktAPI.SyncEpisodeLibrary(TraktHandlers.BasicHandler.CreateEpisodeSyncData(series), TraktSyncModes.unlibrary);
                        TraktLogger.LogTraktResponse(response);
                        System.Threading.Thread.Sleep(500);
                        if (progressDialog.HasUserCancelled)
                        {
                            TraktLogger.Info("Cancelling Library Clearing");
                            progressDialog.CloseDialog();
                            return;
                        }
                    }
                }
                TraktLogger.Info("Removed all shows possible, some manual clean up may be required");
            }
            progressDialog.Value = 100;
            progressDialog.CloseDialog();
        }
Exemplo n.º 13
0
        private void StartSync()
        {
            SetSyncControlProperties(true);

            var syncThread = new Thread(() =>
            {
                if (TraktSettings.AccountStatus != ConnectionState.Connected)
                {
                    // stop sync
                    SetSyncControlProperties(false);
                    TraktSettings.AccountStatus = ConnectionState.Pending;
                    return;
                }

                TraktLogger.Info("Library and Playback Sync started for all enabled plugins");

                // get data from online and store in cache so its readily available for plugin sync
                // data will also be used in user activity feed on the dashboard
                if (!TraktCache.RefreshData())
                {
                    return;
                }

                foreach (var item in clbPlugins.CheckedItems)
                {
                    try
                    {
                        switch (item.ToString())
                        {
                        case "Moving Pictures":
                            var movingPictures = new MovingPictures(TraktSettings.MovingPictures);
                            movingPictures.SyncLibrary();
                            movingPictures.SyncProgress();
                            break;

                        case "MP-TVSeries":
                            var tvSeries = new TVSeries(TraktSettings.TVSeries);
                            tvSeries.SyncLibrary();
                            tvSeries.SyncProgress();
                            break;

                        case "My Videos":
                            var myVideos = new MyVideos(TraktSettings.MyVideos);
                            myVideos.SyncLibrary();
                            myVideos.SyncProgress();
                            break;

                        case "My Films":
                            var myFilms = new MyFilmsHandler(TraktSettings.MyFilms);
                            myFilms.SyncLibrary();
                            myFilms.SyncProgress();
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        TraktLogger.Error("Error synchronising library, Plugin = '{0}', Error = '{1}'", item.ToString(), ex.Message);
                        continue;
                    }
                }

                // save user activity cache
                TraktCache.Save();

                TraktLogger.Info("Library and Playback Sync completed for all enabled plugins");
                SetSyncControlProperties(false);

                if (SilentMode || AutoCloseAfterSync)
                {
                    CloseConfig();
                }
            })
            {
                Name         = "Sync",
                IsBackground = true
            };

            syncThread.Start();
        }
Exemplo n.º 14
0
        private void MovieSelect_Load(object sender, EventArgs e)
        {
            //If MovingPictures is selected
            if (TraktSettings.MovingPictures > -1 && File.Exists(Path.Combine(Config.GetFolder(Config.Dir.Plugins), @"Windows\MovingPictures.dll")))
            {
                //Load the Movies from Moving Pictures
                try
                {
                    LoadMoviesFromMovingPictures();
                }
                catch (Exception)
                {
                    TraktLogger.Info("Tried to load MovingPictures but failed, check minimum requirements are met!");
                }
            }

            //If MyVideos is selected, always installed
            if (TraktSettings.MyVideos > -1)
            {
                string sql = "SELECT movieinfo.strTitle, path.strPath, files.strFilename " +
                             "FROM movieInfo " +
                             "LEFT JOIN files " +
                             "ON movieInfo.idMovie=files.idMovie " +
                             "LEFT JOIN path " +
                             "ON files.idPath=path.idPath " +
                             "ORDER BY strTitle";

                SQLiteResultSet results = VideoDatabase.GetResults(sql);

                for (int row = 0; row < results.Rows.Count; row++)
                {
                    string title    = DatabaseUtility.Get(results, row, 0);
                    string filename = string.Concat(DatabaseUtility.Get(results, row, 1), DatabaseUtility.Get(results, row, 2));
                    if (string.IsNullOrEmpty(filename))
                    {
                        continue;
                    }

                    if (!_blockedFilenames.Contains(filename))
                    {
                        unCheckedMovies.Add(new MovieSelectItem {
                            MovieTitle = title, Filename = new List <string> {
                                filename
                            }
                        });
                    }
                    else
                    {
                        checkedMovies.Add(new MovieSelectItem {
                            MovieTitle = title, Filename = new List <string> {
                                filename
                            }
                        });
                    }
                }
            }

            //If MyFilms is selected
            if (TraktSettings.MyFilms > -1 && File.Exists(Path.Combine(Config.GetFolder(Config.Dir.Plugins), @"Windows\MyFilms.dll")))
            {
                //Load the Movies from MyFilms
                try
                {
                    LoadMoviesFromMyFilms();
                }
                catch (Exception)
                {
                    TraktLogger.Info("Tried to load My Films but failed, check minimum requirements are met!");
                }
            }

            foreach (MovieSelectItem movie in checkedMovies)
            {
                if (!checkedListBoxMovies.Items.Contains(movie))
                {
                    checkedListBoxMovies.Items.Add(movie, true);
                }
            }

            foreach (MovieSelectItem movie in unCheckedMovies)
            {
                if (!checkedListBoxMovies.Items.Contains(movie))
                {
                    checkedListBoxMovies.Items.Add(movie, false);
                }
            }

            checkedListBoxMovies.ItemCheck += new ItemCheckEventHandler(checkedListBoxMovies_ItemCheck);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Saves the Settings
        /// </summary>
        public static void saveSettings()
        {
            TraktLogger.Info("Saving Settings");
            using (Settings xmlwriter = new MPSettings())
            {
                xmlwriter.SetValue(cTrakt, cUsername, Username);
                xmlwriter.SetValue(cTrakt, cPassword, Password);
                xmlwriter.SetValue(cTrakt, cUserLogins, UserLogins.ToJSON());
                xmlwriter.SetValue(cTrakt, cMovingPictures, MovingPictures);
                xmlwriter.SetValue(cTrakt, cTVSeries, TVSeries);
                xmlwriter.SetValue(cTrakt, cMyVideos, MyVideos);
                xmlwriter.SetValue(cTrakt, cMyFilms, MyFilms);
                xmlwriter.SetValue(cTrakt, cOnlineVideos, OnlineVideos);
                xmlwriter.SetValue(cTrakt, cMyAnime, MyAnime);
                xmlwriter.SetValue(cTrakt, cMyTVRecordings, MyTVRecordings);
                xmlwriter.SetValue(cTrakt, cMyTVLive, MyTVLive);
                xmlwriter.SetValue(cTrakt, cForTheRecordRecordings, ForTheRecordRecordings);
                xmlwriter.SetValue(cTrakt, cForTheRecordTVLive, ForTheRecordTVLive);
                xmlwriter.SetValue(cTrakt, cArgusRecordings, ArgusRecordings);
                xmlwriter.SetValue(cTrakt, cArgusTVLive, ArgusTVLive);
                xmlwriter.SetValueAsBool(cTrakt, cKeepTraktLibraryClean, KeepTraktLibraryClean);
                xmlwriter.SetValue(cTrakt, cBlockedFilenames, BlockedFilenames.ToJSON());
                xmlwriter.SetValue(cTrakt, cBlockedFolders, BlockedFolders.ToJSON());
                xmlwriter.SetValue(cTrakt, cSkippedMovies, SkippedMovies.ToJSON());
                xmlwriter.SetValue(cTrakt, cAlreadyExistMovies, AlreadyExistMovies.ToJSON());
                xmlwriter.SetValue(cTrakt, cSyncTimerLength, SyncTimerLength);
                xmlwriter.SetValue(cTrakt, cSyncStartDelay, SyncStartDelay);
                xmlwriter.SetValue(cTrakt, cTrendingMoviesDefaultLayout, TrendingMoviesDefaultLayout);
                xmlwriter.SetValue(cTrakt, cTrendingShowsDefaultLayout, TrendingShowsDefaultLayout);
                xmlwriter.SetValue(cTrakt, cRecommendedMoviesDefaultLayout, RecommendedMoviesDefaultLayout);
                xmlwriter.SetValue(cTrakt, cRecommendedShowsDefaultLayout, RecommendedShowsDefaultLayout);
                xmlwriter.SetValue(cTrakt, cWatchListMoviesDefaultLayout, WatchListMoviesDefaultLayout);
                xmlwriter.SetValue(cTrakt, cWatchListShowsDefaultLayout, WatchListShowsDefaultLayout);
                xmlwriter.SetValue(cTrakt, cWatchListEpisodesDefaultLayout, WatchListEpisodesDefaultLayout);
                xmlwriter.SetValue(cTrakt, cRelatedMoviesDefaultLayout, RelatedMoviesDefaultLayout);
                xmlwriter.SetValue(cTrakt, cRelatedShowsDefaultLayout, RelatedShowsDefaultLayout);
                xmlwriter.SetValue(cTrakt, cListsDefaultLayout, ListsDefaultLayout);
                xmlwriter.SetValue(cTrakt, cListItemsDefaultLayout, ListItemsDefaultLayout);
                xmlwriter.SetValue(cTrakt, cShowSeasonsDefaultLayout, ShowSeasonsDefaultLayout);
                xmlwriter.SetValue(cTrakt, cSeasonEpisodesDefaultLayout, SeasonEpisodesDefaultLayout);
                xmlwriter.SetValue(cTrakt, cDefaultCalendarView, DefaultCalendarView);
                xmlwriter.SetValue(cTrakt, cDefaultCalendarStartDate, DefaultCalendarStartDate);
                xmlwriter.SetValueAsBool(cTrakt, cDownloadFullSizeFanart, DownloadFullSizeFanart);
                xmlwriter.SetValueAsBool(cTrakt, cDownloadFanart, DownloadFanart);
                xmlwriter.SetValue(cTrakt, cWebRequestCacheMinutes, WebRequestCacheMinutes);
                xmlwriter.SetValue(cTrakt, cWebRequestTimeout, WebRequestTimeout);
                xmlwriter.SetValueAsBool(cTrakt, cGetFriendRequestsOnStartup, GetFriendRequestsOnStartup);
                xmlwriter.SetValue(cTrakt, cMovingPicturesCategoryId, MovingPicturesCategoryId);
                xmlwriter.SetValueAsBool(cTrakt, cMovingPicturesCategories, MovingPicturesCategories);
                xmlwriter.SetValue(cTrakt, cMovingPicturesFilterId, MovingPicturesFiltersId);
                xmlwriter.SetValueAsBool(cTrakt, cMovingPicturesFilters, MovingPicturesFilters);
                xmlwriter.SetValueAsBool(cTrakt, cCalendarHideTVShowsInWatchList, CalendarHideTVShowsInWatchList);
                xmlwriter.SetValueAsBool(cTrakt, cHideWatchedRelatedMovies, HideWatchedRelatedMovies);
                xmlwriter.SetValueAsBool(cTrakt, cHideWatchedRelatedShows, HideWatchedRelatedShows);
                xmlwriter.SetValueAsBool(cTrakt, cHideSpoilersOnShouts, HideSpoilersOnShouts);
                xmlwriter.SetValueAsBool(cTrakt, cShowAdvancedRatingsDialog, ShowAdvancedRatingsDialog);
                xmlwriter.SetValueAsBool(cTrakt, cSyncRatings, SyncRatings);
                xmlwriter.SetValueAsBool(cTrakt, cShowRateDialogOnWatched, ShowRateDialogOnWatched);
                xmlwriter.SetValueAsBool(cTrakt, cShowCommunityActivity, ShowCommunityActivity);
                xmlwriter.SetValueAsBool(cTrakt, cIncludeMeInFriendsActivity, IncludeMeInFriendsActivity);
                xmlwriter.SetValue(cTrakt, cLastActivityLoad, LastActivityLoad.ToJSON());
                xmlwriter.SetValue(cTrakt, cLastTrendingShows, (LastTrendingShows ?? "{}".FromJSONArray <TraktTrendingShow>()).ToList().ToJSON());
                xmlwriter.SetValue(cTrakt, cLastTrendingMovies, (LastTrendingMovies ?? "{}".FromJSONArray <TraktTrendingMovie>()).ToList().ToJSON());
                xmlwriter.SetValue(cTrakt, cLastStatistics, LastStatistics.ToJSON());
                xmlwriter.SetValue(cTrakt, cDashboardActivityPollInterval, DashboardActivityPollInterval);
                xmlwriter.SetValue(cTrakt, cDashboardTrendingPollInterval, DashboardTrendingPollInterval);
                xmlwriter.SetValue(cTrakt, cDashboardLoadDelay, DashboardLoadDelay);
                xmlwriter.SetValueAsBool(cTrakt, cDashboardMovieTrendingActive, DashboardMovieTrendingActive);
                xmlwriter.SetValue(cTrakt, cMovieRecommendationGenre, MovieRecommendationGenre);
                xmlwriter.SetValueAsBool(cTrakt, cMovieRecommendationHideCollected, MovieRecommendationHideCollected);
                xmlwriter.SetValueAsBool(cTrakt, cMovieRecommendationHideWatchlisted, MovieRecommendationHideWatchlisted);
                xmlwriter.SetValue(cTrakt, cMovieRecommendationStartYear, MovieRecommendationStartYear);
                xmlwriter.SetValue(cTrakt, cMovieRecommendationEndYear, MovieRecommendationEndYear);
                xmlwriter.SetValue(cTrakt, cShowRecommendationGenre, ShowRecommendationGenre);
                xmlwriter.SetValueAsBool(cTrakt, cShowRecommendationHideCollected, ShowRecommendationHideCollected);
                xmlwriter.SetValueAsBool(cTrakt, cShowRecommendationHideWatchlisted, ShowRecommendationHideWatchlisted);
                xmlwriter.SetValue(cTrakt, cShowRecommendationStartYear, ShowRecommendationStartYear);
                xmlwriter.SetValue(cTrakt, cShowRecommendationEndYear, ShowRecommendationEndYear);
                xmlwriter.SetValue(cTrakt, cSortByRecommendedMovies, SortByRecommendedMovies.ToJSON());
                xmlwriter.SetValue(cTrakt, cSortByRecommendedShows, SortByRecommendedShows.ToJSON());
                xmlwriter.SetValue(cTrakt, cSortByTrendingMovies, SortByTrendingMovies.ToJSON());
                xmlwriter.SetValue(cTrakt, cSortByTrendingShows, SortByTrendingShows.ToJSON());
                xmlwriter.SetValue(cTrakt, cSortByWatchListMovies, SortByWatchListMovies.ToJSON());
                xmlwriter.SetValue(cTrakt, cSortByWatchListShows, SortByWatchListShows.ToJSON());
                xmlwriter.SetValueAsBool(cTrakt, cEnableJumpToForTVShows, EnableJumpToForTVShows);
                xmlwriter.SetValueAsBool(cTrakt, cMyFilmsCategories, MyFilmsCategories);
                xmlwriter.SetValueAsBool(cTrakt, cSortSeasonsAscending, SortSeasonsAscending);
                xmlwriter.SetValueAsBool(cTrakt, cRememberLastSelectedActivity, RememberLastSelectedActivity);
                xmlwriter.SetValueAsBool(cTrakt, cShowRateDlgForPlaylists, ShowRateDlgForPlaylists);
                xmlwriter.SetValue(cTrakt, cDefaultTVShowTrailerSite, DefaultTVShowTrailerSite);
                xmlwriter.SetValue(cTrakt, cDefaultMovieTrailerSite, DefaultMovieTrailerSite);
                xmlwriter.SetValueAsBool(cTrakt, cTrendingMoviesHideWatched, TrendingMoviesHideWatched);
                xmlwriter.SetValueAsBool(cTrakt, cTrendingMoviesHideWatchlisted, TrendingMoviesHideWatchlisted);
                xmlwriter.SetValueAsBool(cTrakt, cTrendingMoviesHideCollected, TrendingMoviesHideCollected);
                xmlwriter.SetValueAsBool(cTrakt, cTrendingMoviesHideRated, TrendingMoviesHideRated);
                xmlwriter.SetValueAsBool(cTrakt, cTrendingShowsHideWatched, TrendingShowsHideWatched);
                xmlwriter.SetValueAsBool(cTrakt, cTrendingShowsHideWatchlisted, TrendingShowsHideWatchlisted);
                xmlwriter.SetValueAsBool(cTrakt, cTrendingShowsHideCollected, TrendingShowsHideCollected);
                xmlwriter.SetValueAsBool(cTrakt, cTrendingShowsHideRated, TrendingShowsHideRated);
                xmlwriter.SetValue(cTrakt, cShowsInCollection, ShowsInCollection.ToJSON());
            }

            Settings.SaveCache();
        }
Exemplo n.º 16
0
 /// <summary>
 /// Loads the Settings
 /// </summary>
 public static void loadSettings()
 {
     TraktLogger.Info("Loading Local Settings");
     using (Settings xmlreader = new MPSettings())
     {
         Username                           = xmlreader.GetValueAsString(cTrakt, cUsername, "");
         Password                           = xmlreader.GetValueAsString(cTrakt, cPassword, "");
         UserLogins                         = xmlreader.GetValueAsString(cTrakt, cUserLogins, "").FromJSONArray <TraktAuthentication>().ToList();
         MovingPictures                     = xmlreader.GetValueAsInt(cTrakt, cMovingPictures, -1);
         TVSeries                           = xmlreader.GetValueAsInt(cTrakt, cTVSeries, -1);
         MyVideos                           = xmlreader.GetValueAsInt(cTrakt, cMyVideos, -1);
         MyFilms                            = xmlreader.GetValueAsInt(cTrakt, cMyFilms, -1);
         OnlineVideos                       = xmlreader.GetValueAsInt(cTrakt, cOnlineVideos, -1);
         MyAnime                            = xmlreader.GetValueAsInt(cTrakt, cMyAnime, -1);
         MyTVRecordings                     = xmlreader.GetValueAsInt(cTrakt, cMyTVRecordings, -1);
         MyTVLive                           = xmlreader.GetValueAsInt(cTrakt, cMyTVLive, -1);
         ForTheRecordRecordings             = xmlreader.GetValueAsInt(cTrakt, cForTheRecordRecordings, -1);
         ForTheRecordTVLive                 = xmlreader.GetValueAsInt(cTrakt, cForTheRecordTVLive, -1);
         ArgusRecordings                    = xmlreader.GetValueAsInt(cTrakt, cArgusRecordings, -1);
         ArgusTVLive                        = xmlreader.GetValueAsInt(cTrakt, cArgusTVLive, -1);
         KeepTraktLibraryClean              = xmlreader.GetValueAsBool(cTrakt, cKeepTraktLibraryClean, false);
         BlockedFilenames                   = xmlreader.GetValueAsString(cTrakt, cBlockedFilenames, "").FromJSONArray <string>().ToList();
         BlockedFolders                     = xmlreader.GetValueAsString(cTrakt, cBlockedFolders, "").FromJSONArray <string>().ToList();
         SkippedMovies                      = xmlreader.GetValueAsString(cTrakt, cSkippedMovies, "{}").FromJSON <SyncMovieCheck>();
         AlreadyExistMovies                 = xmlreader.GetValueAsString(cTrakt, cAlreadyExistMovies, "{}").FromJSON <SyncMovieCheck>();
         LogLevel                           = xmlreader.GetValueAsInt("general", "loglevel", 1);
         SyncTimerLength                    = xmlreader.GetValueAsInt(cTrakt, cSyncTimerLength, 86400000);
         SyncStartDelay                     = xmlreader.GetValueAsInt(cTrakt, cSyncStartDelay, 0);
         TrendingMoviesDefaultLayout        = xmlreader.GetValueAsInt(cTrakt, cTrendingMoviesDefaultLayout, 0);
         TrendingShowsDefaultLayout         = xmlreader.GetValueAsInt(cTrakt, cTrendingShowsDefaultLayout, 0);
         RecommendedMoviesDefaultLayout     = xmlreader.GetValueAsInt(cTrakt, cRecommendedMoviesDefaultLayout, 0);
         RecommendedShowsDefaultLayout      = xmlreader.GetValueAsInt(cTrakt, cRecommendedShowsDefaultLayout, 0);
         WatchListMoviesDefaultLayout       = xmlreader.GetValueAsInt(cTrakt, cWatchListMoviesDefaultLayout, 0);
         WatchListShowsDefaultLayout        = xmlreader.GetValueAsInt(cTrakt, cWatchListShowsDefaultLayout, 0);
         WatchListEpisodesDefaultLayout     = xmlreader.GetValueAsInt(cTrakt, cWatchListEpisodesDefaultLayout, 0);
         ListsDefaultLayout                 = xmlreader.GetValueAsInt(cTrakt, cListsDefaultLayout, 0);
         ListItemsDefaultLayout             = xmlreader.GetValueAsInt(cTrakt, cListItemsDefaultLayout, 0);
         RelatedMoviesDefaultLayout         = xmlreader.GetValueAsInt(cTrakt, cRelatedMoviesDefaultLayout, 0);
         RelatedShowsDefaultLayout          = xmlreader.GetValueAsInt(cTrakt, cRelatedShowsDefaultLayout, 0);
         ShowSeasonsDefaultLayout           = xmlreader.GetValueAsInt(cTrakt, cShowSeasonsDefaultLayout, 0);
         SeasonEpisodesDefaultLayout        = xmlreader.GetValueAsInt(cTrakt, cSeasonEpisodesDefaultLayout, 0);
         DefaultCalendarView                = xmlreader.GetValueAsInt(cTrakt, cDefaultCalendarView, 0);
         DefaultCalendarStartDate           = xmlreader.GetValueAsInt(cTrakt, cDefaultCalendarStartDate, 0);
         DownloadFullSizeFanart             = xmlreader.GetValueAsBool(cTrakt, cDownloadFullSizeFanart, false);
         DownloadFanart                     = xmlreader.GetValueAsBool(cTrakt, cDownloadFanart, true);
         WebRequestCacheMinutes             = xmlreader.GetValueAsInt(cTrakt, cWebRequestCacheMinutes, 15);
         WebRequestTimeout                  = xmlreader.GetValueAsInt(cTrakt, cWebRequestTimeout, 30000);
         GetFriendRequestsOnStartup         = xmlreader.GetValueAsBool(cTrakt, cGetFriendRequestsOnStartup, true);
         MovingPicturesCategoryId           = xmlreader.GetValueAsInt(cTrakt, cMovingPicturesCategoryId, -1);
         MovingPicturesCategories           = xmlreader.GetValueAsBool(cTrakt, cMovingPicturesCategories, false);
         MovingPicturesFiltersId            = xmlreader.GetValueAsInt(cTrakt, cMovingPicturesFilterId, -1);
         MovingPicturesFilters              = xmlreader.GetValueAsBool(cTrakt, cMovingPicturesFilters, false);
         CalendarHideTVShowsInWatchList     = xmlreader.GetValueAsBool(cTrakt, cCalendarHideTVShowsInWatchList, false);
         HideWatchedRelatedMovies           = xmlreader.GetValueAsBool(cTrakt, cHideWatchedRelatedMovies, false);
         HideWatchedRelatedShows            = xmlreader.GetValueAsBool(cTrakt, cHideWatchedRelatedShows, false);
         HideSpoilersOnShouts               = xmlreader.GetValueAsBool(cTrakt, cHideSpoilersOnShouts, false);
         ShowAdvancedRatingsDialog          = xmlreader.GetValueAsBool(cTrakt, cShowAdvancedRatingsDialog, false);
         SyncRatings                        = xmlreader.GetValueAsBool(cTrakt, cSyncRatings, false);
         ShowRateDialogOnWatched            = xmlreader.GetValueAsBool(cTrakt, cShowRateDialogOnWatched, false);
         ShowCommunityActivity              = xmlreader.GetValueAsBool(cTrakt, cShowCommunityActivity, false);
         IncludeMeInFriendsActivity         = xmlreader.GetValueAsBool(cTrakt, cIncludeMeInFriendsActivity, false);
         LastActivityLoad                   = xmlreader.GetValueAsString(cTrakt, cLastActivityLoad, "{}").FromJSON <TraktActivity>();
         LastTrendingMovies                 = xmlreader.GetValueAsString(cTrakt, cLastTrendingMovies, "{}").FromJSONArray <TraktTrendingMovie>();
         LastTrendingShows                  = xmlreader.GetValueAsString(cTrakt, cLastTrendingShows, "{}").FromJSONArray <TraktTrendingShow>();
         LastStatistics                     = xmlreader.GetValueAsString(cTrakt, cLastStatistics, null).FromJSON <TraktUserProfile.Statistics>();
         DashboardActivityPollInterval      = xmlreader.GetValueAsInt(cTrakt, cDashboardActivityPollInterval, 15000);
         DashboardTrendingPollInterval      = xmlreader.GetValueAsInt(cTrakt, cDashboardTrendingPollInterval, 300000);
         DashboardLoadDelay                 = xmlreader.GetValueAsInt(cTrakt, cDashboardLoadDelay, 500);
         DashboardMovieTrendingActive       = xmlreader.GetValueAsBool(cTrakt, cDashboardMovieTrendingActive, false);
         MovieRecommendationGenre           = xmlreader.GetValueAsString(cTrakt, cMovieRecommendationGenre, "All");
         MovieRecommendationHideCollected   = xmlreader.GetValueAsBool(cTrakt, cMovieRecommendationHideCollected, false);
         MovieRecommendationHideWatchlisted = xmlreader.GetValueAsBool(cTrakt, cMovieRecommendationHideWatchlisted, false);
         MovieRecommendationStartYear       = xmlreader.GetValueAsInt(cTrakt, cMovieRecommendationStartYear, 0);
         MovieRecommendationEndYear         = xmlreader.GetValueAsInt(cTrakt, cMovieRecommendationEndYear, 0);
         ShowRecommendationGenre            = xmlreader.GetValueAsString(cTrakt, cShowRecommendationGenre, "All");
         ShowRecommendationHideCollected    = xmlreader.GetValueAsBool(cTrakt, cShowRecommendationHideCollected, false);
         ShowRecommendationHideWatchlisted  = xmlreader.GetValueAsBool(cTrakt, cShowRecommendationHideWatchlisted, false);
         ShowRecommendationStartYear        = xmlreader.GetValueAsInt(cTrakt, cShowRecommendationStartYear, 0);
         ShowRecommendationEndYear          = xmlreader.GetValueAsInt(cTrakt, cShowRecommendationEndYear, 0);
         SortByRecommendedMovies            = xmlreader.GetValueAsString(cTrakt, cSortByRecommendedMovies, "{\"Field\": 0,\"Direction\": 0}").FromJSON <SortBy>();
         SortByRecommendedShows             = xmlreader.GetValueAsString(cTrakt, cSortByRecommendedShows, "{\"Field\": 0,\"Direction\": 0}").FromJSON <SortBy>();
         SortByTrendingMovies               = xmlreader.GetValueAsString(cTrakt, cSortByTrendingMovies, "{\"Field\": 5,\"Direction\": 1}").FromJSON <SortBy>();
         SortByTrendingShows                = xmlreader.GetValueAsString(cTrakt, cSortByTrendingShows, "{\"Field\": 5,\"Direction\": 1}").FromJSON <SortBy>();
         SortByWatchListMovies              = xmlreader.GetValueAsString(cTrakt, cSortByWatchListMovies, "{\"Field\": 6,\"Direction\": 1}").FromJSON <SortBy>();
         SortByWatchListShows               = xmlreader.GetValueAsString(cTrakt, cSortByWatchListShows, "{\"Field\": 6,\"Direction\": 1}").FromJSON <SortBy>();
         EnableJumpToForTVShows             = xmlreader.GetValueAsBool(cTrakt, cEnableJumpToForTVShows, false);
         MyFilmsCategories                  = xmlreader.GetValueAsBool(cTrakt, cMyFilmsCategories, false);
         SortSeasonsAscending               = xmlreader.GetValueAsBool(cTrakt, cSortSeasonsAscending, false);
         RememberLastSelectedActivity       = xmlreader.GetValueAsBool(cTrakt, cRememberLastSelectedActivity, true);
         MovPicsRatingDlgDelay              = xmlreader.GetValueAsInt(cTrakt, cMovPicsRatingDlgDelay, 500);
         ShowRateDlgForPlaylists            = xmlreader.GetValueAsBool(cTrakt, cShowRateDlgForPlaylists, true);
         DefaultTVShowTrailerSite           = xmlreader.GetValueAsString(cTrakt, cDefaultTVShowTrailerSite, "YouTube");
         DefaultMovieTrailerSite            = xmlreader.GetValueAsString(cTrakt, cDefaultMovieTrailerSite, "IMDb Movie Trailers");
         TrendingMoviesHideWatched          = xmlreader.GetValueAsBool(cTrakt, cTrendingMoviesHideWatched, false);
         TrendingMoviesHideWatchlisted      = xmlreader.GetValueAsBool(cTrakt, cTrendingMoviesHideWatchlisted, false);
         TrendingMoviesHideCollected        = xmlreader.GetValueAsBool(cTrakt, cTrendingMoviesHideCollected, false);
         TrendingMoviesHideRated            = xmlreader.GetValueAsBool(cTrakt, cTrendingMoviesHideRated, false);
         TrendingShowsHideWatched           = xmlreader.GetValueAsBool(cTrakt, cTrendingShowsHideWatched, false);
         TrendingShowsHideWatchlisted       = xmlreader.GetValueAsBool(cTrakt, cTrendingShowsHideWatchlisted, false);
         TrendingShowsHideCollected         = xmlreader.GetValueAsBool(cTrakt, cTrendingShowsHideCollected, false);
         TrendingShowsHideRated             = xmlreader.GetValueAsBool(cTrakt, cTrendingShowsHideRated, false);
         ShowsInCollection                  = xmlreader.GetValueAsString(cTrakt, cShowsInCollection, "").FromJSONArray <string>().ToList();
     }
 }