Beispiel #1
0
        private void LoadSettings()
        {
            using (Settings xmlreader = new MPSettings())
            {
                string strTmp = String.Empty;
                strTmp = (string)xmlreader.GetValue(SettingsSection, "sort");
                if (strTmp != null)
                {
                    if (strTmp == "channel")
                    {
                        _currentSortMethod = SortMethod.Channel;
                    }
                    else if (strTmp == "date")
                    {
                        _currentSortMethod = SortMethod.Date;
                    }
                    else if (strTmp == "name")
                    {
                        _currentSortMethod = SortMethod.Name;
                    }
                }

                strTmp = String.Empty;
                strTmp = (string)xmlreader.GetValue(SettingsSection, "programtype");
                if (strTmp != null)
                {
                    if (strTmp == "recordings")
                    {
                        _currentProgramType = ScheduleType.Recording;
                    }
                    else if (strTmp == "alerts")
                    {
                        _currentProgramType = ScheduleType.Alert;
                    }
                    else if (strTmp == "suggestions")
                    {
                        _currentProgramType = ScheduleType.Suggestion;
                    }
                }

                m_bSortAscending = xmlreader.GetValueAsBool(SettingsSection, "sortascending", false);

                if (_groupBySchedButton != null)
                {
                    _groupBySchedButton.Selected = xmlreader.GetValueAsBool(SettingsSection, "groupbyschedule", false);
                }
            }
        }
Beispiel #2
0
 private void LoadSettings()
 {
     using (Settings xmlreader = new MPSettings())
     {
         string strTmp = String.Empty;
         strTmp = (string)xmlreader.GetValue("tvscheduler", "sort");
         if (strTmp != null)
         {
             if (strTmp == "channel")
             {
                 currentSortMethod = SortMethod.Channel;
             }
             else if (strTmp == "date")
             {
                 currentSortMethod = SortMethod.Date;
             }
             else if (strTmp == "name")
             {
                 currentSortMethod = SortMethod.Name;
             }
         }
         m_bSortAscending = xmlreader.GetValueAsBool("tvscheduler", "sortascending", true);
         if (btnSeries != null)
         {
             btnSeries.Selected = xmlreader.GetValueAsBool("tvscheduler", "series", false);
         }
     }
 }
        public PluginSettings()
        {
            using (Settings settings = new MPSettings())
            {
                ServerName    = settings.GetValueAsString(SECTION_NAME, SERVER_NAME, System.Windows.Forms.SystemInformation.ComputerName);
                Password      = settings.GetValueAsString(SECTION_NAME, SERVER_PASS, null);
                CustomAddress = settings.GetValueAsString(SECTION_NAME, CUSTOM_ADDRESS, null).BytesFromHexString();
                RtspPort      = settings.GetValueAsInt(SECTION_NAME, RTSP_PORT, DEFAULT_RTSP_PORT);
                UdpPort       = settings.GetValueAsInt(SECTION_NAME, UDP_PORT, DEFAULT_UDP_PORT);
                AllowVolume   = settings.GetValueAsBool(SECTION_NAME, ALLOW_VOLUME, true);
                SendCommands  = settings.GetValueAsBool(SECTION_NAME, SEND_COMMANDS, true);

                decimal bufferSize;
                if (!decimal.TryParse(settings.GetValue(SECTION_NAME, BUFFER_SIZE), NumberStyles.Float, CultureInfo.InvariantCulture, out bufferSize))
                {
                    bufferSize = 2M;
                }
                AudioBuffer = bufferSize;

                AirplayPort    = settings.GetValueAsInt(SECTION_NAME, AIRPLAY_PORT, DEFAULT_HTTP_PORT);
                AllowHDStreams = settings.GetValueAsBool(SECTION_NAME, ALLOW_HD_STREAMS, true);
                VideoBuffer    = settings.GetValueAsInt(SECTION_NAME, VIDEO_BUFFER, 2);

                iOS8Workaround = settings.GetValueAsBool(SECTION_NAME, IOS8_WORKAROUND, false);
            }
        }
 protected object GetValue(string name)
 {
     using (Settings xmlreader = new MPSettings())
     {
         return(xmlreader.GetValue(CONFIG_SECTION, _prefix + "_" + name));
     }
 }
