Exemplo n.º 1
0
 private void LoadStats()
 {
     try
     {
         CurrentStats = TVRenameStats.Load();
     }
     catch (Exception)
     {
         // not worried if stats loading fails
     }
 }
Exemplo n.º 2
0
        // ReSharper disable once InconsistentNaming
        private bool LoadXMLSettings([CanBeNull] FileInfo from)
        {
            Logger.Info("Loading Settings from {0}", from?.FullName);
            if (from is null)
            {
                return(true);
            }

            try
            {
                if (!from.Exists)
                {
                    return(true); // that's ok
                }

                XElement x = XElement.Load(from.FullName);

                if (x.Name.LocalName != "TVRename")
                {
                    LoadErr = from.Name + " : Not a TVRename settings file";
                    return(false);
                }

                if (x.Attribute("Version")?.Value != "2.1")
                {
                    LoadErr = from.Name + " : Incompatible version";
                    return(false);
                }

                TVSettings.Instance.load(x.Descendants("Settings").First());
                Library.LoadFromXml(x.Descendants("MyShows").First());
                TVSettings.Instance.IgnoreFolders =
                    x.Descendants("IgnoreFolders").FirstOrDefault()?.ReadStringsFromXml("Folder") ?? new List <string>();
                TVSettings.Instance.DownloadFolders =
                    x.Descendants("FinderSearchFolders").FirstOrDefault()?.ReadStringsFromXml("Folder") ?? new List <string>();
                TVSettings.Instance.IgnoredAutoAddHints =
                    x.Descendants("IgnoredAutoAddHints").FirstOrDefault()?.ReadStringsFromXml("Hint") ?? new List <string>();
                TVSettings.Instance.Ignore =
                    x.Descendants("IgnoreItems").FirstOrDefault()?.ReadIiFromXml("Ignore") ?? new List <IgnoreItem>();
                TVSettings.Instance.PreviouslySeenEpisodes = new PreviouslySeenEpisodes(x.Descendants("PreviouslySeenEpisodes").FirstOrDefault());

                //MonitorFolders are a little more complex as there is a parameter named the same which we need to ignore
                IEnumerable <XElement> mfs = x.Descendants("MonitorFolders");
                foreach (XElement mf in mfs)
                {
                    if (mf.Descendants("Folder").Any())
                    {
                        TVSettings.Instance.LibraryFolders = mf.ReadStringsFromXml("Folder");
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Warn(e, "Problem on Startup loading File");
                LoadErr = from.Name + " : " + e.Message;
                return(false);
            }

            try
            {
                CurrentStats = TVRenameStats.Load();
            }
            catch (Exception)
            {
                // not worried if stats loading fails
            }

            try
            {
                TheTVDB.Instance.LanguageList = Languages.Load();
            }
            catch (Exception)
            {
                // not worried if language loading fails as we'll repopulate
            }

            return(true);
        }