Skip to content

Commit

Permalink
Fix #8 403 when download from MangaFox
Browse files Browse the repository at this point in the history
  • Loading branch information
NguyenDanPhuong committed Sep 7, 2016
1 parent 4f1b898 commit a100cb8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
1 change: 0 additions & 1 deletion MangaRipper.Core/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ private HttpWebRequest CreateRequest(string url)
HttpWebRequest request = WebRequest.CreateHttp(uri);
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
request.Credentials = CredentialCache.DefaultCredentials;
request.Referer = uri.AbsoluteUri;
return request;
}

Expand Down
3 changes: 3 additions & 0 deletions MangaRipper.Core/IMangaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace MangaRipper.Core
{
/// <summary>
/// We have many manga services, each service support downloading from one site.
/// </summary>
public interface IMangaService
{
SiteInformation GetInformation();
Expand Down
2 changes: 1 addition & 1 deletion MangaRipper.Core/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private async Task DownloadChapterInternal(Chapter chapter, string mangaLocalPat
// create folder to keep images
var downloader = new Downloader();
var folderName = chapter.Name.RemoveFileNameInvalidChar();
var destinationPath = Path.Combine(mangaLocalPath, folderName); ;
var destinationPath = Path.Combine(mangaLocalPath, folderName);
Directory.CreateDirectory(destinationPath);
// download images
int countImage = 0;
Expand Down
30 changes: 23 additions & 7 deletions MangaRipper.Test/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public async Task MangaReader_Test()
Assert.AreEqual("http://i10.mangareader.net/naruto/1/naruto-1564773.jpg", images[0]);
Assert.AreEqual("http://i4.mangareader.net/naruto/1/naruto-1564774.jpg", images[1]);
Assert.AreEqual("http://i1.mangareader.net/naruto/1/naruto-1564825.jpg", images[52]);

var downloader = new Downloader();
string imageString = await downloader.DownloadStringAsync(images[0]);
Assert.IsNotNull(imageString, "Cannot download image!");
}

[TestMethod]
Expand All @@ -61,6 +65,10 @@ public async Task MangaFox_Test()
Assert.AreEqual("http://h.mfcdn.net/store/manga/19803/001.0/compressed/q001.jpg", images[0]);
Assert.AreEqual("http://h.mfcdn.net/store/manga/19803/001.0/compressed/q002.jpg", images[1]);
Assert.AreEqual("http://h.mfcdn.net/store/manga/19803/001.0/compressed/q015.jpg", images[14]);

var downloader = new Downloader();
string imageString = await downloader.DownloadStringAsync(images[0]);
Assert.IsNotNull(imageString, "Cannot download image!");
}

[TestMethod]
Expand All @@ -78,23 +86,31 @@ public async Task MangaHere_Test()
Assert.AreEqual("http://h.mhcdn.net/store/manga/9275/001.0/compressed/m001.01.jpg", images[0]);
Assert.AreEqual("http://h.mhcdn.net/store/manga/9275/001.0/compressed/m001.02.jpg", images[1]);
Assert.AreEqual("http://h.mhcdn.net/store/manga/9275/001.0/compressed/m001.55.jpg", images[54]);

var downloader = new Downloader();
string imageString = await downloader.DownloadStringAsync(images[0]);
Assert.IsNotNull(imageString, "Cannot download image!");
}

[TestMethod]
public async Task MangaShare_Test()
{
string url = "http://read.mangashare.com/Beelzebub";
string url = "http://read.mangashare.com/Gantz";
var service = Framework.GetService(url);
var chapters = await service.FindChapters(url, new Progress<int>(), source.Token);
Assert.IsTrue(chapters.Count > 0, "Cannot find chapters.");
var chapter = chapters.Last();
Assert.AreEqual("Beelzebub 1", chapter.Name);
Assert.AreEqual("http://read.mangashare.com/Beelzebub/chapter-001/page001.html", chapter.Link);
Assert.AreEqual("Gantz 1", chapter.Name);
Assert.AreEqual("http://read.mangashare.com/Gantz/chapter-001/page001.html", chapter.Link);
var images = await service.FindImanges(chapter, new Progress<int>(), source.Token);
Assert.AreEqual(58, images.Count);
Assert.AreEqual("http://dl01.mangashare.com/manga/Beelzebub/001/001.jpg", images[0]);
Assert.AreEqual("http://dl01.mangashare.com/manga/Beelzebub/001/002.jpg", images[1]);
Assert.AreEqual("http://dl01.mangashare.com/manga/Beelzebub/001/058.jpg", images[57]);
Assert.AreEqual(43, images.Count);
Assert.AreEqual("http://dl01.mangashare.com/manga/Gantz/001/001.jpg", images[0]);
Assert.AreEqual("http://dl01.mangashare.com/manga/Gantz/001/002.jpg", images[1]);
Assert.AreEqual("http://dl01.mangashare.com/manga/Gantz/001/043.jpg", images[42]);

var downloader = new Downloader();
string imageString = await downloader.DownloadStringAsync(images[0]);
Assert.IsNotNull(imageString, "Cannot download image!");
}
}
}

0 comments on commit a100cb8

Please sign in to comment.