Beispiel #1
0
        /// <summary>
        /// Saves the Settings
        /// </summary>
        public static void SaveSettings()
        {
            Logger.Debug("Saving IMDb+ options to file.");

            #region Scraper
            XmlWriter xmlWriter = new XmlWriter();
            if (!xmlWriter.Load(OptionsFile))
            {
                if (File.Exists(OptionsFile))
                {
                    try
                    {
                        File.Delete(OptionsFile);
                    }
                    catch (Exception e)
                    {
                        Logger.Error("Error deleting file: '{0}'", OptionsFile);
                        Logger.Error("Exception: {0}", e.Message);
                        return;
                    }
                }

                // create it
                Logger.Info("Creating new IMDb+ options file.");
                xmlWriter.CreateXmlConfigFile(OptionsFile);
                xmlWriter.Load(OptionsFile);
            }

            xmlWriter.SetOptionsEntry(cOriginalTitle, "01", OriginalTitle.ToString());
            xmlWriter.SetOptionsEntry(cForeignTitle, "02", ForeignTitle.ToString());
            xmlWriter.SetOptionsEntry(cForeignFirst, "03", ForeignFirst.ToString());
            xmlWriter.SetOptionsEntry(cUkRating, "04", UkRating.ToString());
            xmlWriter.SetOptionsEntry(cIMDbScore, "05", IMDbScore.ToString());
            xmlWriter.SetOptionsEntry(cIMDbMetaScore, "06", IMDbMetaScore.ToString());
            xmlWriter.SetOptionsEntry(cLongSummary, "07", LongSummary.ToString());
            xmlWriter.SetOptionsEntry(cRottenMeter, "08", RottenMeter.ToString());
            xmlWriter.SetOptionsEntry(cRottenAverage, "09", RottenAverage.ToString());
            xmlWriter.SetOptionsEntry(cRottenTopCritics, "10", RottenTopCritics.ToString());
            xmlWriter.SetOptionsEntry(cSpecialEdition, "11", SpecialEdition.ToString());
            xmlWriter.SetOptionsEntry(cRenameTitles, "12", RenameTitles.ToString());
            xmlWriter.SetOptionsEntry(cSingleScore, "13", SingleScore.ToString());
            xmlWriter.SetOptionsEntry(cMinIMDbVotes, "14", MinIMDbVotes.ToString());
            xmlWriter.SetOptionsEntry(cRefreshAllFields, "15", RefreshAllFields.ToString());
            xmlWriter.SetOptionsEntry(cOneWriterDirector, "16", OneWriterDirector.ToString());
            xmlWriter.SetOptionsEntry(cRemoveFirstRoman, "17", RemoveFirstRoman.ToString());
            xmlWriter.SetOptionsEntry(cFixMissingSummary, "18", FixMissingSummary.ToString());

            xmlWriter.SetOptionsEntry(cRatings, "94", Ratings);
            xmlWriter.SetOptionsEntry(cSecondaryEnglishTitle, "95", SecondaryEnglishTitle.ToString());
            xmlWriter.SetOptionsEntry(cSecondarySummary, "96", SecondarySummary.ToString());
            xmlWriter.SetOptionsEntry(cSecondaryDetails, "97", SecondaryDetails);
            xmlWriter.SetOptionsEntry(cCountryFilter, "98", CountryFilter);
            xmlWriter.SetOptionsEntry(cLanguageFilter, "99", LanguageFilter);

            // save file
            xmlWriter.Save(OptionsFile);
            #endregion

            #region Plugin
            using (Settings xmlwriter = new MPSettings())
            {
                xmlwriter.SetValue(cSection, cSyncInterval, SyncInterval.ToString());
                xmlwriter.SetValueAsBool(cSection, cSyncOnStartup, SyncOnStartup);
                xmlwriter.SetValue(cSection, cSyncLastDateTime, SyncLastDateTime.ToString());
                xmlwriter.SetValueAsBool(cSection, cDisableNotifications, DisableNotifications);
                xmlwriter.SetValue(cSection, cMoviesRefreshed, MoviesRefreshed.ToJSON());
            }
            Settings.SaveCache();
            #endregion
        }
