Example #1
0
        public async Task MangaFox_Test()
        {
            // Test with unlicensed manga. Appveyor CI is US based and cannot access licensed manga in the US.
            // If we test with a licensed manga, this test will failed.
            string url      = "http://mangafox.me/manga/tian_jiang_xian_shu_nan/";
            var    service  = FrameworkProvider.GetService(url);
            var    chapters = await service.FindChapters(url, new Progress <int>(), _source.Token);

            Assert.IsTrue(chapters.Any(), "Cannot find chapters.");
            var chapter = chapters.Last();

            Assert.AreEqual("Tian Jiang Xian Shu Nan 1", chapter.Name);
            Assert.AreEqual("http://mangafox.me/manga/tian_jiang_xian_shu_nan/c001/1.html", chapter.Url);
            var images = await service.FindImanges(chapter, new Progress <int>(), _source.Token);

            Assert.AreEqual(15, images.Count());
            Assert.IsTrue(images.ToArray()[0].StartsWith("http://h.mfcdn.net/store/manga/19803/001.0/compressed/q001.jpg"));
            Assert.IsTrue(images.ToArray()[1].StartsWith("http://h.mfcdn.net/store/manga/19803/001.0/compressed/q002.jpg"));
            Assert.IsTrue(images.ToArray()[2].StartsWith("http://h.mfcdn.net/store/manga/19803/001.0/compressed/q003.jpg"));

            var    downloader  = new DownloadService();
            string imageString = await downloader.DownloadStringAsync(images.ToArray()[0]);

            Assert.IsNotNull(imageString, "Cannot download image!");
        }
Example #2
0
        private async void btnGetChapter_Click(object sender, EventArgs e)
        {
            try
            {
                btnGetChapter.Enabled = false;
                var titleUrl = cbTitleUrl.Text;

                var worker      = FrameworkProvider.GetWorker();
                var progressInt = new Progress <int>(progress => txtPercent.Text = progress + @"%");
                var chapters    = await worker.FindChapters(titleUrl, progressInt);

                dgvChapter.DataSource = chapters.ToList();
                if (checkBoxForPrefix.Checked)
                {
                    PrefixLogic(); // in case if tick is set
                }
            }
            catch (OperationCanceledException ex)
            {
                txtMessage.Text = @"Download cancelled! Reason: " + ex.Message;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                txtMessage.Text = @"Download cancelled! Reason: " + ex.Message;
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                btnGetChapter.Enabled = true;
            }
        }
Example #3
0
        public async Task Batoto_Test()
        {
            string url     = "http://bato.to/comic/_/comics/21st-century-boys-r1591";
            var    service = FrameworkProvider.GetService(url);

            service.Configuration(new[] {
                new KeyValuePair <string, object>("Username", "gufrohepra"),
                new KeyValuePair <string, object>("Password", "123"),
                new KeyValuePair <string, object>("Languages", "")
            });

            var chapters = await service.FindChapters(url, new Progress <int>(), _source.Token);

            Assert.IsTrue(chapters.Any(), "Cannot find chapters.");
            var chapter = chapters.Last();

            Assert.AreEqual("Vol.01 Ch.01 Read Online", chapter.Name);
            Assert.AreEqual("https://bato.to/reader#900d11d96d1466f2", chapter.Url);
            var images = await service.FindImages(chapter, new Progress <int>(), _source.Token);

            Assert.AreEqual(31, images.Count());
            Assert.IsTrue(images.ToArray()[0].StartsWith("http://img.bato.to/comics/2014/10/08/2/read54357eb5e1ca9/img000001.jpg"));
            Assert.IsTrue(images.ToArray()[1].StartsWith("http://img.bato.to/comics/2014/10/08/2/read54357eb5e1ca9/img000002.jpg"));
            Assert.IsTrue(images.ToArray()[2].StartsWith("http://img.bato.to/comics/2014/10/08/2/read54357eb5e1ca9/img000003.jpg"));

            var    downloader  = new DownloadService();
            string imageString = await downloader.DownloadStringAsync(images.ToArray()[0], _source.Token);

            Assert.IsNotNull(imageString, "Cannot download image!");
        }
