public MangaViewModel UpdateOrCreateManga(MangaViewModel manga)
 {
     var index = Mangas.IndexOf(manga);
     if (index == -1)
     {
         Mangas.Add(manga);
         return manga;
     }
     else
     {
         return Mangas[index].MergeWith(manga);
     }
 }
 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));
         }
     });
 }
 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));
         }
     });
 }
 public MangaViewModel MergeWith(MangaViewModel mangaToMerge)
 {
     if (mangaToMerge.Name == Name)
     {
         foreach (DetailMangaSource sourceToMerge in mangaToMerge.Sources)
         {
             var s = sourceToMerge.ToString();
             int index = this.Sources.IndexOf(sourceToMerge);
             if (index == -1)
             {
                 Sources.Add(sourceToMerge);
             }
             else
             {
                 Sources[index] = sourceToMerge;
             }
         }
     }
     return this;
 }
 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;
         }
     });
 }
 public override Task UpdateChapter(MangaViewModel m)
 {
     throw new NotImplementedException();
 }
 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));
             }
         }
     });
 }
Beispiel #8
0
 public abstract Task UpdateManga(MangaViewModel m);
Beispiel #9
0
 public abstract Task UpdateChapter(MangaViewModel m);