Beispiel #2
0
        /// <summary>
        /// Loads the Settings
        /// </summary>
        public static void LoadSettings()
        {
            Logger.Debug("Loading IMDb+ options from file.");

            #region Scraper
            XmlReader xmlReader = new XmlReader();
            if (!xmlReader.Load(OptionsFile))
            {
                Logger.Error("Error opening IMDb+ Options file, will restore defaults.");                
            }
            
            OriginalTitle = xmlReader.GetOptionValueAsBool(cOriginalTitle, false);
            ForeignTitle = xmlReader.GetOptionValueAsBool(cForeignTitle, false);
            ForeignFirst = xmlReader.GetOptionValueAsBool(cForeignFirst, false);
            SpecialEdition = xmlReader.GetOptionValueAsBool(cSpecialEdition, true);
            RenameTitles = xmlReader.GetOptionValueAsBool(cRenameTitles, true);
            SingleScore = xmlReader.GetOptionValueAsBool(cSingleScore, false);
            IMDbScore = xmlReader.GetOptionValueAsBool(cIMDbScore, false);
            IMDbMetaScore = xmlReader.GetOptionValueAsBool(cIMDbMetaScore, false);
            RottenMeter = xmlReader.GetOptionValueAsBool(cRottenMeter, false);
            RottenAverage = xmlReader.GetOptionValueAsBool(cRottenAverage, false);
            RottenTopCritics = xmlReader.GetOptionValueAsBool(cRottenTopCritics, false);
            MinIMDbVotes = xmlReader.GetOptionValueAsBool(cMinIMDbVotes, false);
            LongSummary = xmlReader.GetOptionValueAsBool(cLongSummary, false);
            UkRating = xmlReader.GetOptionValueAsBool(cUkRating, false);
            OneWriterDirector = xmlReader.GetOptionValueAsBool(cOneWriterDirector, false);
            FixMissingSummary = xmlReader.GetOptionValueAsBool(cFixMissingSummary, false);
            RemoveFirstRoman = xmlReader.GetOptionValueAsBool(cRemoveFirstRoman, false);
            Ratings = xmlReader.GetOptionValueAsString(cRatings, "01");
            SecondaryEnglishTitle = xmlReader.GetOptionValueAsBool(cSecondaryEnglishTitle, false);
            SecondaryDetails = xmlReader.GetOptionValueAsString(cSecondaryDetails, "01");
            SecondarySummary = xmlReader.GetOptionValueAsBool(cSecondarySummary, false);
            RefreshAllFields = xmlReader.GetOptionValueAsBool(cRefreshAllFields, true);
            CountryFilter = xmlReader.GetOptionValueAsString(cCountryFilter, "us|ca|gb|ie|au|nz");
            LanguageFilter = xmlReader.GetOptionValueAsString(cLanguageFilter, "en");
            #endregion

            #region Plugin
            using (Settings xmlreader = new MPSettings())
            {
                SyncInterval = xmlreader.GetValueAsInt(cSection, cSyncInterval, 24);
                SyncOnStartup = xmlreader.GetValueAsBool(cSection, cSyncOnStartup, false);
                SyncLastDateTime = xmlreader.GetValueAsString(cSection, cSyncLastDateTime, DateTime.MinValue.ToString());
                DisableNotifications = xmlreader.GetValueAsBool(cSection, cDisableNotifications, false);
                MoviesRefreshed = xmlreader.GetValueAsString(cSection, cMoviesRefreshed, "[]").FromJSONArray<string>().ToList();
            }
            #endregion

            #region MediaPortal
            // Check if MediaPortal will Show TVSeries Plugin when restarting
            // We need to do this because we may need to show a modal dialog e.g. PinCode and we can't do this if MediaPortal window is not yet ready            
            using (Settings xmlreader = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
            {
                ShowLastActiveModuleOnRestart = xmlreader.GetValueAsBool("general", "showlastactivemodule", false);
                LastActiveModule = xmlreader.GetValueAsInt("general", "lastactivemodule", -1);
            }
            #endregion

            // save settings, might be some new settings added
            SaveSettings();
        }