Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();
            generic = new GenericSiteUtil();
            generic.Initialize(new SiteSettings());
            generic.Settings.Name        = "please fill";
            generic.Settings.Description = "please fill";
            generic.Settings.Language    = "en";
            generic.Settings.UtilName    = "GenericSite";
            foreach (PlayerType pt in Enum.GetValues(typeof(PlayerType)))
            {
                playerComboBox.Items.Add(pt);
            }
            foreach (GenericSiteUtil.HosterResolving pt in Enum.GetValues(typeof(GenericSiteUtil.HosterResolving)))
            {
                comboBoxResolving.Items.Add(pt);
            }
            playerComboBox.SelectedIndex = 0;

            FillDecodingCombo(categoryUrlDecodingComboBox);
            FillDecodingCombo(subCategoryUrlDecodingComboBox);
            FillDecodingCombo(nextPageUrlDecodingComboBox);
            FillDecodingCombo(videoListUrlDecodingComboBox);
            FillDecodingCombo(videoUrlDecodingComboBox);
            FillDecodingCombo(fileUrlDecodingComboBox);
            FillDecodingCombo(fileUrlNameDecodingComboBox);

            FillLanguagesComboBox();

            UtilToGui(generic);
#if !DEBUG
            debugToolStripMenuItem.Visible = false;
#endif
        }
Ejemplo n.º 2
0
        private string GetRegex(GenericSiteUtil site, string regexName)
        {
            Regex r = (Regex)GetProperty(site, regexName);

            if (r == null)
            {
                return(String.Empty);
            }
            return(r.ToString().TrimStart('{').TrimEnd('}'));
        }
Ejemplo n.º 3
0
        private void GuiToUtil(GenericSiteUtil util)
        {
            util.Settings.Name = nameTextBox.Text;
            SetProperty(util, "baseUrl", baseUrlTextbox.Text);
            util.Settings.Description = descriptionTextBox.Text;
            util.Settings.Player      = (PlayerType)playerComboBox.SelectedItem;
            util.Settings.ConfirmAge  = ageCheckBox.Checked;
            SetProperty(util, "forceUTF8Encoding", forceUtf8CheckBox.Checked);
            string[] cookies = cookiesTextBox.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            SetProperty(util, "cookies", String.Join(",", cookies));

            util.Settings.Language = cbLanguages.SelectedValue.ToString();

            SetRegex(util, "regEx_dynamicCategories", "dynamicCategoriesRegEx", categoryRegexTextbox.Text);
            SetProperty(util, "dynamicCategoryUrlFormatString", categoryUrlFormatTextBox.Text);
            SetProperty(util, "dynamicCategoryUrlDecoding", categoryUrlDecodingComboBox.SelectedItem);
            SetRegex(util, "regEx_dynamicCategoriesNextPage", "dynamicCategoriesNextPageRegEx", categoryNextPageRegexTextBox.Text);

            SetRegex(util, "regEx_dynamicSubCategories", "dynamicSubCategoriesRegEx", subcategoryRegexTextBox.Text);
            SetProperty(util, "dynamicSubCategoryUrlFormatString", subcategoryUrlFormatTextBox.Text);
            SetProperty(util, "dynamicSubCategoryUrlDecoding", subCategoryUrlDecodingComboBox.SelectedItem);
            SetRegex(util, "regEx_dynamicSubCategoriesNextPage", "dynamicSubCategoriesNextPageRegEx", subcategoryNextPageRegexTextBox.Text);

            SetRegex(util, "regEx_VideoList", "videoListRegEx", videoListRegexTextBox.Text);
            SetProperty(util, "videoListRegExFormatString", videoListRegexFormatTextBox.Text);

            SetProperty(util, "videoThumbFormatString", videoThumbFormatStringTextBox.Text);

            SetRegex(util, "regEx_NextPage", "nextPageRegEx", nextPageRegExTextBox.Text);
            SetProperty(util, "nextPageRegExUrlFormatString", nextPageRegExUrlFormatStringTextBox.Text);
            SetProperty(util, "nextPageRegExUrlDecoding", nextPageUrlDecodingComboBox.SelectedItem);

            SetRegex(util, "regEx_VideoUrl", "videoUrlRegEx", videoUrlRegExTextBox.Text);
            SetProperty(util, "videoUrlFormatString", videoUrlFormatStringTextBox.Text);
            SetProperty(util, "videoListUrlDecoding", videoListUrlDecodingComboBox.SelectedItem);
            SetProperty(util, "videoUrlDecoding", videoUrlDecodingComboBox.SelectedItem);

            SetProperty(util, "searchUrl", searchUrlTextBox.Text);
            SetProperty(util, "searchPostString", searchPostStringTextBox.Text);

            SetRegex(util, "regEx_PlaylistUrl", "playlistUrlRegEx", playlistUrlRegexTextBox.Text);
            SetProperty(util, "playlistUrlFormatString", playlistUrlFormatStringTextBox.Text);

            SetRegex(util, "regEx_FileUrl", "fileUrlRegEx", fileUrlRegexTextBox.Text);
            SetProperty(util, "fileUrlDecoding", fileUrlDecodingComboBox.SelectedItem);
            SetProperty(util, "fileUrlFormatString", fileUrlFormatStringTextBox.Text);
            SetProperty(util, "fileUrlPostString", fileUrlPostStringTextBox.Text);
            SetProperty(util, "fileUrlNameFormatString", fileUrlNameFormatStringTextBox.Text);
            SetProperty(util, "fileUrlNameDecoding", fileUrlNameDecodingComboBox.SelectedItem);
            SetProperty(util, "getRedirectedFileUrl", getRedirectedFileUrlCheckBox.Checked);
            SetProperty(util, "resolveHoster", comboBoxResolving.SelectedItem);
        }