Beispiel #5
0
        protected override void LoadSettings()
        {
            if (settingsRadioLoaded)
            {
                return;
            }

            base.LoadSettings();
            using (Settings xmlreader = new MPSettings())
            {
                currentLayout    = (Layout)xmlreader.GetValueAsInt(SerializeName, "layout", (int)Layout.List);
                m_bSortAscending = xmlreader.GetValueAsBool(SerializeName, "sortasc", true);

                string tmpLine;
                tmpLine = xmlreader.GetValue("myradio", "sort");
                if (tmpLine != null)
                {
                    if (tmpLine == "name")
                    {
                        currentSortMethod = SortMethod.Name;
                    }
                    else if (tmpLine == "type")
                    {
                        currentSortMethod = SortMethod.Type;
                    }
                    else if (tmpLine == "genre")
                    {
                        currentSortMethod = SortMethod.Genre;
                    }
                    else if (tmpLine == "bitrate")
                    {
                        currentSortMethod = SortMethod.Bitrate;
                    }
                    else if (tmpLine == "number")
                    {
                        currentSortMethod = SortMethod.Number;
                    }
                }

                if (xmlreader.GetValueAsBool("myradio", "rememberlastgroup", true))
                {
                    currentFolder = xmlreader.GetValueAsString("myradio", "lastgroup", null);
                }
                hideAllChannelsGroup = xmlreader.GetValueAsBool("myradio", "hideAllChannelsGroup", false);
                rootGroup            = xmlreader.GetValueAsString("myradio", "rootgroup", "(none)");

                _autoTurnOnRadio = xmlreader.GetValueAsBool("myradio", "autoturnonradio", false);
            }
            settingsRadioLoaded = true;
        }
    /// <summary>
    /// Loads the standby configuration
    /// </summary>
    private void LoadSettings()
    {
      bool changed = false;
      bool boolSetting;
      int intSetting;
      string stringSetting;
      PowerSetting powerSetting;

      Log.Debug("PS: LoadSettings()");

      // Load initial settings only once
      if (_settings == null)
      {
        using (Settings reader = new MPSettings())
        {

          // Check if update of old PS settings is necessary
          if (reader.GetValue("psclientplugin", "ExpertMode") == "")
          {
            // Initialise list of old and new settings names to update
            List<String[]> settingNames = new List<String[]>();
            settingNames.Add(new String[] { "homeonly", "HomeOnly" });
            settingNames.Add(new String[] { "idletimeout", "IdleTimeout" });
            settingNames.Add(new String[] { "shutdownenabled", "ShutdownEnabled" });
            settingNames.Add(new String[] { "shutdownmode", "ShutdownMode" });

            // Update settings names
            foreach (String[] settingName in settingNames)
            {
              String settingValue = reader.GetValue("psclientplugin", settingName[0]);
              if (settingValue != "")
              {
                reader.RemoveEntry("psclientplugin", settingName[0]);
                reader.SetValue("psclientplugin", settingName[1], settingValue);
              }
            }
          }

          _settings = new PowerSettings();
          changed = true;

          // Set constant values (needed for backward compatibility)
          _settings.ForceShutdown = false;
          _settings.ExtensiveLogging = false;
          _settings.PreNoShutdownTime = 300;
          _settings.CheckInterval = 15;

          // Check if we only should suspend in MP's home window
          boolSetting = reader.GetValueAsBool("psclientplugin", "HomeOnly", false);
          powerSetting = _settings.GetSetting("HomeOnly");
          powerSetting.Set<bool>(boolSetting);
          Log.Debug("PS: Only allow standby when on home window: {0}", boolSetting);

          // Get external command
          stringSetting = reader.GetValueAsString("psclientplugin", "Command", String.Empty);
          powerSetting = _settings.GetSetting("Command");
          powerSetting.Set<string>(stringSetting);
          Log.Debug("PS: Run command on power state change: {0}", stringSetting);

          // Check if we should unmute the master volume
          boolSetting = reader.GetValueAsBool("psclientplugin", "UnmuteMasterVolume", true);
          powerSetting = _settings.GetSetting("UnmuteMasterVolume");
          powerSetting.Set<bool>(boolSetting);
          Log.Debug("PS: Unmute master volume: {0}", boolSetting);

          // Detect single-seat
          string tvPluginDll = Config.GetSubFolder(Config.Dir.Plugins, "windows") + @"\" + "TvPlugin.dll";
          if (File.Exists(tvPluginDll))
          {
            string hostName = reader.GetValueAsString("tvservice", "hostname", String.Empty);
            if (hostName != String.Empty && PowerManager.IsLocal(hostName))
            {
              _singleSeat = true;
              Log.Info("PS: Detected single-seat setup - TV-Server on local system");
            }
            else if (hostName == String.Empty)
            {
              _singleSeat = false;
              Log.Info("PS: Detected standalone client setup - no TV-Server configured");
            }
            else
            {
              _singleSeat = false;
              Log.Info("PS: Detected remote client setup - TV-Server on \"{0}\"", hostName);

              RemotePowerControl.HostName = hostName;
              Log.Debug("PS: Set RemotePowerControl.HostName: {0}", hostName);
            }
          }
          else
          {
            _singleSeat = false;
            Log.Info("PS: Detected standalone client setup - no TV-Plugin installed");
          }

          // Standalone client has local standby / wakeup settings
          if (!_singleSeat)
          {
            // Check if PowerScheduler should actively put the system into standby
            boolSetting = reader.GetValueAsBool("psclientplugin", "ShutdownEnabled", false);
            _settings.ShutdownEnabled = boolSetting;
            Log.Debug("PS: PowerScheduler forces system to go to standby when idle: {0}", boolSetting);

            if (_settings.ShutdownEnabled)
            {
              // Check configured shutdown mode
              intSetting = reader.GetValueAsInt("psclientplugin", "ShutdownMode", 0);
              _settings.ShutdownMode = (ShutdownMode)intSetting;
              Log.Debug("PS: Shutdown mode: {0}", _settings.ShutdownMode.ToString());
            }

            // Get idle timeout
            if (_settings.ShutdownEnabled)
            {
              intSetting = reader.GetValueAsInt("psclientplugin", "IdleTimeout", 30);
              _settings.IdleTimeout = intSetting;
              Log.Debug("PS: Standby after: {0} minutes", intSetting);
            }

            // Check configured pre-wakeup time (can only be configured by editing MediaPortal.xml)
            intSetting = reader.GetValueAsInt("psclientplugin", "PreWakeupTime", 60);
            _settings.PreWakeupTime = intSetting;
            Log.Debug("PS: Pre-wakeup time: {0} seconds", intSetting);

            // Check configured pre-no-standby time (can only be configured by editing MediaPortal.xml)
            intSetting = reader.GetValueAsInt("psclientplugin", "PreNoStandbyTime", 300);
            _settings.PreNoShutdownTime = intSetting;
            Log.Debug("PS: Pre-no-standby time: {0} seconds", intSetting);

            // Check if PowerScheduler should wakeup the system automatically
            intSetting = reader.GetValueAsInt("psclientplugin", "Profile", 0);
            if (intSetting == 2)
              boolSetting = false;  // Notebook
            else
              boolSetting = true;   // HTPC, Desktop
            _settings.WakeupEnabled = boolSetting;
            Log.Debug("PS: Wakeup system for various events: {0}", boolSetting);
          }
        }
      }

      // (Re-)Load settings every check interval
      if (_singleSeat)
      {
        // Connect to local tvservice (RemotePowerControl)
        if (RemotePowerControl.Instance != null && RemotePowerControl.Isconnected)
        {
          // Check if PowerScheduler should actively put the system into standby
          boolSetting = RemotePowerControl.Instance.PowerSettings.ShutdownEnabled;
          if (_settings.ShutdownEnabled != boolSetting)
          {
            _settings.ShutdownEnabled = boolSetting;
            Log.Debug("PS: Server plugin setting - PowerScheduler forces system to go to standby when idle: {0}", boolSetting);
            changed = true;
          }

          if (_settings.ShutdownEnabled)
          {
            // Get configured shutdown mode from local tvservice
            intSetting = (int)RemotePowerControl.Instance.PowerSettings.ShutdownMode;
            if ((int)_settings.ShutdownMode != intSetting)
            {
              _settings.ShutdownMode = (ShutdownMode)intSetting;
              Log.Debug("PS: Server plugin setting - Shutdown mode: {0}", _settings.ShutdownMode.ToString());
              changed = true;
            }
          }

          // Get idle timeout from local tvservice
          intSetting = RemotePowerControl.Instance.PowerSettings.IdleTimeout;
          if (_settings.IdleTimeout != intSetting)
          {
            _settings.IdleTimeout = intSetting;
            Log.Debug("PS: Server plugin setting - {0}: {1} minutes", (_settings.ShutdownEnabled ? "Standby after" : "System idle timeout"), intSetting);
            changed = true;
          }

          // Get configured pre-wakeup time from local tvservice
          intSetting = RemotePowerControl.Instance.PowerSettings.PreWakeupTime;
          if (_settings.PreWakeupTime != intSetting)
          {
            _settings.PreWakeupTime = intSetting;
            Log.Debug("PS: Pre-wakeup time: {0} seconds", intSetting);
            changed = true;
          }

          // Check if PowerScheduler should wakeup the system automatically
          boolSetting = RemotePowerControl.Instance.PowerSettings.WakeupEnabled;
          if (_settings.WakeupEnabled != boolSetting)
          {
            _settings.WakeupEnabled = boolSetting;
            Log.Debug("PS: Server plugin setting - Wakeup system for various events: {0}", boolSetting);
            changed = true;
          }
        }
        else
        {
          Log.Error("PS: Cannot connect to local tvservice to load settings");
        }
      }
      else
      {
        // Get active idle timeout for standalone client if standby is handled by Windows
        if (!_settings.ShutdownEnabled)
        {
          intSetting = (int)PowerManager.GetActivePowerSetting(PowerManager.SystemPowerSettingType.STANDBYIDLE) / 60;
          if (_settings.IdleTimeout != intSetting)
          {
            _settings.IdleTimeout = intSetting;
            Log.Debug("PS: System idle timeout: {0} minutes", intSetting);
            changed = true;
          }
        }
      }

      // Send message in case any setting has changed
      if (changed)
      {
        PowerSchedulerEventArgs args = new PowerSchedulerEventArgs(PowerSchedulerEventType.SettingsChanged);
        args.SetData<PowerSettings>(_settings.Clone());
        SendPowerSchedulerEvent(args);
      }
    }
 protected object GetValue(string name)
 {
   using (Settings xmlreader = new MPSettings())
   {
     return xmlreader.GetValue(CONFIG_SECTION, _prefix + "_" + name);
   }
 }
