Beispiel #1
0
        public SiteUtilBase CreateUtilFromShortName(string name, SiteSettings settings)
        {
            Type result = null;

            if (utils.TryGetValue(name, out result))
            {
                SiteUtilBase util = null;
                try
                {
                    util = (SiteUtilBase)Activator.CreateInstance(result);
                    util.Initialize(settings);
                    return(util);
                }
                catch (Exception ex)
                {
                    Log.Warn("SiteUtil '{0}' is faulty or not compatible with this build of OnlineVideos: {1}", name, ex.Message);
                    return(util);
                }
            }
            else
            {
                Log.Warn(string.Format("SiteUtil with name: {0} not found!", name));
                return(null);
            }
        }
        /// <summary>
        /// Changes the value of a site property
        /// </summary>
        /// <param name="siteName">The name of the Site</param>
        /// <param name="propertygName">The DisplayName of the Property</param>
        /// <param name="value">The new value</param>
        /// <returns></returns>
        public bool SetSiteSetting(string siteName, string propertygName, string value)
        {
            SiteUtilBase site = GetSites().Single(x => x.Settings.Name == siteName);

            if (site == null)
            {
                return(false);
            }
            var property = site.GetUserConfigurationProperties().Single(x => x.DisplayName == propertygName);

            if (property == null)
            {
                return(false);
            }
            try
            {
                site.SetConfigValueFromString(property, value);
            }
            catch (Exception ex)
            {
                Logger.Error("OnlineVideosManager: Error changing Site settings!", ex);
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// We require the command line parameters for the web browser host
        /// Util should be an implementation of IBrowserSiteUtil
        /// </summary>
        /// <param name="util"></param>
        public void Initialise(SiteUtilBase util)
        {
            var browserConfig = (util as IBrowserSiteUtil);

            if (browserConfig != null)
            {
                _automationType = browserConfig.ConnectorEntityTypeName;
                _username       = browserConfig.UserName;
                _password       = browserConfig.Password;
            }
            var emulationSite = util as OnlineVideos.Sites.Interfaces.IBrowserVersionEmulation;

            if (emulationSite != null)
            {
                _emulationLevel  = emulationSite.EmulatedVersion;
                _hostProcessName = _emulationLevel > 10000 ? HOST_PROCESS_NAME_IE : HOST_PROCESS_NAME;
            }
            _lastError = string.Empty;

            _callback.OnBrowserClosing  += _callback_OnBrowserHostClosing;
            _callback.OnBrowserKeyPress += _callback_OnBrowserKeyPress;
            _callback.OnBrowserWndProc  += _callback_OnBrowserWndProc;

            // Wire up to an existing browser process if one exists
            GetRunningProcess(_hostProcessName);
        }
Beispiel #4
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string file = string.Empty;

            if (value is string && !string.IsNullOrEmpty((string)value))
            {
                try { if (System.IO.Path.IsPathRooted(value as string) && System.IO.File.Exists(value as string))
                      {
                          file = value as string;
                      }
                }
                catch { }
            }
            else
            {
                SiteUtilBase site = value as SiteUtilBase;
                if (site == null)
                {
                    var siteViewModel = value as ViewModels.Site;
                    if (siteViewModel != null)
                    {
                        site = siteViewModel.Model;
                    }
                }
                if (site != null)
                {
                    string subDir = string.IsNullOrEmpty(parameter as string) ? "Icons" : parameter as string;
                    // use Icon with the same name as the Site
                    string image = System.IO.Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, subDir + @"/" + site.Settings.Name + ".png");
                    if (System.IO.File.Exists(image))
                    {
                        file = image;
                    }
                    else
                    {
                        // if that does not exist, try icon with the same name as the Util
                        image = System.IO.Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, subDir + @"/" + site.Settings.UtilName + ".png");
                        if (System.IO.File.Exists(image))
                        {
                            file = image;
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(file))
            {
                return(null);
            }

            // load the image, specify CacheOption so the file is not locked
            var bitmapImage = new BitmapImage();

            bitmapImage.BeginInit();
            bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
            bitmapImage.UriSource   = new Uri(file);
            bitmapImage.EndInit();
            return(bitmapImage);
        }
 public static IInformationConnector GetInformationConnector(ConnectorType connectorType, SiteUtilBase siteUtil)
 {     
     if (connectorType == ConnectorType.AmazonPrime)
         return new AmazonPrimeInformationConnector(siteUtil);
     if (connectorType == ConnectorType.AmazonPrimeDe)
         return new AmazonPrimeInformationConnector(siteUtil);
     return null;
 }
 public static IInformationConnector GetInformationConnector(ConnectorType connectorType, SiteUtilBase siteUtil)
 {     
     if (connectorType == ConnectorType.SkyGo)
         return new SkyGoInformationConnector(siteUtil);
     if (connectorType == ConnectorType._4oD)
         return new _4ODInformationConnector(siteUtil);
     return null;
 }
Beispiel #7
0
        public SiteUtilBase CloneFreshSiteFromExisting(SiteUtilBase site)
        {
            // create new instance of this site with reset settings
            SerializableSettings s = new SerializableSettings()
            {
                Sites = new BindingList <SiteSettings>()
            };

            s.Sites.Add(site.Settings);
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            s.Serialize(ms);
            ms.Position = 0;
            SiteSettings originalSettings = SerializableSettings.Deserialize(new StreamReader(ms))[0];

            return(CreateUtilFromShortName(site.Settings.UtilName, originalSettings));
        }
        private static string GetSiteThumbPath(string id)
        {
            string siteName;

            OnlineVideosIdGenerator.DecodeSiteId(id, out siteName);

            SiteUtilBase site = MP2Extended.OnlineVideosManager.GetSites().Single(x => x.Settings.Name == siteName);

            // use Icon with the same name as the Site
            string image = Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, ICONS_DIR + @"/" + site.Settings.Name + ".png");

            if (File.Exists(image))
            {
                return(image);
            }

            // if that does not exist, try icon with the same name as the Util
            image = Path.Combine(OnlineVideoSettings.Instance.ThumbsDir, ICONS_DIR + @"/" + site.Settings.UtilName + ".png");
            return(File.Exists(image) ? image : string.Empty);
        }
Beispiel #9
0
        public void BuildSiteUtilsList()
        {
            SiteUtilsList.Clear();
            LatestVideosSiteUtilsList.Clear();

            if (FavoritesFirst)
            {
                AddFavoritesSite();
                AddDownloadsSite();
            }

            foreach (SiteSettings siteSettings in SiteSettingsList)
            {
                // only need enabled sites
                if (siteSettings.IsEnabled)
                {
                    SiteUtilBase siteutil = SiteUtilFactory.CreateFromShortName(siteSettings.UtilName, siteSettings);
                    if (siteutil != null && !SiteUtilsList.ContainsKey(siteSettings.Name))
                    {
                        SiteUtilsList.Add(siteSettings.Name, siteutil);
                    }
                    if (siteutil is LatestVideosSiteUtilBase)
                    {
                        LatestVideosSiteUtilsList.Add(siteutil as LatestVideosSiteUtilBase);
                    }
                }
            }

            if (!FavoritesFirst)
            {
                AddFavoritesSite();
                AddDownloadsSite();
            }

            SiteUtilsWereBuilt = true;
            Log.Info("Created {0} SiteUtils", SiteUtilsList.Count);
        }
        /// <summary>
        /// Returns the UserSettings for a Site by it's name. It only returns the settings, which are in the Namespace "System", are bool or enum.
        /// </summary>
        /// <param name="siteName"></param>
        /// <returns></returns>
        public List <WebOnlineVideosSiteSetting> GetSiteSettings(string siteName)
        {
            SiteUtilBase site = GetSites().Single(x => x.Settings.Name == siteName);
            List <WebOnlineVideosSiteSetting> output = new List <WebOnlineVideosSiteSetting>();

            foreach (var prop in site.GetUserConfigurationProperties())
            {
                // limit to what the UI can show
                if (prop.IsEnum || prop.IsBool || prop.Namespace == "System")
                {
                    output.Add(new WebOnlineVideosSiteSetting
                    {
                        SiteId         = OnlineVideosIdGenerator.BuildSiteId(siteName),
                        Name           = prop.DisplayName,
                        Description    = prop.Description,
                        Value          = site.GetConfigValueAsString(prop),
                        PossibleValues = prop.IsEnum ? prop.GetEnumValues() : new string[0],
                        IsBool         = prop.IsBool
                    });
                }
                //Logger.Info("SiteSetting: {0} - {1} isBool: {2} isEnum: {3} EnumValues: {4} Value: {5} NameSpace: {6}", site.Settings.Name, prop.DisplayName, prop.IsBool.ToString(), prop.IsEnum.ToString(), prop.IsEnum ? string.Join(", ", prop.GetEnumValues()) : "", site.GetConfigValueAsString(prop), prop.Namespace);
            }
            return(output);
        }
Beispiel #11
0
        /// <summary>
        /// We require the command line parameters for the web browser host
        /// Util should be an implementation of IBrowserSiteUtil
        /// </summary>
        /// <param name="util"></param>
        public void Initialise(SiteUtilBase util)
        {
            var browserConfig = (util as IBrowserSiteUtil);

            if (browserConfig != null)
            {
                _automationType = browserConfig.ConnectorEntityTypeName;
                _username       = browserConfig.UserName;
                _password       = browserConfig.Password;
            }
            _lastError = string.Empty;

            _callback.OnBrowserClosing  += _callback_OnBrowserHostClosing;
            _callback.OnBrowserKeyPress += _callback_OnBrowserKeyPress;
            _callback.OnBrowserWndProc  += _callback_OnBrowserWndProc;

            // Wire up to an existing browser process if one exists
            var processes = System.Diagnostics.Process.GetProcessesByName("OnlineVideos.WebAutomation.BrowserHost");

            if (processes != null && processes.Count() > 0)
            {
                _browserProcess = processes[0];
            }
        }
 public SkyGoInformationConnector(SiteUtilBase siteUtil)
 {
     _siteUtil = siteUtil;
 }
Beispiel #13
0
 public _4ODInformationConnector(SiteUtilBase siteUtil)
 {
     _siteUtil   = siteUtil;
     defaultLogo = string.Format(@"{0}\Icons\{1}.png", OnlineVideoSettings.Instance.ThumbsDir, siteUtil.Settings.Name);
 }
 public AmazonPrimeInformationConnector(SiteUtilBase siteUtil)
 {
     _siteUtil = siteUtil;
     _browserSession = new AmazonBrowserSession();
 }
 public static IInformationConnector GetInformationConnector(ConnectorType connectorType, SiteUtilBase siteUtil)
 {
     if (connectorType == ConnectorType.SkyGo)
     {
         return(new SkyGoInformationConnector(siteUtil));
     }
     if (connectorType == ConnectorType._4oD)
     {
         return(new _4ODInformationConnector(siteUtil));
     }
     return(null);
 }
Beispiel #16
0
 public AmazonPrimeInformationConnector(SiteUtilBase siteUtil)
 {
     _siteUtil       = siteUtil;
     _browserSession = new AmazonBrowserSession();
 }
Beispiel #17
0
 public static IInformationConnector GetInformationConnector(ConnectorType connectorType, SiteUtilBase siteUtil)
 {
     if (connectorType == ConnectorType.AmazonPrime)
     {
         return(new AmazonPrimeInformationConnector(siteUtil));
     }
     if (connectorType == ConnectorType.AmazonPrimeDe)
     {
         return(new AmazonPrimeInformationConnector(siteUtil));
     }
     return(null);
 }
 public WindowSiteSettings(SiteUtilBase site) : this()
 {
     this.site = site;
     GenerateOptions();
 }
Beispiel #19
0
 public SkyGoInformationConnector(SiteUtilBase siteUtil)
 {
     _siteUtil = siteUtil;
 }
 public _4ODInformationConnector(SiteUtilBase siteUtil)
 {
     _siteUtil = siteUtil;
     defaultLogo = string.Format(@"{0}\Icons\{1}.png", OnlineVideoSettings.Instance.ThumbsDir, siteUtil.Settings.Name);
 }