Skip to content

Commit

Permalink
Fix #5 mangahere.co: chapter name is empty, image path is not well fo…
Browse files Browse the repository at this point in the history
…rmated.
  • Loading branch information
NguyenDanPhuong committed Aug 1, 2016
1 parent 92a5abe commit ae715b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions MangaRipper.Core/MangaHereService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task<IList<Chapter>> FindChapters(string manga, IProgress<int> prog
progress.Report(0);
// find all chapters in a manga
string input = await downloader.DownloadStringAsync(manga);
var chaps = parser.ParseGroup("<a class=\"color_0077\" href=\"(?<Value>http://[^\"]+)\"[^<]+>(?<Text>[^<]+)</a>", input, "Name", "Value");
var chaps = parser.ParseGroup("<a class=\"color_0077\" href=\"(?<Value>http://[^\"]+)\"[^<]+>(?<Name>[^<]+)</a>", input, "Name", "Value");
progress.Report(100);
return chaps;
}
Expand Down Expand Up @@ -47,7 +47,7 @@ public async Task<IList<string>> FindImanges(Chapter chapter, IProgress<int> pro
int i = Convert.ToInt32(f * 100);
progress.Report(i);
}), cancellationToken);
var images = parser.Parse("<img src=\"(?<Value>[^\"]+)\"[ ]+onerror", pageData, "Value");
var images = parser.Parse("<img src=\"(?<Value>[^?]+)?[^\"]+\"[ ]+onerror", pageData, "Value");

return images;
}
Expand Down
6 changes: 3 additions & 3 deletions MangaRipper.Core/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public IList<Chapter> ParseGroup(string regExp, string input, string nameGroup,

foreach (Match match in matches)
{
var value = match.Groups[valueGroup].Value;
string name = match.Groups[nameGroup].Value;
var value = match.Groups[valueGroup].Value.Trim();
string name = match.Groups[nameGroup].Value.Trim();
var chapter = new Chapter(name, value);
list.Add(chapter);
}
Expand All @@ -39,7 +39,7 @@ public IList<string> Parse(string regExp, string input, string groupName)

foreach (Match match in matches)
{
var value = match.Groups[groupName].Value;
var value = match.Groups[groupName].Value.Trim();
list.Add(value);
}

Expand Down
3 changes: 2 additions & 1 deletion MangaRipper.Test/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public async Task MangaHere_Test()
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[0];
var chapter = chapters.First();
Assert.IsTrue(chapter.Name.Length > 0, "Chapter's name is empty string.");
var images = await service.FindImanges(chapter, new Progress<int>(), source.Token);
Assert.IsTrue(images.Count > 0, "Cannot find images.");
}
Expand Down

0 comments on commit ae715b7

Please sign in to comment.