Ejemplo n.º 1
0
 public override Task UpdateManga(MangaViewModel manga)
 {
     var d = Dispatcher.CurrentDispatcher;
     return Task.Factory.StartNew(() =>
     {
         String downloadedPage = DownloadManager.DownloadPage(DetailMangaLink);
         var htmlDoc = new HtmlDocument();
         htmlDoc.LoadHtml(downloadedPage);
         foreach (HtmlNode itemChapter in htmlDoc.DocumentNode.SelectNodes(@"html/body/section[@id='main']/article[@class='widscreen left']/div[@class='mr316']/div[@class='manga_detail']/div[@class='detail_list']/ul[1]/li/span[@class='left']/a[@class='color_0077']"))
         {
             var matches = Regex.Matches(itemChapter.InnerHtml, @"\d+");
             var chapterName = matches[matches.Count - 1].Value;
             var chapterLink = itemChapter.GetAttributeValue("href", "");
             ChapterViewModel chapter = new ChapterViewModel { Name = chapterName };
             chapter.Sources.Add(new MangaHereChapterSource { ChapterLink = chapterLink });
             d.Invoke(() => manga.UpdateOrCreateChapter(chapter));
         }
     });
 }
Ejemplo n.º 2
0
 public override Task UpdateManga(MangaViewModel manga)
 {
     var d = Dispatcher.CurrentDispatcher;
     return Task.Factory.StartNew(() =>
     {
         String downloadedPage = DownloadManager.DownloadPage(DetailMangaLink);
         var htmlDoc = new HtmlDocument();
         htmlDoc.LoadHtml(downloadedPage);
         foreach (HtmlNode itemChapter in htmlDoc.DocumentNode.SelectNodes(@"/html/body/div[@id='container']/div[@id='wrapper_body']/div[@id='chapterlist']/table[@id='listing']/tr/td/a"))
         {
             var matches = Regex.Matches(itemChapter.InnerHtml, @"\d+");
             var chapterName = matches[matches.Count - 1].Value;
             var chapterLink = itemChapter.GetAttributeValue("href", "");
             ChapterViewModel chapter = new ChapterViewModel { Name = chapterName };
             chapter.Sources.Add(new MangaReaderChapterSource { ChapterLink = chapterLink });
             d.Invoke(() => manga.UpdateOrCreateChapter(chapter));
         }
     });
 }
Ejemplo n.º 3
0
 public override Task UpdateRecentChapters(LibraryViewModel l)
 {
     var d = Dispatcher.CurrentDispatcher;
     return Task.Factory.StartNew(() =>
     {
         var v = new WebClient();
         String downloadedPage = DownloadManager.DownloadPage(@"http://www.mangahere.com/latest/");
         var htmlDoc = new HtmlDocument();
         htmlDoc.LoadHtml(downloadedPage);
         foreach (HtmlNode itemManga in htmlDoc.DocumentNode.SelectNodes(@"/html/body/section[@class='page_main']/div[@class='latest_released']/div[@class='manga_updates']/dl"))
         {
             var mangaNode = itemManga.SelectSingleNode(@"dt");
             var mangaName = mangaNode.SelectSingleNode("a").InnerText;
             var mangaDetailLink = mangaNode.SelectSingleNode("a").GetAttributeValue("href", "");
             MangaViewModel manga = new MangaViewModel { Name = mangaName };
             DetailMangaSource detailMangaSource = new MangaHereDetailMangaSource { DetailMangaLink = mangaDetailLink };
             manga.Sources.Add(detailMangaSource);
             d.Invoke(() => manga = l.UpdateOrCreateManga(manga));
             foreach (var itemChapter in itemManga.SelectNodes("dd"))
             {
                 var matches = Regex.Matches(itemChapter.SelectSingleNode("a").InnerText, @"\d+");
                 var chapterName = matches[matches.Count - 1].Value;
                 var chapterLink = mangaNode.SelectSingleNode("a").GetAttributeValue("href", "");
                 ChapterViewModel chapter = new ChapterViewModel { Name = chapterName };
                 chapter.Sources.Add(new MangaHereChapterSource { ChapterLink = chapterLink });
                 d.Invoke(() => manga.UpdateOrCreateChapter(chapter));
             }
             manga.Name = mangaName;
         }
     });
 }
Ejemplo n.º 4
0
 public override Task UpdateRecentChapters(LibraryViewModel l)
 {
     Dispatcher d = Dispatcher.CurrentDispatcher;
     return Task.Factory.StartNew(() =>
     {
         String downloadedPage = DownloadManager.DownloadPage(@"http://www.mangareader.net/latest");
         var htmlDoc = new HtmlDocument();
         htmlDoc.LoadHtml(downloadedPage);
         foreach (HtmlNode itemManga in htmlDoc.DocumentNode.SelectNodes(@"html/body/div[@id='container']/div[@id='wrapper_body']/div[@id='latest']/div[@id='latestchapters']/table[@class='updates']/tr/td[2]"))
         {
             var mangaNode = itemManga.SelectSingleNode(@"a[@class='chapter']");
             var mangaName = mangaNode.InnerText;
             var mangaDetailLink = "http://www.mangareader.net" + mangaNode.GetAttributeValue("href", "");
             MangaViewModel manga = new MangaViewModel { Name = mangaName };
             d.Invoke(() => manga.Sources.Add(new MangaReaderDetailMangaSource { DetailMangaLink = mangaDetailLink }));
             d.Invoke(() => manga = l.UpdateOrCreateManga(manga));
             foreach (var itemChapter in itemManga.SelectNodes(@"a[@class='chaptersrec']"))
             {
                 var matches = Regex.Matches(itemChapter.InnerText, @"\d+");
                 var chapterName = matches[matches.Count - 1].Value;
                 var chapterLink = itemChapter.GetAttributeValue("href", "");
                 ChapterViewModel chapter = new ChapterViewModel { Name = chapterName };
                 chapter.Sources.Add(new MangaReaderChapterSource { ChapterLink = chapterLink });
                 d.Invoke(() => manga.UpdateOrCreateChapter(chapter));
             }
         }
     });
 }
Ejemplo n.º 5
0
 public ChapterViewModel UpdateOrCreateChapter(ChapterViewModel chapter)
 {
     int index = Chapters.IndexOf(chapter);
     if (index != -1)
     {
         return Chapters[index].MergeWith(chapter);
     }
     else
     {
         Chapters.Add(chapter);
         return chapter;
     }
 }
Ejemplo n.º 6
0
 public ChapterViewModel MergeWith(ChapterViewModel chapterToMerge)
 {
     if (chapterToMerge.Name == Name)
     {
         foreach (var sourceToMerge in chapterToMerge.Sources)
         {
             int index = this.Sources.IndexOf(sourceToMerge);
             if (index == -1)
             {
                 Sources.Add(sourceToMerge);
             }
             else
             {
                 Sources[index] = sourceToMerge;
             }
         }
     }
     return this;
 }