Ejemplo n.º 1
0
 public static List<NyaaseRssViewModel> GetItems(string url)
 {
     var items = new List<NyaaseRssViewModel>();
     string xml;
     using (var webClient = new WebClient()) {
         xml = Encoding.UTF8.GetString(webClient.DownloadData(url));
     }
     //xml = xml.Replace("pubDate", "datee");
     var bytes = Encoding.ASCII.GetBytes(xml);
     var reader = XmlReader.Create(new MemoryStream(bytes));
     var feed = SyndicationFeed.Load(reader);
     // "0 seeder(s), 1 leecher(s), 17 download(s) - 281.3 MiB - Remake"
     foreach (var mangs in feed.Items) {
         var summary = Regex.Match(mangs.Summary.Text,
             @"(\d+) seeder\(s\), (\d+) leecher\(s\), (\d+) download\(s\) - (.+\s[a-z]iB)",
             RegexOptions.IgnoreCase);
         var item = new NyaaseRssViewModel {
             Name = mangs.Title.Text,
             Link = mangs.Links[0].Uri.AbsoluteUri,
             Seeder = summary.Groups[1].Value,
             Leecher = summary.Groups[2].Value,
             Downloads = summary.Groups[3].Value,
             Size = summary.Groups[4].Value,
             Color = GetStatus(mangs.Summary.Text)
         };
         if (!items.Contains(item)) {
             items.Add(item);
         }
     }
     return items;
 }
        public void Download(string foldertxt, string filename, NyaaseRssViewModel item, string tf, string tc)
        {
            var selectediten = item;
            if (!Directory.Exists(foldertxt)) {
                Directory.CreateDirectory(foldertxt);
            }
            //var file = Tools.DownloadFile(selectediten.Link, tf + @"\");
            //using (var web = new WebClient())
            //{
            //    web.DownloadFile(new Uri(selectediten.Link),
            //        tf + @"\" + selectediten.Name.Replace("'", string.Empty) + @".torrent");
            //}
            Deluge.openFeeddownload(tc, foldertxt, selectediten.Link);

            var i = new AnimeViewModel {
                Name = selectediten.Name,
                Added = DateTime.Now,
                Tag = Path.Combine(foldertxt, item.Name),
                Status = "Not Watched"
            };
            Global.AnimeAdd = i;

            Tools.showBalloon("Nyaa.se", "Downloading\n" + selectediten.Name);
            GC.Collect();
        }