Example #4
0
        public async Task MangaReader_Test()
        {
            string url     = "http://www.mangareader.net/naruto";
            var    service = FrameworkProvider.GetService(url);
            // Test service can find chapters
            var chapters = await service.FindChapters(url, new Progress <int>(), _source.Token);

            Assert.IsTrue(chapters.Any(), "Cannot find chapters.");
            // Test chapters are in correct order.
            var chapter = chapters.Last();

            Assert.AreEqual("Naruto 1", chapter.Name);
            Assert.AreEqual("http://www.mangareader.net/naruto/1", chapter.Url);
            // Test there're no duplicated chapters.
            var anyDuplicated = chapters.GroupBy(x => x.Url).Any(g => g.Count() > 1);

            Assert.IsFalse(anyDuplicated, "There're duplicated chapters.");
            // Test service can find images.
            var images = await service.FindImanges(chapter, new Progress <int>(), _source.Token);

            Assert.AreEqual(53, images.Count());
            Assert.AreEqual("http://i10.mangareader.net/naruto/1/naruto-1564773.jpg", images.ToArray()[0]);
            Assert.AreEqual("http://i4.mangareader.net/naruto/1/naruto-1564774.jpg", images.ToArray()[1]);
            Assert.AreEqual("http://i1.mangareader.net/naruto/1/naruto-1564825.jpg", images.ToArray()[52]);

            var    downloader  = new DownloadService();
            string imageString = await downloader.DownloadStringAsync(images.ToArray()[0]);

            Assert.IsNotNull(imageString, "Cannot download image!");
        }
Example #5
0
        private async Task DownloadChapter(DownloadChapterTask task, string mangaLocalPath, IProgress <int> progress)
        {
            var chapter = task.Chapter;

            progress.Report(0);
            var service = FrameworkProvider.GetService(chapter.Url);
            var images  = await service.FindImages(chapter, new Progress <int>(count =>
            {
                progress.Report(count / 2);
            }), _source.Token);

            var tempFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Directory.CreateDirectory(tempFolder);

            await DownloadImages(images, tempFolder, progress);

            var folderName  = chapter.Name;
            var finalFolder = Path.Combine(mangaLocalPath, folderName);

            if (task.Formats.Contains(OutputFormat.Folder))
            {
                if (!Directory.Exists(finalFolder))
                {
                    Directory.CreateDirectory(finalFolder);
                }
                ExtensionHelper.SuperMove(tempFolder, finalFolder);
            }
            if (task.Formats.Contains(OutputFormat.CBZ))
            {
                PackageCbzHelper.Create(tempFolder, Path.Combine(task.SaveToFolder, task.Chapter.Name + ".cbz"));
            }

            progress.Report(100);
        }
Example #6
0
    private static Task GeneratePlatformIndexAsync(string frameworksPath, string indexFrameworksPath)
    {
        var frameworkResolvers = new FrameworkProvider[]
        {
            new ArchivedFrameworkProvider(frameworksPath),
            new PackBasedFrameworkProvider(frameworksPath)
        };

        var frameworks = frameworkResolvers.SelectMany(r => r.Resolve())
                         .OrderBy(t => t.FrameworkName);
        var reindex = false;

        Directory.CreateDirectory(indexFrameworksPath);

        foreach (var(frameworkName, paths) in frameworks)
        {
            var path           = Path.Join(indexFrameworksPath, $"{frameworkName}.xml");
            var alreadyIndexed = !reindex && File.Exists(path);

            if (alreadyIndexed)
            {
                Console.WriteLine($"{frameworkName} already indexed.");
            }
            else
            {
                Console.WriteLine($"Indexing {frameworkName}...");
                var frameworkEntry = FrameworkIndexer.Index(frameworkName, paths);
                using (var stream = File.Create(path))
                    frameworkEntry.Write(stream);
            }
        }

        return(Task.CompletedTask);
    }
        public static void PopulateWithFrameworkTypes(TypeIdentifierMap typeIdentifierMap)
        {
            frameworkVersion = FrameworkProvider.GetFrameworkVersion0();
            FrameworkIntegration.typeIdentifierMap = typeIdentifierMap;

            PopulateWithTypes(typeIdentifierMap, frameworkVersion);
        }
        public static void PopulateWithFrameworkSymbols(HoistedIdentifierMap globalIdentifierMap, TypeIdentifierMap typeIdentifierMap)
        {
            FrameworkVersion frameworkVersion = FrameworkProvider.GetFrameworkVersion0();

            PopulateWithTypes(typeIdentifierMap, frameworkVersion);
            PopulateWithFunctions(globalIdentifierMap, typeIdentifierMap, frameworkVersion);
            PopulateWithConstants(globalIdentifierMap, typeIdentifierMap, frameworkVersion);
        }
