private static void InitialSitesUpdateAndLoad()
        {
            // clear cache files that might be left over from an application crash
            MPUrlSourceFilter.Downloader.ClearDownloadCache();

            // load translation strings
            TranslationLoader.LoadTranslations(ServiceRegistration.Get <ILocalization>().CurrentCulture.TwoLetterISOLanguageName,
                                               Path.Combine(Path.GetDirectoryName(typeof(OnlineVideosPlugin).Assembly.Location), "Language"), "en", "strings_{0}.xml");

            // load the xml that holds all configured sites
            OnlineVideoSettings.Instance.LoadSites();

            var settingsManager = ServiceRegistration.Get <ISettingsManager>();
            var ovMP2Settings   = settingsManager.Load <Configuration.Settings>();

            // if the current version is compatible and automatic update is enabled and due, run it before loading the site utils
            if (Sites.Updater.VersionCompatible &&
                ovMP2Settings.AutomaticUpdate &&
                ovMP2Settings.LastAutomaticUpdate.AddHours(ovMP2Settings.AutomaticUpdateInterval) < DateTime.Now)
            {
                Sites.Updater.UpdateSites();
                ovMP2Settings.LastAutomaticUpdate = DateTime.Now;
                settingsManager.Save(ovMP2Settings);

                // delete old cached thumbs (todo : no better place to do this for now, should be configurable)
                ImageDownloader.DeleteOldThumbs(30, r => { return(true); });
            }

            // instantiate and initialize all siteutils
            OnlineVideoSettings.Instance.BuildSiteUtilsList();
        }
        public OnlineVideosWorkflowModel()
        {
            SitesList = new ItemsList();

            OnlineVideosAppDomain.UseSeperateDomain = true;

            ServiceRegistration.Get <ISettingsManager>().Load <Configuration.Settings>().SetValuesToApi();
            string ovConfigPath = ServiceRegistration.Get <IPathManager>().GetPath(string.Format(@"<CONFIG>\{0}\", Environment.UserName));
            string ovDataPath   = ServiceRegistration.Get <IPathManager>().GetPath(@"<DATA>\OnlineVideos");

            OnlineVideoSettings.Instance.Logger    = new LogDelegator();
            OnlineVideoSettings.Instance.UserStore = new Configuration.UserSiteSettingsStore();

            OnlineVideoSettings.Instance.DllsDir   = System.IO.Path.Combine(ovDataPath, "SiteUtils");
            OnlineVideoSettings.Instance.ThumbsDir = System.IO.Path.Combine(ovDataPath, "Thumbs");
            OnlineVideoSettings.Instance.ConfigDir = ovConfigPath;

            OnlineVideoSettings.Instance.AddSupportedVideoExtensions(new List <string>()
            {
                ".asf", ".asx", ".flv", ".m4v", ".mov", ".mkv", ".mp4", ".wmv"
            });

            // clear cache files that might be left over from an application crash
            MPUrlSourceFilter.Downloader.ClearDownloadCache();
            // load translation strings in other AppDomain, so SiteUtils can use localized language strings
            TranslationLoader.LoadTranslations(ServiceRegistration.Get <ILocalization>().CurrentCulture.TwoLetterISOLanguageName, System.IO.Path.Combine(System.IO.Path.GetDirectoryName(GetType().Assembly.Location), "Language"), "en", "strings_{0}.xml");
            // The default connection limit is 2 in .Net on most platforms! This means downloading two files will block all other WebRequests.
            System.Net.ServicePointManager.DefaultConnectionLimit = 100;
            // The default .Net implementation for URI parsing removes trailing dots, which is not correct
            Helpers.DotNetFrameworkHelper.FixUriTrailingDots();

            // load the xml that holds all configured sites
            OnlineVideoSettings.Instance.LoadSites();

            // create a message queue where we listen to changes to the sites
            _messageQueue = new AsynchronousMessageQueue(this, new string[] { OnlineVideosMessaging.CHANNEL });
            _messageQueue.MessageReceived += new MessageReceivedHandler(OnlineVideosMessageReceived);

            // listen to changes of configuration settings
            _settingsWatcher = new SettingsChangeWatcher <Configuration.Settings>();
            _settingsWatcher.SettingsChanged += OnlineVideosSettingsChanged;
        }
Exemple #3
0
        static Translator()
        {
            try
            {
                Lang  = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
                _info = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentUICulture);
            }
            catch (Exception)
            {
                Lang  = CultureInfo.CurrentUICulture.Name;
                _info = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentUICulture);
            }

            Log.Instance.Info("Using language '{0}'", Lang);

            string _path = Config.GetSubFolder(Config.Dir.Language, "OnlineVideos");

            if (!Directory.Exists(_path))
            {
                Directory.CreateDirectory(_path);
            }

            Lang = TranslationLoader.LoadTranslations(Lang, _path);
        }