コード例 #1
0
ファイル: RTorrentManager.cs プロジェクト: kctec/MylarSideCar
        public static void AddTorrent(TorzNabResult torsNabResult)
        {
            var config = ConfigManager.GetConfig <RTorrentConfig>();

            var client = new RTorrentProxy(Logger);

            client.AddTorrentFromUrl(torsNabResult.Link, "mylar", RTorrentPriority.Normal, "", false, config);
        }
コード例 #2
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);
        }