Ejemplo n.º 4
0
        private void SetRegex(GenericSiteUtil site, string regexName, string propertyName, string value)
        {
            Regex r;

            if (String.IsNullOrEmpty(value))
            {
                r = null;
            }
            else
            {
                r = new Regex(value, RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture);
            }
            SetProperty(site, regexName, r);
            SetProperty(site, propertyName, value);
        }
Ejemplo n.º 5
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            // Load settings from selected site into TextBoxes
            SiteSettings siteSettings = comboBoxSites.SelectedItem as SiteSettings;

            if (siteSettings != null)
            {
                generic = new GenericSiteUtil();
                generic.Initialize(siteSettings);
                staticList = new List <RssLink>();
                foreach (RssLink cat in generic.Settings.Categories)
                {
                    staticList.Add(cat);
                }

                UtilToGui(generic);

                LoadIconAndBanner();
            }
        }
Ejemplo n.º 6
0
 private object GetProperty(GenericSiteUtil site, string propertyName)
 {
     return(typeof(GenericSiteUtil).InvokeMember(propertyName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, site, null));
 }
Ejemplo n.º 7
0
 private void SetProperty(GenericSiteUtil site, string propertyName, object value)
 {
     typeof(GenericSiteUtil).InvokeMember(propertyName, BindingFlags.NonPublic | BindingFlags.Instance |
                                          BindingFlags.SetField, null, site, new[] { value });
 }