Beispiel #8
0
        void Load()
        {
            OnlineVideos.OnlineVideoSettings ovsconf = OnlineVideos.OnlineVideoSettings.Instance;

            ovsconf.UserStore = new UserStore();
            ovsconf.FavDB     = FavoritesDatabase.Instance;
            ovsconf.Logger    = Log.Instance;
            ovsconf.ThumbsDir = Config.GetFolder(Config.Dir.Thumbs) + @"\OnlineVideos\";
            ovsconf.ConfigDir = Config.GetFolder(Config.Dir.Config);
            ovsconf.DllsDir   = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "OnlineVideos\\");

            // When run from MPEI we get an invalid plugin directory, we'll try to rectify that here
            try
            {
                var hasFiles = true;

                if (Directory.Exists(ovsconf.DllsDir))
                {
                    var files = Directory.GetFiles(ovsconf.DllsDir, "OnlineVideos.Sites.*.dll");
                    if (files == null || files.Count() == 0)
                    {
                        hasFiles = false;
                    }
                }
                else
                {
                    hasFiles = false;
                }

                if (!hasFiles)
                {
                    ovsconf.DllsDir = Path.Combine(MediaPortal.Configuration.Config.GetDirectoryInfo(MediaPortal.Configuration.Config.Dir.Plugins).FullName, "Windows\\OnlineVideos");
                }
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex);
            }

            ovsconf.ThumbsResizeOptions = new OnlineVideos.Downloading.ImageDownloader.ResizeOptions()
            {
                MaxSize       = (int)Thumbs.ThumbLargeResolution,
                Compositing   = Thumbs.Compositing,
                Interpolation = Thumbs.Interpolation,
                Smoothing     = Thumbs.Smoothing
            };
            try
            {
                ovsconf.Locale = CultureInfo.CreateSpecificCulture(GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage()));
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex);
            }
            try
            {
                using (Settings settings = new MPSettings())
                {
                    BasicHomeScreenName = settings.GetValueAsString(CFG_SECTION, CFG_BASICHOMESCREEN_NAME, BasicHomeScreenName);
                    siteOrder           = (SiteOrder)settings.GetValueAsInt(CFG_SECTION, CFG_SITEVIEW_ORDER, (int)SiteOrder.AsInFile);
                    currentGroupView    = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_GROUPVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentSiteView     = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_SITEVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentCategoryView = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_CATEGORYVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentVideoView    = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_VIDEOVIEW_MODE, (int)GUIFacadeControl.Layout.SmallIcons);

                    ovsconf.ThumbsDir = settings.GetValueAsString(CFG_SECTION, CFG_THUMBNAIL_DIR, ovsconf.ThumbsDir).Replace("/", @"\");
                    if (!ovsconf.ThumbsDir.EndsWith(@"\"))
                    {
                        ovsconf.ThumbsDir = ovsconf.ThumbsDir + @"\";                                    // fix thumbnail dir to include the trailing slash
                    }
                    try { if (!string.IsNullOrEmpty(ovsconf.ThumbsDir) && !Directory.Exists(ovsconf.ThumbsDir))
                          {
                              Directory.CreateDirectory(ovsconf.ThumbsDir);
                          }
                    }
                    catch (Exception e) { Log.Instance.Error("Failed to create thumb dir: {0}", e.ToString()); }
                    ThumbsAge = settings.GetValueAsInt(CFG_SECTION, CFG_THUMBNAIL_AGE, ThumbsAge);
                    Log.Instance.Info("Thumbnails will be stored in {0} with a maximum age of {1} days.", ovsconf.ThumbsDir, ThumbsAge);

                    ovsconf.DownloadDir = settings.GetValueAsString(CFG_SECTION, CFG_DOWNLOAD_DIR, "");
                    try { if (!string.IsNullOrEmpty(ovsconf.DownloadDir) && !Directory.Exists(ovsconf.DownloadDir))
                          {
                              Directory.CreateDirectory(ovsconf.DownloadDir);
                          }
                    }
                    catch (Exception e) { Log.Instance.Error("Failed to create download dir: {0}", e.ToString()); }

                    ovsconf.CacheTimeout           = settings.GetValueAsInt(CFG_SECTION, CFG_CACHE_TIMEOUT, ovsconf.CacheTimeout);
                    ovsconf.UseAgeConfirmation     = settings.GetValueAsBool(CFG_SECTION, CFG_USE_AGECONFIRMATION, ovsconf.UseAgeConfirmation);
                    ovsconf.UtilTimeout            = settings.GetValueAsInt(CFG_SECTION, CFG_UTIL_TIMEOUT, ovsconf.UtilTimeout);
                    ovsconf.DynamicCategoryTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_CATEGORYDISCOVERED_TIMEOUT, ovsconf.DynamicCategoryTimeout);

                    // set an almost random string by default -> user must enter pin in Configuration before beeing able to watch adult sites
                    pinAgeConfirmation = settings.GetValueAsString(CFG_SECTION, CFG_PIN_AGECONFIRMATION, DateTime.Now.Millisecond.ToString());
                    useQuickSelect     = settings.GetValueAsBool(CFG_SECTION, CFG_USE_QUICKSELECT, useQuickSelect);
                    wmpbuffer          = settings.GetValueAsInt(CFG_SECTION, CFG_WMP_BUFFER, wmpbuffer);
                    playbuffer         = settings.GetValueAsInt(CFG_SECTION, CFG_PLAY_BUFFER, playbuffer);
                    email    = settings.GetValueAsString(CFG_SECTION, CFG_EMAIL, "");
                    password = settings.GetValueAsString(CFG_SECTION, CFG_PASSWORD, "");
                    string lsFilter = settings.GetValueAsString(CFG_SECTION, CFG_FILTER, "").Trim();
                    FilterArray       = lsFilter != "" ? lsFilter.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) : null;
                    searchHistoryNum  = settings.GetValueAsInt(CFG_SECTION, CFG_SEARCHHISTORY_NUM, searchHistoryNum);
                    searchHistoryType = (SearchHistoryType)settings.GetValueAsInt(CFG_SECTION, CFG_SEARCHHISTORYTYPE, (int)searchHistoryType);

                    string searchHistoryXML = settings.GetValueAsString(CFG_SECTION, CFG_SEARCHHISTORY, "").Trim();
                    if ("" != searchHistoryXML)
                    {
                        try
                        {
                            byte[]       searchHistoryBytes = System.Text.Encoding.UTF8.GetBytes(searchHistoryXML);
                            MemoryStream xmlMem             = new MemoryStream(searchHistoryBytes);
                            xmlMem.Position = 0;
                            System.Runtime.Serialization.DataContractSerializer dcs = new System.Runtime.Serialization.DataContractSerializer(typeof(Dictionary <string, List <string> >));
                            searchHistory = (Dictionary <string, List <string> >)dcs.ReadObject(xmlMem);
                        }
                        catch (Exception e)
                        {
                            Log.Instance.Warn("Error reading search history from configuration: {0}:{1}! Clearing...", e.GetType(), e.Message);
                            searchHistory = null;
                        }
                    }
                    if (null == searchHistory)
                    {
                        searchHistory = new Dictionary <string, List <string> >();
                    }

                    // set updateOnStart only when defined, so we have 3 modes: undefined = ask, true = don't ask and update, false = don't ask and don't update
                    string doUpdateString = settings.GetValue(CFG_SECTION, CFG_UPDATEONSTART);
                    if (!string.IsNullOrEmpty(doUpdateString))
                    {
                        updateOnStart = settings.GetValueAsBool(CFG_SECTION, CFG_UPDATEONSTART, true);
                    }

                    // last point in time the plugin was run in mediaportal
                    string tempDate = settings.GetValueAsString(CFG_SECTION, CFG_LAST_FIRSTRUN, string.Empty);
                    if (!string.IsNullOrEmpty(tempDate))
                    {
                        DateTime.TryParse(tempDate, out lastFirstRun);
                    }

                    updatePeriod = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_UPDATEPERIOD, (int)updatePeriod);

                    // read the video extensions configured in MediaPortal
                    string[] mediaportal_user_configured_video_extensions;
                    string   strTmp = settings.GetValueAsString("movies", "extensions", ".avi,.mpg,.ogm,.mpeg,.mkv,.wmv,.ifo,.qt,.rm,.mov,.sbe,.dvr-ms,.ts");
                    mediaportal_user_configured_video_extensions = strTmp.Split(',');
                    var listOfExtensions = mediaportal_user_configured_video_extensions.ToList();
                    listOfExtensions.AddRange(new string[] { ".asf", ".asx", ".flv", ".m4v", ".mov", ".mp4", ".wmv" });
                    listOfExtensions = listOfExtensions.Distinct().ToList();
                    listOfExtensions.Sort();
                    ovsconf.AddSupportedVideoExtensions(listOfExtensions);

                    autoGroupByLang        = settings.GetValueAsBool(CFG_SECTION, CFG_AUTO_LANG_GROUPS, autoGroupByLang);
                    ovsconf.FavoritesFirst = settings.GetValueAsBool(CFG_SECTION, CFG_FAVORITES_FIRST, ovsconf.FavoritesFirst);

                    LatestVideosRandomize         = settings.GetValueAsBool(CFG_SECTION, CFG_LATESTVIDEOS_RANDOMIZE, LatestVideosRandomize);
                    LatestVideosMaxItems          = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_MAXITEMS, (int)LatestVideosMaxItems);
                    LatestVideosOnlineDataRefresh = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_ONLINEDATA_REFRESH, (int)LatestVideosOnlineDataRefresh);
                    LatestVideosGuiDataRefresh    = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_GUIDATA_REFRESH, (int)LatestVideosGuiDataRefresh);

                    AllowRefreshRateChange = settings.GetValueAsBool(CFG_SECTION, CFG_ALLOW_REFRESHRATE_CHANGE, AllowRefreshRateChange);
                    StoreLayoutPerCategory = settings.GetValueAsBool(CFG_SECTION, CFG_STORE_LAYOUT_PER_CATEGORY, StoreLayoutPerCategory);

                    ovsconf.HttpPreferredNetworkInterface    = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_HTTP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.HttpOpenConnectionTimeout        = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_TIMEOUT, ovsconf.HttpOpenConnectionTimeout);
                    ovsconf.HttpOpenConnectionSleepTime      = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.HttpOpenConnectionSleepTime);
                    ovsconf.HttpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.HttpTotalReopenConnectionTimeout);

                    ovsconf.RtmpPreferredNetworkInterface    = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_RTMP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.RtmpOpenConnectionTimeout        = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtmpOpenConnectionTimeout);
                    ovsconf.RtmpOpenConnectionSleepTime      = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtmpOpenConnectionSleepTime);
                    ovsconf.RtmpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtmpTotalReopenConnectionTimeout);

                    ovsconf.RtspPreferredNetworkInterface    = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_RTSP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.RtspOpenConnectionTimeout        = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtspOpenConnectionTimeout);
                    ovsconf.RtspOpenConnectionSleepTime      = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtspOpenConnectionSleepTime);
                    ovsconf.RtspTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtspTotalReopenConnectionTimeout);

                    ovsconf.RtspClientPortMin = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MIN, ovsconf.RtspClientPortMin);
                    ovsconf.RtspClientPortMax = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MAX, ovsconf.RtspClientPortMax);

                    ovsconf.UdpRtpPreferredNetworkInterface    = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_UDPRTP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.UdpRtpOpenConnectionTimeout        = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpOpenConnectionTimeout);
                    ovsconf.UdpRtpOpenConnectionSleepTime      = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.UdpRtpOpenConnectionSleepTime);
                    ovsconf.UdpRtpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpTotalReopenConnectionTimeout);
                    ovsconf.UdpRtpReceiveDataCheckInterval     = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_RECEIVE_DATA_CHECK_INTERVAL, ovsconf.UdpRtpReceiveDataCheckInterval);
                }
                LoadSitesGroups();
                ovsconf.LoadSites();
            }
            catch (Exception e)
            {
                Log.Instance.Error(e);
            }
        }
        internal void GetLatestMediaInfo()
        {
            int z = 1;

            if (Utils.LatestTVRecordings)
            {
                //TV Recordings
                LatestsCollection latestTVRecordings = null;
                try
                {
                    string useArgus;
                    using (Settings xmlreader = new MPSettings())
                    {
                        useArgus = xmlreader.GetValue("plugins", "ARGUS TV");
                    }
                    string dllFile = Config.GetFile(Config.Dir.Plugins, @"Windows\ArgusTV.UI.MediaPortal.dll");

                    if (useArgus != null && useArgus.Equals("yes", StringComparison.CurrentCulture) && File.Exists(dllFile))
                    {
                        FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(dllFile);
                        logger.Debug("Argus version = {0}", myFileVersionInfo.FileVersion);

                        if (Largusrh == null)
                        {
                            Largusrh = new LatestArgusRecordingsHandler(this);
                        }

                        ResolveEventHandler assemblyResolve = Largusrh.OnAssemblyResolve;
                        try
                        {
                            AppDomain currentDomain = AppDomain.CurrentDomain;
                            currentDomain.AssemblyResolve        += new ResolveEventHandler(Largusrh.OnAssemblyResolve);
                            Largusrh.IsGetTypeRunningOnThisThread = true;
                            latestTVRecordings = Largusrh.GetArgusRecordings();
                            Largusrh.UpdateActiveRecordings();
                            AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve;
                            Utils.UsedArgus = true;
                        }
                        catch (FileNotFoundException)
                        {
                            //do nothing
                        }
                        catch (MissingMethodException)
                        {
                            //do nothing
                        }
                        catch (Exception ex)
                        {
                            logger.Error("GetLatestMediaInfo (TV Argus Recordings): " + ex.ToString());
                            AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve;
                        }
                    }
                    else
                    {
                        if (Ltvrh == null)
                        {
                            Ltvrh = new LatestTVRecordingsHandler(this);
                        }
                        latestTVRecordings = Ltvrh.GetTVRecordings();
                        Ltvrh.UpdateActiveRecordings();
                        Utils.UsedArgus = false;
                    }
                }
                catch (FileNotFoundException)
                {
                    //do nothing
                }
                catch (MissingMethodException)
                {
                    //do nothing
                }
                catch (Exception ex)
                {
                    logger.Error("GetLatestMediaInfo (TV Recordings): " + ex.ToString());
                }
                bool noNewRecordings = false;
                if ((latestTVRecordings != null && latestTVRecordings.Count > 0) &&
                    Utils.GetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".title").Equals(latestTVRecordings[0].Title, StringComparison.CurrentCulture))
                {
                    noNewRecordings = true;
                    logger.Info("Updating Latest Media Info: TV Recording: No new recordings since last check!");
                }

                if (latestTVRecordings != null && latestTVRecordings.Count > 0)
                {
                    if (!noNewRecordings)
                    {
                        EmptyLatestMediaProperties();
                        z = 1;
                        for (int i = 0; i < latestTVRecordings.Count && i < Utils.LatestsMaxTVNum; i++)
                        {
                            logger.Info("Updating Latest Media Info: TV Recording: Recording " + z + ": " + latestTVRecordings[i].Title);

                            string recsummary        = (string.IsNullOrEmpty(latestTVRecordings[i].Summary) ? Translation.NoDescription : latestTVRecordings[i].Summary);
                            string recsummaryoutline = Utils.GetSentences(recsummary, Utils.LatestPlotOutlineSentencesNum);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".thumb", latestTVRecordings[i].Thumb);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".title", latestTVRecordings[i].Title);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".dateAdded", latestTVRecordings[i].DateAdded);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".genre", latestTVRecordings[i].Genre);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".summary", recsummary);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".summaryoutline", recsummaryoutline);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".series", latestTVRecordings[i].SeriesIndex);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".episode", latestTVRecordings[i].EpisodeIndex);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".episodename", latestTVRecordings[i].ThumbSeries);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".directory", latestTVRecordings[i].Directory);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".new", latestTVRecordings[i].New);
                            z++;
                        }
                        //latestTVRecordings.Clear();
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.latest.enabled", "true");
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.hasnew", CurrentFacade.HasNew ? "true" : "false");
                        logger.Debug("Updating Latest Media Info: TV Recording: Has new: " + (CurrentFacade.HasNew ? "true" : "false"));
                    }
                }
                else
                {
                    EmptyLatestMediaProperties();
                    logger.Info("Updating Latest Media Info: TV Recording: No recordings found!");
                }
                //latestTVRecordings = null;
                z = 1;
            }
            else
            {
                EmptyLatestMediaProperties();
            }
            Utils.UpdateLatestsUpdate(Utils.LatestsCategory.TV, DateTime.Now);
        }
        void Load()
        {
            OnlineVideos.OnlineVideoSettings ovsconf = OnlineVideos.OnlineVideoSettings.Instance;

            ovsconf.UserStore = new UserStore();
            ovsconf.FavDB = FavoritesDatabase.Instance;
            ovsconf.Logger = Log.Instance;
            ovsconf.ThumbsDir = Config.GetFolder(Config.Dir.Thumbs) + @"\OnlineVideos\";
            ovsconf.ConfigDir = Config.GetFolder(Config.Dir.Config);
            ovsconf.DllsDir = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "OnlineVideos\\");

            // When run from MPEI we get an invalid plugin directory, we'll try to rectify that here
            try 
            {
                var hasFiles = true;

                if (Directory.Exists(ovsconf.DllsDir))
                {
                    var files = Directory.GetFiles(ovsconf.DllsDir, "OnlineVideos.Sites.*.dll");
                    if (files == null || files.Count() == 0)
                        hasFiles = false;
                }
                else
                    hasFiles = false;

                if (!hasFiles)
                    ovsconf.DllsDir = Path.Combine(MediaPortal.Configuration.Config.GetDirectoryInfo(MediaPortal.Configuration.Config.Dir.Plugins).FullName, "Windows\\OnlineVideos"); 
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex);
            }
            
            ovsconf.ThumbsResizeOptions = new OnlineVideos.Downloading.ImageDownloader.ResizeOptions()
            {
                MaxSize = (int)Thumbs.ThumbLargeResolution,
                Compositing = Thumbs.Compositing,
                Interpolation = Thumbs.Interpolation,
                Smoothing = Thumbs.Smoothing 
            };
            try
            {
                ovsconf.Locale = CultureInfo.CreateSpecificCulture(GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage()));
            }
            catch (Exception ex)
            {                
                Log.Instance.Error(ex);
            }
            try
            {
                using (Settings settings = new MPSettings())
                {
                    BasicHomeScreenName = settings.GetValueAsString(CFG_SECTION, CFG_BASICHOMESCREEN_NAME, BasicHomeScreenName);
                    siteOrder = (SiteOrder)settings.GetValueAsInt(CFG_SECTION, CFG_SITEVIEW_ORDER, (int)SiteOrder.AsInFile);
                    currentGroupView = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_GROUPVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentSiteView = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_SITEVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentCategoryView = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_CATEGORYVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentVideoView = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_VIDEOVIEW_MODE, (int)GUIFacadeControl.Layout.SmallIcons);

					ovsconf.ThumbsDir = settings.GetValueAsString(CFG_SECTION, CFG_THUMBNAIL_DIR, ovsconf.ThumbsDir).Replace("/", @"\");
                    if (!ovsconf.ThumbsDir.EndsWith(@"\")) ovsconf.ThumbsDir = ovsconf.ThumbsDir + @"\"; // fix thumbnail dir to include the trailing slash
                    try { if (!string.IsNullOrEmpty(ovsconf.ThumbsDir) && !Directory.Exists(ovsconf.ThumbsDir)) Directory.CreateDirectory(ovsconf.ThumbsDir); }
                    catch (Exception e) { Log.Instance.Error("Failed to create thumb dir: {0}", e.ToString()); }
                    ThumbsAge = settings.GetValueAsInt(CFG_SECTION, CFG_THUMBNAIL_AGE, ThumbsAge);
                    Log.Instance.Info("Thumbnails will be stored in {0} with a maximum age of {1} days.", ovsconf.ThumbsDir, ThumbsAge);

                    ovsconf.DownloadDir = settings.GetValueAsString(CFG_SECTION, CFG_DOWNLOAD_DIR, "");
                    try { if (!string.IsNullOrEmpty(ovsconf.DownloadDir) && !Directory.Exists(ovsconf.DownloadDir)) Directory.CreateDirectory(ovsconf.DownloadDir); }
                    catch (Exception e) { Log.Instance.Error("Failed to create download dir: {0}", e.ToString()); }

                    ovsconf.CacheTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_CACHE_TIMEOUT, ovsconf.CacheTimeout);                    
                    ovsconf.UseAgeConfirmation = settings.GetValueAsBool(CFG_SECTION, CFG_USE_AGECONFIRMATION, ovsconf.UseAgeConfirmation);
                    ovsconf.UtilTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_UTIL_TIMEOUT, ovsconf.UtilTimeout);
					ovsconf.DynamicCategoryTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_CATEGORYDISCOVERED_TIMEOUT, ovsconf.DynamicCategoryTimeout);

                    // set an almost random string by default -> user must enter pin in Configuration before beeing able to watch adult sites
                    pinAgeConfirmation = settings.GetValueAsString(CFG_SECTION, CFG_PIN_AGECONFIRMATION, DateTime.Now.Millisecond.ToString());
                    useQuickSelect = settings.GetValueAsBool(CFG_SECTION, CFG_USE_QUICKSELECT, useQuickSelect);
                    wmpbuffer = settings.GetValueAsInt(CFG_SECTION, CFG_WMP_BUFFER, wmpbuffer);
                    playbuffer = settings.GetValueAsInt(CFG_SECTION, CFG_PLAY_BUFFER, playbuffer);
                    email = settings.GetValueAsString(CFG_SECTION, CFG_EMAIL, "");
                    password = settings.GetValueAsString(CFG_SECTION, CFG_PASSWORD, "");
                    string lsFilter = settings.GetValueAsString(CFG_SECTION, CFG_FILTER, "").Trim();
                    FilterArray = lsFilter != "" ? lsFilter.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) : null;
                    searchHistoryNum = settings.GetValueAsInt(CFG_SECTION, CFG_SEARCHHISTORY_NUM, searchHistoryNum);
                    searchHistoryType = (SearchHistoryType)settings.GetValueAsInt(CFG_SECTION, CFG_SEARCHHISTORYTYPE, (int)searchHistoryType);

                    string searchHistoryXML = settings.GetValueAsString(CFG_SECTION, CFG_SEARCHHISTORY, "").Trim();
                    if ("" != searchHistoryXML)
                    {
                        try
                        {
                            byte[] searchHistoryBytes = System.Text.Encoding.UTF8.GetBytes(searchHistoryXML);
                            MemoryStream xmlMem = new MemoryStream(searchHistoryBytes);
                            xmlMem.Position = 0;
                            System.Runtime.Serialization.DataContractSerializer dcs = new System.Runtime.Serialization.DataContractSerializer(typeof(Dictionary<string, List<string>>));
                            searchHistory = (Dictionary<string, List<string>>)dcs.ReadObject(xmlMem);
                        }
                        catch (Exception e)
                        {
                            Log.Instance.Warn("Error reading search history from configuration: {0}:{1}! Clearing...", e.GetType(), e.Message);
                            searchHistory = null;
                        }
                    }
                    if (null == searchHistory) searchHistory = new Dictionary<string, List<string>>();

                    // set updateOnStart only when defined, so we have 3 modes: undefined = ask, true = don't ask and update, false = don't ask and don't update
                    string doUpdateString = settings.GetValue(CFG_SECTION, CFG_UPDATEONSTART);
                    if (!string.IsNullOrEmpty(doUpdateString)) updateOnStart = settings.GetValueAsBool(CFG_SECTION, CFG_UPDATEONSTART, true);

                    // last point in time the plugin was run in mediaportal
                    string tempDate = settings.GetValueAsString(CFG_SECTION, CFG_LAST_FIRSTRUN, string.Empty);
                    if (!string.IsNullOrEmpty(tempDate)) DateTime.TryParse(tempDate, out lastFirstRun);

                    updatePeriod = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_UPDATEPERIOD, (int)updatePeriod);

                    // read the video extensions configured in MediaPortal                    
                    string[] mediaportal_user_configured_video_extensions;
                    string strTmp = settings.GetValueAsString("movies", "extensions", ".avi,.mpg,.ogm,.mpeg,.mkv,.wmv,.ifo,.qt,.rm,.mov,.sbe,.dvr-ms,.ts");
                    mediaportal_user_configured_video_extensions = strTmp.Split(',');
					var listOfExtensions = mediaportal_user_configured_video_extensions.ToList();
					listOfExtensions.AddRange(new string[] { ".asf", ".asx", ".flv", ".m4v", ".mov", ".mp4", ".wmv" });
					listOfExtensions = listOfExtensions.Distinct().ToList();
					listOfExtensions.Sort();
					ovsconf.AddSupportedVideoExtensions(listOfExtensions);

                    autoGroupByLang = settings.GetValueAsBool(CFG_SECTION, CFG_AUTO_LANG_GROUPS, autoGroupByLang);
					ovsconf.FavoritesFirst = settings.GetValueAsBool(CFG_SECTION, CFG_FAVORITES_FIRST, ovsconf.FavoritesFirst);

					LatestVideosRandomize = settings.GetValueAsBool(CFG_SECTION, CFG_LATESTVIDEOS_RANDOMIZE, LatestVideosRandomize);
					LatestVideosMaxItems = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_MAXITEMS, (int)LatestVideosMaxItems);
					LatestVideosOnlineDataRefresh = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_ONLINEDATA_REFRESH, (int)LatestVideosOnlineDataRefresh);
					LatestVideosGuiDataRefresh = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_GUIDATA_REFRESH, (int)LatestVideosGuiDataRefresh);

					AllowRefreshRateChange = settings.GetValueAsBool(CFG_SECTION, CFG_ALLOW_REFRESHRATE_CHANGE, AllowRefreshRateChange);
					StoreLayoutPerCategory = settings.GetValueAsBool(CFG_SECTION, CFG_STORE_LAYOUT_PER_CATEGORY, StoreLayoutPerCategory);

                    ovsconf.HttpPreferredNetworkInterface = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_HTTP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.HttpOpenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_TIMEOUT, ovsconf.HttpOpenConnectionTimeout);
                    ovsconf.HttpOpenConnectionSleepTime = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.HttpOpenConnectionSleepTime);
                    ovsconf.HttpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.HttpTotalReopenConnectionTimeout);

                    ovsconf.HttpServerAuthenticate = settings.GetValueAsBool(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_AUTHENTICATE, ovsconf.HttpServerAuthenticate);
                    ovsconf.HttpServerUserName = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_USER_NAME, ovsconf.HttpServerUserName);
                    ovsconf.HttpServerPassword = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_HTTP_SERVER_PASSWORD, ovsconf.HttpServerPassword);

                    ovsconf.HttpProxyServerAuthenticate = settings.GetValueAsBool(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_AUTHENTICATE, ovsconf.HttpProxyServerAuthenticate);
                    ovsconf.HttpProxyServer = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER, ovsconf.HttpProxyServer);
                    ovsconf.HttpProxyServerPort = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_PORT, ovsconf.HttpProxyServerPort);
                    ovsconf.HttpProxyServerUserName = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_USER_NAME, ovsconf.HttpProxyServerUserName);
                    ovsconf.HttpProxyServerPassword = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_PASSWORD, ovsconf.HttpProxyServerPassword);
                    ovsconf.HttpProxyServerType = (OnlineVideos.MPUrlSourceFilter.ProxyServerType)settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_PROXY_SERVER_TYPE, (int)ovsconf.HttpProxyServerType);

                    ovsconf.RtmpPreferredNetworkInterface = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_RTMP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.RtmpOpenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtmpOpenConnectionTimeout);
                    ovsconf.RtmpOpenConnectionSleepTime = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtmpOpenConnectionSleepTime);
                    ovsconf.RtmpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtmpTotalReopenConnectionTimeout);

                    ovsconf.RtspPreferredNetworkInterface = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_RTSP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.RtspOpenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtspOpenConnectionTimeout);
                    ovsconf.RtspOpenConnectionSleepTime = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtspOpenConnectionSleepTime);
                    ovsconf.RtspTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtspTotalReopenConnectionTimeout);

                    ovsconf.RtspClientPortMin = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MIN, ovsconf.RtspClientPortMin);
                    ovsconf.RtspClientPortMax = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MAX, ovsconf.RtspClientPortMax);

                    ovsconf.UdpRtpPreferredNetworkInterface = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_UDPRTP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.UdpRtpOpenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpOpenConnectionTimeout);
                    ovsconf.UdpRtpOpenConnectionSleepTime = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.UdpRtpOpenConnectionSleepTime);
                    ovsconf.UdpRtpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpTotalReopenConnectionTimeout);
                    ovsconf.UdpRtpReceiveDataCheckInterval = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_RECEIVE_DATA_CHECK_INTERVAL, ovsconf.UdpRtpReceiveDataCheckInterval);
                }
                LoadSitesGroups();
                ovsconf.LoadSites();
            }
            catch (Exception e)
            {
                Log.Instance.Error(e);
            }
        }