Exemplo n.º 1
0
        public static List <NewzNabSearchResult> Search(Issue issue, Comic comic)
        {
            var results = new List <NewzNabSearchResult>();

            if (!ConfigManager.HasValue <NewzNabConfig>())
            {
                return(null);
            }

            var newzNabConfig = ConfigManager.GetConfig <NewzNabConfig>();

            if (!string.IsNullOrEmpty(newzNabConfig.NewzNabURL_1) && newzNabConfig.NewzNabEnabled_1)
            {
                try
                {
                    results.AddRange(NewzNabManager.SearchForIssue(issue, comic, newzNabConfig.NewzNabURL_1,
                                                                   newzNabConfig.NewzNabApiKey_1, newzNabConfig.NewzNabName_1));
                }
                catch
                {
                    //disable provider
                    newzNabConfig.NewzNabEnabled_1 = false;
                    ConfigManager.SetConfigValue(newzNabConfig);
                    ConfigManager.Save();
                }
            }

            if (!string.IsNullOrEmpty(newzNabConfig.NewzNabURL_2) && newzNabConfig.NewzNabEnabled_2)
            {
                try
                {
                    results.AddRange(NewzNabManager.SearchForIssue(issue, comic, newzNabConfig.NewzNabURL_2,
                                                                   newzNabConfig.NewzNabApiKey_2, newzNabConfig.NewzNabName_2));
                }
                catch
                {
                    //disable provider
                    newzNabConfig.NewzNabEnabled_1 = false;
                    ConfigManager.SetConfigValue(newzNabConfig);
                    ConfigManager.Save();
                }
            }

            if (!string.IsNullOrEmpty(newzNabConfig.NewzNabURL_3) && newzNabConfig.NewzNabEnabled_3)
            {
                try
                {
                    results.AddRange(NewzNabManager.SearchForIssue(issue, comic, newzNabConfig.NewzNabURL_3,
                                                                   newzNabConfig.NewzNabApiKey_3, newzNabConfig.NewzNabName_3));
                }
                catch
                {
                    //disable provider
                    newzNabConfig.NewzNabEnabled_3 = false;
                    ConfigManager.SetConfigValue(newzNabConfig);
                    ConfigManager.Save();
                }
            }

            if (!string.IsNullOrEmpty(newzNabConfig.NewzNabURL_4) && newzNabConfig.NewzNabEnabled_4)
            {
                try
                {
                    results.AddRange(NewzNabManager.SearchForIssue(issue, comic, newzNabConfig.NewzNabURL_4,
                                                                   newzNabConfig.NewzNabApiKey_4, newzNabConfig.NewzNabName_4));
                }
                catch
                {
                    //disable provider
                    newzNabConfig.NewzNabEnabled_4 = false;
                    ConfigManager.SetConfigValue(newzNabConfig);
                    ConfigManager.Save();
                }
            }


            return(results);
        }
Exemplo n.º 2
0
 private static ComicVineConfig GetConfig()
 {
     return(_comicVineConfig ?? (_comicVineConfig = ConfigManager.GetConfig <ComicVineConfig>()));
 }
Exemplo n.º 3
0
 private static MylarConfig GetConfig()
 {
     return(_mylarConfig ?? (_mylarConfig = ConfigManager.GetConfig <MylarConfig>()));
 }
Exemplo n.º 4
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);
        }