Example #9
0
        private async Task <IEnumerable <Chapter> > FindChaptersInternal(string mangaPath, IProgress <int> progress)
        {
            progress.Report(0);
            // let service find all chapters in manga
            var service  = FrameworkProvider.GetService(mangaPath);
            var chapters = await service.FindChapters(mangaPath, progress, _source.Token);

            progress.Report(100);
            return(chapters);
        }
Example #10
0
        private static void Main()
        {
            Logger.Info("> Main()");
            var appDomain = AppDomain.CurrentDomain;

            appDomain.UnhandledException += AppDomain_UnhandledException;
            FrameworkProvider.Init(Path.Combine(Environment.CurrentDirectory, "Plugins"),
                                   Path.Combine(Environment.CurrentDirectory, "MangaRipper.Configuration.json"));
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormMain());
            Logger.Info("< Main()");
        }
Example #11
0
        public async Task Batoto_GermanEnglishLanguages_Test()
        {
            string url     = "https://bato.to/comic/_/comics/bitter-virgin-r110";
            var    service = FrameworkProvider.GetService(url);

            service.Configuration(new[] {
                new KeyValuePair <string, object>("Username", "gufrohepra"),
                new KeyValuePair <string, object>("Password", "123"),
                new KeyValuePair <string, object>("Languages", "German, English")
            });

            var chapters = await service.FindChapters(url, new Progress <int>(), _source.Token);

            Assert.AreEqual(chapters.Count(), 64);
        }
        public void CheckFrameworkProvider()
        {
            var provider = new FrameworkProvider();

            // validate garbage collection counts
            var currentGen0CollectionCount = GC.CollectionCount(0);
            var currentGen1CollectionCount = GC.CollectionCount(1);
            var currentGen2CollectionCount = GC.CollectionCount(2);

            GC.Collect(0);
            GC.Collect(1);
            GC.Collect(1);
            GC.Collect(2);
            GC.Collect(2);
            GC.Collect(2);

            var expectedGen0CollectionCount = GC.CollectionCount(0) - currentGen0CollectionCount;
            var expectedGen1CollectionCount = GC.CollectionCount(1) - currentGen1CollectionCount;
            var expectedGen2CollectionCount = GC.CollectionCount(2) - currentGen2CollectionCount;

            var metrics              = provider.GetMetrics();
            var checkedMetricsCount  = 0;
            var expectedMetricsCount = 3;

            for (int i = 0; i < metrics.Count; i++)
            {
                if (string.CompareOrdinal(metrics[i].Name, MetricsNames.Gen0CollectionsCount) == 0)
                {
                    Assert.True(expectedGen0CollectionCount <= TryGetValue(metrics[i].Value));
                    checkedMetricsCount++;
                }
                else
                if (string.CompareOrdinal(metrics[i].Name, MetricsNames.Gen1CollectionsCount) == 0)
                {
                    Assert.True(expectedGen1CollectionCount <= TryGetValue(metrics[i].Value));
                    checkedMetricsCount++;
                }
                else
                if (string.CompareOrdinal(metrics[i].Name, MetricsNames.Gen2CollectionsCount) == 0)
                {
                    Assert.True(expectedGen2CollectionCount <= TryGetValue(metrics[i].Value));
                    checkedMetricsCount++;
                }
            }

            Assert.Equal(expectedMetricsCount, checkedMetricsCount);
        }
