Exemple #1
0
        private static IEnumerable <TorzNabResult> ParseTorzNabXml(string content)
        {
            TorzNabConfig torzNabConfig = ConfigManager.GetConfig <TorzNabConfig>();
            var           list          = new List <TorzNabResult>();
            var           doc           = new XmlDocument();

            doc.LoadXml(content);

            var items = doc.SelectNodes("//item");

            if (items == null)
            {
                return(list);
            }

            foreach (XmlNode item in items)
            {
                var torzNabResult = new TorzNabResult();

                foreach (XmlNode attribute in item.ChildNodes)
                {
                    switch (attribute.Name)
                    {
                    case "title":
                        torzNabResult.Title = attribute.InnerText;
                        continue;

                    case "jackettindexer":
                        torzNabResult.JackettIndexer = attribute.InnerText;
                        continue;

                    case "files":
                        torzNabResult.Files = attribute.InnerText;
                        continue;

                    case "guid":
                        torzNabResult.Guid = attribute.InnerText;
                        continue;

                    case "grabs":
                        torzNabResult.Grabs = attribute.InnerText;
                        continue;

                    case "link":
                        if (string.IsNullOrEmpty(torzNabConfig.LinkSubFind))
                        {
                            torzNabResult.Link = attribute.InnerText.Replace("&amp;", "&");
                        }
                        else
                        {
                            string link = attribute.InnerText.Replace("&amp;", "&");
                            link = link.Replace(torzNabConfig.LinkSubFind,
                                                torzNabConfig.LinkSubReplace);
                            torzNabResult.Link = link;
                        }

                        continue;

                    case "description":
                        torzNabResult.Description = attribute.InnerText;
                        continue;

                    case "comments":
                        torzNabResult.Comments = attribute.InnerText;
                        continue;

                    case "size":
                        torzNabResult.Size = attribute.InnerText;
                        continue;

                    case "pubDate":
                        torzNabResult.PublishDate = attribute.InnerText;
                        continue;
                    }


                    if (attribute.Attributes?.GetNamedItem("name")?.InnerText == "category")
                    {
                        if (torzNabResult.Categories == null)
                        {
                            torzNabResult.Categories = new List <string>();
                        }
                        torzNabResult.Categories.Add(attribute.Attributes?.GetNamedItem("value")?.InnerText);
                    }

                    if (attribute.Attributes?.GetNamedItem("name")?.InnerText == "peers")
                    {
                        torzNabResult.Peers = attribute.Attributes?.GetNamedItem("value")?.InnerText;
                    }

                    if (attribute.Attributes?.GetNamedItem("name")?.InnerText == "seeders")
                    {
                        torzNabResult.Seeders = attribute.Attributes?.GetNamedItem("value")?.InnerText;
                    }
                }


                list.Add(torzNabResult);
            }


            return(list);
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtRTorrentHost.Text))
            {
                var rTorrentConfig = ConfigManager.GetConfig <RTorrentConfig>();
                rTorrentConfig.Password = txtRTorrentPassword.Text;
                rTorrentConfig.Host     = txtRTorrentHost.Text;
                rTorrentConfig.Port     = txtRTorrentPort.Text;
                rTorrentConfig.UrlBase  = txtRTorrentUrlBase.Text;
                rTorrentConfig.UseSsl   = chkRTorrentHttps.Checked;
                rTorrentConfig.Username = txtRTorrentUserName.Text;
                ConfigManager.SetConfigValue(rTorrentConfig);
            }

            if (!string.IsNullOrEmpty(txtComicVineApiKey.Text))
            {
                var comicVineConfig = new ComicVineConfig()
                {
                    ApiKey = txtComicVineApiKey.Text
                };

                ConfigManager.SetConfigValue(comicVineConfig);
            }


            if (!string.IsNullOrEmpty(txtAPIkey.Text))
            {
                var sabConfig = new SabConfig
                {
                    ApIkey   = txtAPIkey.Text,
                    HostUrl  = txtHost.Text,
                    UserName = txtUserName.Text,
                    Password = txtPassword.Text,
                    Root     = txtSabRoot.Text,
                    Https    = chkSabSsl.Checked
                };
                if (txtSabPort.Text != null)
                {
                    if (!string.IsNullOrEmpty(txtSabPort.Text))
                    {
                        sabConfig.Port = int.Parse(txtSabPort.Text);
                    }
                }

                ConfigManager.SetConfigValue(sabConfig);
            }
            if (!string.IsNullOrEmpty(txtMylarApiKey.Text))
            {
                var mylarConfig = new MylarConfig
                {
                    APIkey   = txtMylarApiKey.Text,
                    HostURL  = txtMylarHost.Text,
                    UserName = txtMylarUserName.Text,
                    Password = txtMylarPassword.Text
                };

                ConfigManager.SetConfigValue(mylarConfig);
            }

            if (!string.IsNullOrEmpty(txtTorzNabHost1.Text) || !string.IsNullOrEmpty(txtTorzNabHost2.Text) ||
                !string.IsNullOrEmpty(txtTorzNabHost3.Text) || !string.IsNullOrEmpty(txtTorzNabHost4.Text))
            {
                var torzNabConfig = new TorzNabConfig
                {
                    TorzNabName_1    = txtTorzNabName1.Text,
                    TorzNabApiKey_1  = txtTorzNabApiKey1.Text,
                    TorzNabURL_1     = txtTorzNabHost1.Text,
                    TorzNabEnabled_1 = chkTorzNabEnabled1.Checked,
                    TorzNabName_2    = txtTorzNabName2.Text,
                    TorzNabApiKey_2  = txtTorzNabApiKey2.Text,
                    TorzNabURL_2     = txtTorzNabHost2.Text,
                    TorzNabEnabled_2 = chkTorzNabEnabled2.Checked,
                    TorzNabName_3    = txtTorzNabName3.Text,
                    TorzNabApiKey_3  = txtTorzNabApiKey3.Text,
                    TorzNabURL_3     = txtTorzNabHost3.Text,
                    TorzNabEnabled_3 = chkTorzNabEnabled3.Checked,
                    TorzNabName_4    = txtTorzNabName4.Text,
                    TorzNabApiKey_4  = txtTorzNabApiKey4.Text,
                    TorzNabURL_4     = txtTorzNabHost4.Text,
                    TorzNabEnabled_4 = chkTorzNabEnabled4.Checked,
                    LinkSubFind      = txtLinkSubFind.Text,
                    LinkSubReplace   = txtLinkSubReplace.Text
                };



                ConfigManager.SetConfigValue(torzNabConfig);
            }

            if (!string.IsNullOrEmpty(txtNewzHost1.Text) || !string.IsNullOrEmpty(txtNewzHost2.Text) ||
                !string.IsNullOrEmpty(txtNewzHost3.Text) || !string.IsNullOrEmpty(txtNewzHost4.Text))
            {
                var newzNabConfig = new NewzNabConfig
                {
                    NewzNabName_1    = txtNewzName1.Text,
                    NewzNabApiKey_1  = txtNewzApi1.Text,
                    NewzNabURL_1     = txtNewzHost1.Text,
                    NewzNabEnabled_1 = chkNewzNabEnabled1.Checked,
                    NewzNabName_2    = txtNewzName2.Text,
                    NewzNabApiKey_2  = txtNewzApi2.Text,
                    NewzNabURL_2     = txtNewzHost2.Text,
                    NewzNabEnabled_2 = chkNewzNabEnabled2.Checked,
                    NewzNabName_3    = txtNewzName3.Text,
                    NewzNabApiKey_3  = txtNewzApi3.Text,
                    NewzNabURL_3     = txtNewzHost3.Text,
                    NewzNabEnabled_3 = chkNewzNabEnabled3.Checked,
                    NewzNabName_4    = txtNewzName4.Text,
                    NewzNabApiKey_4  = txtNewzApi4.Text,
                    NewzNabURL_4     = txtNewzHost4.Text,
                    NewzNabEnabled_4 = chkNewzNabEnabled4.Checked
                };

                ConfigManager.SetConfigValue(newzNabConfig);
            }


            ConfigManager.Save();

            Close();
        }