/// <summary> /// Добавить мангу. /// </summary> /// <param name="uri">Ссылка на мангу.</param> public async Task <(bool Success, IManga Manga)> Add(Uri uri) { using (var context = Repository.GetEntityContext()) { var manga = await context.Get <IManga>().FirstOrDefaultAsync(m => m.Uri == uri).ConfigureAwait(false); if (manga != null) { Log.Info("Манга уже добавлена."); return(false, manga); } } var newManga = await Mangas.CreateFromWeb(uri).ConfigureAwait(false); if (newManga == null || !await newManga.IsValid().ConfigureAwait(false)) { Log.Info("Не удалось найти мангу."); return(false, null); } OnLibraryChanged(new LibraryViewModelArgs(null, newManga, MangaOperation.Added, LibraryOperation.UpdateMangaChanged)); Log.Info(Strings.Library_Status_MangaAdded + newManga.Name); return(true, newManga); }
private async Task <Acomics.Acomics> GetManga(string uri) { var manga = await Mangas.CreateFromWeb(new Uri(uri)).ConfigureAwait(false) as Acomics.Acomics; await new Parser().UpdateContent(manga).ConfigureAwait(false); return(manga); }
public async Task ValidateStatusAndDescription(MangaInfo mangaInfo) { IManga manga; using (var context = Repository.GetEntityContext("Description")) { var mangaUri = new Uri(mangaInfo.Uri); var existsManga = await context.Get <IManga>().FirstOrDefaultAsync(m => m.Uri == mangaUri).ConfigureAwait(false); if (existsManga != null) { await context.Delete(existsManga).ConfigureAwait(false); } manga = await Mangas.CreateFromWeb(mangaUri).ConfigureAwait(false); } Assert.AreEqual(mangaInfo.Description, manga.Description); if (Equals(mangaInfo.Status, manga.Status)) { Assert.Pass(); } else { var storedWords = GetWords(mangaInfo.Status); var downloaded = GetWords(manga.Status); var changes = storedWords.Except(downloaded).Count() + downloaded.Except(storedWords).Count(); // Status can contain regular changed info, try to compare Assert.LessOrEqual(changes, 2); } }
public static async Task <MangaInfo> Generate(InfoCacheAttribute cacheAttribute) { var info = new MangaInfo(); info.Uri = cacheAttribute.Uri; var manga = await Mangas.CreateFromWeb(new Uri(cacheAttribute.Uri)).ConfigureAwait(false); if (cacheAttribute.Downloadable) { await manga.Download().ConfigureAwait(false); var files = Directory.GetFiles(manga.GetAbsoluteFolderPath(), "*", SearchOption.AllDirectories); var fileInfos = files.Select(f => new FileInfo(f)).ToList(); info.FilesInFolder = fileInfos.Count; info.FolderSize = fileInfos.Sum(f => f.Length); info.AllFilesUnique = 1 == fileInfos.GroupBy(f => f.Length).Max(g => g.Count()); } info.Status = manga.Status; info.Description = manga.Description; return(info); }
public async Task DownloadReadmanga() { var rm = Mangas.CreateFromWeb(new Uri(@"http://readmanga.me/black_butler_anthology_comic_dj____rainbow_butler")); var sw = new Stopwatch(); sw.Start(); rm.PropertyChanged += RmOnDownloadChanged; DirectoryHelpers.DeleteDirectory(rm.GetAbsoulteFolderPath()); await rm.Download(); sw.Stop(); Log.Add($"manga loaded {sw.Elapsed.TotalSeconds}, iscompleted = {rm.IsDownloaded}, lastpercent = {lastPercent}"); Assert.IsTrue(Directory.Exists(rm.GetAbsoulteFolderPath())); var files = Directory.GetFiles(rm.GetAbsoulteFolderPath(), "*", SearchOption.AllDirectories); Assert.AreEqual(212, files.Length); var fileInfos = files.Select(f => new FileInfo(f)).ToList(); Assert.AreEqual(67470935, fileInfos.Sum(f => f.Length)); // Количество повторяющихся картинок на мангу - не больше одной на главу. Assert.IsTrue(rm.Volumes.Sum(v => v.Container.Count()) >= fileInfos.GroupBy(f => f.Length).Max(g => g.Count())); Assert.IsTrue(rm.IsDownloaded); Assert.AreEqual(100, lastPercent); }
public void MintmangaBonus() { var manga = Mangas.CreateFromWeb(new Uri("http://mintmanga.com/haruka_na_receive")); manga.Parser.UpdateContent(manga); var chapters = manga.Volumes.SelectMany(v => v.Container).OfType <Grouple.GroupleChapter>(); Assert.AreEqual(1, chapters.Count(c => c.VolumeNumber == 1 && c.Number == 0)); }
public async Task MintmangaBonus() { var manga = await Mangas.CreateFromWeb(new Uri("https://mintmanga.live/harukana_receive")).ConfigureAwait(false); await manga.Parser.UpdateContent(manga).ConfigureAwait(false); var chapters = manga.Volumes.SelectMany(v => v.Container).OfType <Grouple.GroupleChapter>(); Assert.AreEqual(1, chapters.Count(c => c.VolumeNumber == 1 && c.Number == 0)); }
private async Task <Hentaichan.Hentaichan> GetManga(string url) { await Login().ConfigureAwait(false); var manga = await Mangas.CreateFromWeb(new Uri(url)).ConfigureAwait(false) as Hentaichan.Hentaichan; await Unlogin().ConfigureAwait(false); return(manga); }
public void ReadmangaBonus() { var manga = Mangas.CreateFromWeb(new Uri("http://readmanga.me/animal_country")); manga.Parser.UpdateContent(manga); var chapters = manga.Volumes.SelectMany(v => v.Container).OfType <Grouple.GroupleChapter>(); Assert.AreEqual(1, chapters.Count(c => c.VolumeNumber == 14 && c.Number == 54)); Assert.AreEqual(1, chapters.Count(c => c.VolumeNumber == 6 && c.Number == 22)); }
public void MangachanBonus() { var manga = Mangas.CreateFromWeb(new Uri("http://mangachan.me/manga/5335-the-breaker-new-waves.html")); manga.Parser.UpdateContent(manga); var chapters = manga.Volumes.SelectMany(v => v.Container).ToList(); Assert.AreEqual(1, chapters.Count(c => c.Number == 170)); Assert.AreEqual(1, chapters.Count(c => c.Number == 170.1)); }
public async Task MangachanBonus() { var manga = await Mangas.CreateFromWeb(new Uri("https://manga-chan.me/manga/5335-the-breaker-new-waves.html")).ConfigureAwait(false); await manga.Parser.UpdateContent(manga).ConfigureAwait(false); var chapters = manga.Volumes.SelectMany(v => v.Container).ToList(); Assert.AreEqual(1, chapters.Count(c => c.Number == 170)); Assert.AreEqual(1, chapters.Count(c => c.Number == 170.1)); }
public async Task ReadmangaBonus() { var manga = await Mangas.CreateFromWeb(new Uri("https://readmanga.io/animal_country")).ConfigureAwait(false); await manga.Parser.UpdateContent(manga).ConfigureAwait(false); var chapters = manga.Volumes.SelectMany(v => v.Container).OfType <Grouple.GroupleChapter>(); Assert.AreEqual(1, chapters.Count(c => c.VolumeNumber == 14 && c.Number == 54)); Assert.AreEqual(1, chapters.Count(c => c.VolumeNumber == 6 && c.Number == 22)); }
public async Task MintmangaBonus() { using (var context = Repository.GetEntityContext()) { var uri = new Uri(MangaInfos.Mintmanga.HarukaNaReceive.Uri); var toRemove = await context.Get <IManga>().Where(m => m.Uri == uri).ToListAsync().ConfigureAwait(false); foreach (var remove in toRemove) { await context.Delete(remove).ConfigureAwait(false); } var manga = await Mangas.CreateFromWeb(uri).ConfigureAwait(false); await manga.Parser.UpdateContent(manga).ConfigureAwait(false); var chapters = manga.Volumes.SelectMany(v => v.Container).OfType <Grouple.GroupleChapter>(); Assert.AreEqual(1, chapters.Count(c => c.VolumeNumber == 1 && c.Number == 0)); } }
public async Task MangachanBonus() { using (var context = Repository.GetEntityContext()) { var login = await context.Get <MangachanLogin>().SingleAsync().ConfigureAwait(false); login.PasswordHash = "e84fce6c43aacd7f8452409a63083c18"; login.UserId = "282433"; login.IsLogined = true; await context.Save(login).ConfigureAwait(false); } var manga = await Mangas.CreateFromWeb(new Uri("https://manga-chan.me/manga/5335-the-breaker-new-waves.html")).ConfigureAwait(false); await manga.Parser.UpdateContent(manga).ConfigureAwait(false); var chapters = manga.Volumes.SelectMany(v => v.Container).ToList(); Assert.AreEqual(1, chapters.Count(c => c.Number == 170)); Assert.AreEqual(1, chapters.Count(c => c.Number == 170.1)); }
/// <summary> /// Добавить мангу. /// </summary> /// <param name="uri"></param> public bool Add(Uri uri) { using (var context = Repository.GetEntityContext()) { if (context.Get <IManga>().Any(m => m.Uri == uri)) { return(false); } } var newManga = Mangas.CreateFromWeb(uri); if (newManga == null || !newManga.IsValid()) { return(false); } OnLibraryChanged(new LibraryViewModelArgs(null, newManga, MangaOperation.Added, LibraryOperation.UpdateMangaChanged)); Log.Info(Strings.Library_Status_MangaAdded + newManga.Name); return(true); }
public async Task ValidateStatusAndDescription(MangaInfo mangaInfo) { IManga manga; using (var context = Repository.GetEntityContext("Description")) { if (mangaInfo.Uri == MangaInfos.Mangachan.EveScramble.Uri) { var login = await context.Get <MangachanLogin>().SingleAsync().ConfigureAwait(false); login.PasswordHash = "e84fce6c43aacd7f8452409a63083c18"; login.UserId = "282433"; login.IsLogined = true; await context.Save(login).ConfigureAwait(false); } var mangaUri = new Uri(mangaInfo.Uri); var existsManga = await context.Get <IManga>().FirstOrDefaultAsync(m => m.Uri == mangaUri).ConfigureAwait(false); if (existsManga != null) { await context.Delete(existsManga).ConfigureAwait(false); } manga = await Mangas.CreateFromWeb(mangaUri).ConfigureAwait(false); } Assert.AreEqual(mangaInfo.Description, manga.Description); if (Equals(mangaInfo.Status, manga.Status)) { Assert.Pass(); } else { var storedWords = GetWords(mangaInfo.Status); var downloaded = GetWords(manga.Status); var changes = storedWords.Except(downloaded).Count() + downloaded.Except(storedWords).Count(); // Status can contain regular changed info, try to compare Assert.LessOrEqual(changes, 2); } }
public async Task DownloadAcomics() { var rm = Mangas.CreateFromWeb(new Uri(@"https://acomics.ru/~MGS-LDIOH")); var sw = new Stopwatch(); sw.Start(); rm.PropertyChanged += RmOnDownloadChanged; DirectoryHelpers.DeleteDirectory(rm.GetAbsoulteFolderPath()); await rm.Download(); sw.Stop(); Log.Add($"manga loaded {sw.Elapsed.TotalSeconds}, iscompleted = {rm.IsDownloaded}, lastpercent = {lastPercent}"); Assert.IsTrue(Directory.Exists(rm.GetAbsoulteFolderPath())); var files = Directory.GetFiles(rm.GetAbsoulteFolderPath(), "*", SearchOption.AllDirectories); Assert.AreEqual(6, files.Length); var fileInfos = files.Select(f => new FileInfo(f)).ToList(); Assert.AreEqual(8301123, fileInfos.Sum(f => f.Length)); Assert.AreEqual(1, fileInfos.GroupBy(f => f.Length).Max(g => g.Count())); Assert.IsTrue(rm.IsDownloaded); Assert.AreEqual(100, lastPercent); }
public async Task Download(MangaInfo mangaInfo) { IManga manga; var sw = new Stopwatch(); using (var context = Repository.GetEntityContext($"Test to download {mangaInfo.Uri}")) { foreach (var toDelete in context.Get <IManga>().Where(m => m.Uri.ToString() == mangaInfo.Uri)) { await context.Delete(toDelete).ConfigureAwait(false); DirectoryHelpers.DeleteDirectory(toDelete.GetAbsoluteFolderPath()); } manga = await Mangas.CreateFromWeb(new Uri(mangaInfo.Uri)).ConfigureAwait(false); DirectoryHelpers.DeleteDirectory(manga.GetAbsoluteFolderPath()); sw.Start(); await manga.Download().ConfigureAwait(false); } sw.Stop(); Log.Add($"manga loaded {sw.Elapsed.TotalSeconds}, iscompleted = {manga.IsDownloaded}, downloaded = {manga.Downloaded}%"); Assert.IsTrue(Directory.Exists(manga.GetAbsoluteFolderPath())); var files = Directory.GetFiles(manga.GetAbsoluteFolderPath(), "*", SearchOption.AllDirectories); Assert.AreEqual(mangaInfo.FilesInFolder, files.Length); var fileInfos = files.Select(f => new FileInfo(f)).ToList(); Assert.AreEqual(mangaInfo.FolderSize, fileInfos.Sum(f => f.Length), mangaInfo.FolderSize / 100.0); if (mangaInfo.AllFilesUnique) { Assert.AreEqual(1, fileInfos.GroupBy(f => f.Length).Max(g => g.Count())); } Assert.IsTrue(manga.IsDownloaded); Assert.AreEqual(100, manga.Downloaded); }
public async Task DownloadHentaichan() { CreateLogin(); var rm = Mangas.CreateFromWeb(new Uri(@"http://hentai-chan.me/manga/12850-twisted-intent-chast-1.html")); var sw = new Stopwatch(); sw.Start(); rm.PropertyChanged += RmOnDownloadChanged; DirectoryHelpers.DeleteDirectory(rm.GetAbsoulteFolderPath()); await rm.Download(); sw.Stop(); Log.Add($"manga loaded {sw.Elapsed.TotalSeconds}, iscompleted = {rm.IsDownloaded}, lastpercent = {lastPercent}"); Assert.IsTrue(Directory.Exists(rm.GetAbsoulteFolderPath())); var files = Directory.GetFiles(rm.GetAbsoulteFolderPath(), "*", SearchOption.AllDirectories); Assert.AreEqual(32, files.Length); var fileInfos = files.Select(f => new FileInfo(f)).ToList(); Assert.AreEqual(9984593, fileInfos.Sum(f => f.Length)); Assert.AreEqual(1, fileInfos.GroupBy(f => f.Length).Max(g => g.Count())); Assert.IsTrue(rm.IsDownloaded); Assert.AreEqual(100, lastPercent); }
private Hentaichan.Hentaichan GetManga(string url) { var manga = Mangas.CreateFromWeb(new Uri(url)) as Hentaichan.Hentaichan; return(manga); }
private Acomics.Acomics GetManga(string uri) { var manga = Mangas.CreateFromWeb(new Uri(uri)) as Acomics.Acomics; new Acomics.Parser().UpdateContent(manga); return manga; }
private static IManga GetManga(string url) { return(Mangas.CreateFromWeb(new Uri(url))); }
private void AddManga() { #warning Отсюда нужен переход к превью. Mangas.CreateFromWeb(new Uri(ManualUri)); }
private static async Task<IManga> GetManga(string url) { return await Mangas.CreateFromWeb(new Uri(url)).ConfigureAwait(false); }