Ejemplo n.º 8
0
        private void UtilToGui(GenericSiteUtil util)
        {
            nameTextBox.Text = util.Settings.Name;

            baseUrlTextbox.Text          = (string)GetProperty(util, "baseUrl");
            descriptionTextBox.Text      = util.Settings.Description;
            playerComboBox.SelectedIndex = playerComboBox.Items.IndexOf(util.Settings.Player);
            ageCheckBox.Checked          = util.Settings.ConfirmAge;
            forceUtf8CheckBox.Checked    = GetForceUTF8();
            string cookieString = (string)GetProperty(util, "cookies");

            if (!String.IsNullOrEmpty(cookieString))
            {
                string[] cookies = cookieString.Split(',');
                cookiesTextBox.Text = String.Join(Environment.NewLine, cookies);
            }
            else
            {
                cookiesTextBox.Text = String.Empty;
            }
            cbLanguages.SelectedValue = util.Settings.Language;

            categoryRegexTextbox.Text                = GetRegex(util, "regEx_dynamicCategories");
            categoryUrlFormatTextBox.Text            = (string)GetProperty(util, "dynamicCategoryUrlFormatString");
            categoryUrlDecodingComboBox.SelectedItem = (GenericSiteUtil.UrlDecoding)GetProperty(util, "dynamicCategoryUrlDecoding");
            categoryNextPageRegexTextBox.Text        = (string)GetRegex(util, "regEx_dynamicCategoriesNextPage");

            subcategoryRegexTextBox.Text                = GetRegex(util, "regEx_dynamicSubCategories");
            subcategoryUrlFormatTextBox.Text            = (string)GetProperty(util, "dynamicSubCategoryUrlFormatString");
            subCategoryUrlDecodingComboBox.SelectedItem = (GenericSiteUtil.UrlDecoding)GetProperty(util, "dynamicSubCategoryUrlDecoding");
            subcategoryNextPageRegexTextBox.Text        = (string)GetRegex(util, "regEx_dynamicSubCategoriesNextPage");

            videoListRegexTextBox.Text       = GetRegex(util, "regEx_VideoList");
            videoListRegexFormatTextBox.Text = (string)GetProperty(util, "videoListRegExFormatString");

            videoThumbFormatStringTextBox.Text = (string)GetProperty(util, "videoThumbFormatString");

            nextPageRegExTextBox.Text = GetRegex(util, "regEx_NextPage");
            nextPageRegExUrlFormatStringTextBox.Text = (string)GetProperty(util, "nextPageRegExUrlFormatString");
            nextPageUrlDecodingComboBox.SelectedItem = (GenericSiteUtil.UrlDecoding)GetProperty(util, "nextPageRegExUrlDecoding");

            videoUrlRegExTextBox.Text                 = GetRegex(util, "regEx_VideoUrl");
            videoUrlFormatStringTextBox.Text          = (string)GetProperty(util, "videoUrlFormatString");
            videoListUrlDecodingComboBox.SelectedItem = (GenericSiteUtil.UrlDecoding)GetProperty(util, "videoListUrlDecoding");
            videoUrlDecodingComboBox.SelectedItem     = (GenericSiteUtil.UrlDecoding)GetProperty(util, "videoUrlDecoding");

            searchUrlTextBox.Text        = GetProperty(util, "searchUrl") as string;
            searchPostStringTextBox.Text = GetProperty(util, "searchPostString") as string;

            playlistUrlRegexTextBox.Text        = GetRegex(util, "regEx_PlaylistUrl");
            playlistUrlFormatStringTextBox.Text = (string)GetProperty(util, "playlistUrlFormatString");

            fileUrlRegexTextBox.Text                 = GetRegex(util, "regEx_FileUrl");
            fileUrlFormatStringTextBox.Text          = (string)GetProperty(util, "fileUrlFormatString");
            fileUrlDecodingComboBox.SelectedItem     = (GenericSiteUtil.UrlDecoding)GetProperty(util, "fileUrlDecoding");
            fileUrlPostStringTextBox.Text            = (string)GetProperty(util, "fileUrlPostString");
            fileUrlNameFormatStringTextBox.Text      = (string)GetProperty(util, "fileUrlNameFormatString");
            fileUrlNameDecodingComboBox.SelectedItem = (GenericSiteUtil.UrlDecoding)GetProperty(util, "fileUrlNameDecoding");
            getRedirectedFileUrlCheckBox.Checked     = (bool)GetProperty(util, "getRedirectedFileUrl");
            comboBoxResolving.SelectedItem           = (GenericSiteUtil.HosterResolving)GetProperty(util, "resolveHoster");

            treeView1.Nodes.Clear();
            TreeNode root = treeView1.Nodes.Add("site");

            foreach (Category cat in staticList)
            {
                root.Nodes.Add(cat.Name).Tag = cat;
                cat.HasSubCategories         = true;
            }
            if (root.Nodes.Count > 0)
            {
                root.Expand();
            }
        }