Example #13
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            // Enables double-buffering to reduce flicker.
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

            var state = _appConf.LoadCommonSettings();

            Size                      = state.WindowSize;
            Location                  = state.Location;
            WindowState               = state.WindowState;
            txtSaveTo.Text            = state.SaveTo;
            cbTitleUrl.Text           = state.Url;
            cbSaveCbz.Checked         = state.CbzChecked;
            checkBoxForPrefix.Checked = state.PrefixChecked;

            dgvQueueChapter.AutoGenerateColumns = false;
            dgvChapter.AutoGenerateColumns      = false;

            Text = $@"{Application.ProductName} {Application.ProductVersion}";

            try
            {
                foreach (var service in FrameworkProvider.GetMangaServices())
                {
                    var infor = service.GetInformation();
                    dgvSupportedSites.Rows.Add(infor.Name, infor.Link, infor.Language);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
            }

            if (string.IsNullOrWhiteSpace(SaveDestination))
            {
                txtSaveTo.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }

            _downloadQueue             = _appConf.LoadDownloadChapterTasks();
            dgvQueueChapter.DataSource = _downloadQueue;
            LoadBookmark();
            CheckForUpdate();
        }
Example #14
0
        private async Task OnFindChapters(string obj)
        {
            try
            {
                var worker      = FrameworkProvider.GetWorker();
                var progressInt = new Progress <int>(progress => View.SetChaptersProgress(progress + @"%"));
                var chapters    = await worker.FindChapterListAsync(obj, progressInt);

                View.SetChapters(chapters);
            }
            catch (OperationCanceledException ex)
            {
                View.SetStatusText(@"Download cancelled! Reason: " + ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                View.SetStatusText(@"Download cancelled! Reason: " + ex.Message);
                View.ShowMessageBox(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #15
0
        private async Task StartDownload()
        {
            while (_downloadQueue.Count > 0)
            {
                var chapter = _downloadQueue.First();
                var worker  = FrameworkProvider.GetWorker();

                await worker.DownloadChapter(chapter, new Progress <int>(c =>
                {
                    foreach (DataGridViewRow item in dgvQueueChapter.Rows)
                    {
                        if (chapter == item.DataBoundItem)
                        {
                            chapter.Percent = c;
                            dgvQueueChapter.Refresh();
                        }
                    }
                }));

                _downloadQueue.Remove(chapter);
            }
        }
Example #16
0
        public async Task MangaHere_Test()
        {
            string url      = "http://www.mangahere.co/manga/the_god_of_high_school/";
            var    service  = FrameworkProvider.GetService(url);
            var    chapters = await service.FindChapters(url, new Progress <int>(), _source.Token);

            Assert.IsTrue(chapters.Any(), "Cannot find chapters.");
            var chapter = chapters.Last();

            Assert.AreEqual("The God Of High School 1", chapter.Name);
            Assert.AreEqual("http://www.mangahere.co/manga/the_god_of_high_school/c001/", chapter.Url);
            var images = await service.FindImanges(chapter, new Progress <int>(), _source.Token);

            Assert.AreEqual(55, images.Count());
            Assert.IsTrue(images.ToArray()[0].StartsWith("http://h.mhcdn.net/store/manga/9275/001.0/compressed/m001.01.jpg"));
            Assert.IsTrue(images.ToArray()[1].StartsWith("http://h.mhcdn.net/store/manga/9275/001.0/compressed/m001.02.jpg"));
            Assert.IsTrue(images.ToArray()[54].StartsWith("http://h.mhcdn.net/store/manga/9275/001.0/compressed/m001.55.jpg"));

            var    downloader  = new DownloadService();
            string imageString = await downloader.DownloadStringAsync(images.ToArray()[0]);

            Assert.IsNotNull(imageString, "Cannot download image!");
        }
Example #17
0
        public async Task MangaStream_Test()
        {
            string url      = "http://mangastream.com/manga/dragon_ball_super";
            var    service  = FrameworkProvider.GetService(url);
            var    chapters = await service.FindChapters(url, new Progress <int>(), _source.Token);

            Assert.IsTrue(chapters.Any(), "Cannot find chapters.");
            var chapter = chapters.Last();

            Assert.AreEqual("001 - The God of Destruction's Prophetic Dream", chapter.Name);
            Assert.AreEqual("http://readms.net/r/dragon_ball_super/001/2831/1", chapter.Url);
            var images = await service.FindImages(chapter, new Progress <int>(), _source.Token);

            Assert.AreEqual(17, images.Count());
            Assert.IsTrue(images.ToArray()[0].StartsWith("http://img.readms.net/cdn/manga/107/2831/001.jpg"));
            Assert.IsTrue(images.ToArray()[1].StartsWith("http://img.readms.net/cdn/manga/107/2831/001a.jpg"));
            Assert.IsTrue(images.ToArray()[2].StartsWith("http://img.readms.net/cdn/manga/107/2831/002.png"));

            var    downloader  = new DownloadService();
            string imageString = await downloader.DownloadStringAsync(images.ToArray()[0], _source.Token);

            Assert.IsNotNull(imageString, "Cannot download image!");
        }
Example #18
0
        public async Task MangaShare_Test()
        {
            string url      = "http://read.mangashare.com/Gantz";
            var    service  = FrameworkProvider.GetService(url);
            var    chapters = await service.FindChapters(url, new Progress <int>(), _source.Token);

            Assert.IsTrue(chapters.Any(), "Cannot find chapters.");
            var chapter = chapters.Last();

            Assert.AreEqual("Gantz 1", chapter.Name);
            Assert.AreEqual("http://read.mangashare.com/Gantz/chapter-001/page001.html", chapter.Url);
            var images = await service.FindImanges(chapter, new Progress <int>(), _source.Token);

            Assert.AreEqual(43, images.Count());
            Assert.AreEqual("http://dl01.mangashare.com/manga/Gantz/001/001.jpg", images.ToArray()[0]);
            Assert.AreEqual("http://dl01.mangashare.com/manga/Gantz/001/002.jpg", images.ToArray()[1]);
            Assert.AreEqual("http://dl01.mangashare.com/manga/Gantz/001/043.jpg", images.ToArray()[42]);

            var    downloader  = new DownloadService();
            string imageString = await downloader.DownloadStringAsync(images.ToArray()[0]);

            Assert.IsNotNull(imageString, "Cannot download image!");
        }
Example #19
0
        public async Task KissManga_Test()
        {
            string url      = "http://kissmanga.com/Manga/Onepunch-Man";
            var    service  = FrameworkProvider.GetService(url);
            var    chapters = await service.FindChapters(url, new Progress <int>(), _source.Token);

            Assert.IsTrue(chapters.Any(), "Cannot find chapters.");
            var chapter = chapters.Last();

            Assert.AreEqual("Onepunch-Man _vol.001 ch.001", chapter.Name);
            Assert.AreEqual("http://kissmanga.com/Manga/Onepunch-Man/vol-001-ch-001?id=313725", chapter.Url);
            var images = await service.FindImanges(chapter, new Progress <int>(), _source.Token);

            Assert.AreEqual(19, images.Count());
            Assert.IsTrue(images.ToArray()[0].StartsWith("https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?container=focus&gadget=a&no_expand=1&resize_h=0&rewriteMime=image%2F*&url=http%3a%2f%2f2.p.mpcdn.net%2f50%2f531513%2f1.jpg&imgmax=30000"));
            Assert.IsTrue(images.ToArray()[1].StartsWith("https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?container=focus&gadget=a&no_expand=1&resize_h=0&rewriteMime=image%2F*&url=http%3a%2f%2f2.p.mpcdn.net%2f50%2f531513%2f2.jpg&imgmax=30000"));
            Assert.IsTrue(images.ToArray()[2].StartsWith("https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?container=focus&gadget=a&no_expand=1&resize_h=0&rewriteMime=image%2F*&url=http%3a%2f%2f2.p.mpcdn.net%2f50%2f531513%2f3.jpg&imgmax=30000"));

            var    downloader  = new DownloadService();
            string imageString = await downloader.DownloadStringAsync(images.ToArray()[0]);

            Assert.IsNotNull(imageString, "Cannot download image!");
        }
Example #20
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     FrameworkProvider.GetWorker().Cancel();
 }
Example #21
0
 public void Setup()
 {
     frw = FrameworkProvider.GetFrameworkVersion0();
 }
Example #22
0
 public void Initialize()
 {
     FrameworkProvider.Init(Environment.CurrentDirectory, Path.Combine(Environment.CurrentDirectory, "MangaRipper.Configuration.json"));
     _source = new CancellationTokenSource();
 }