Skip to content

Commit

Permalink
Merge pull request #83 from NguyenDanPhuong/develop
Browse files Browse the repository at this point in the history
Fix batoto, mangafox
  • Loading branch information
NguyenDanPhuong authored Jul 12, 2017
2 parents bc3870a + f43d4d3 commit 378bb92
Show file tree
Hide file tree
Showing 49 changed files with 1,370 additions and 512 deletions.
10 changes: 5 additions & 5 deletions MangaRipper.Core/Controllers/WorkerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Cancel()
/// <param name="task">Contain chapter and save to path</param>
/// <param name="progress">Callback to report progress</param>
/// <returns></returns>
public async Task DownloadChapter(DownloadChapterTask task, IProgress<int> progress)
public async Task RunDownloadTaskAsync(DownloadChapterTask task, IProgress<int> progress)
{
Logger.Info("> DownloadChapter: {0} To: {1}", task.Chapter.Url, task.SaveToFolder);
await Task.Run(async () =>
Expand All @@ -57,7 +57,7 @@ await Task.Run(async () =>
_source = new CancellationTokenSource();
await _sema.WaitAsync();
task.IsBusy = true;
await DownloadChapterInternal(task, task.SaveToFolder, progress);
await DownloadChapter(task, task.SaveToFolder, progress);
}
catch (Exception ex)
{
Expand All @@ -78,7 +78,7 @@ await Task.Run(async () =>
/// <param name="mangaPath">The URL of manga</param>
/// <param name="progress">Progress report callback</param>
/// <returns></returns>
public async Task<IEnumerable<Chapter>> FindChapters(string mangaPath, IProgress<int> progress)
public async Task<IEnumerable<Chapter>> FindChapterListAsync(string mangaPath, IProgress<int> progress)
{
Logger.Info("> FindChapters: {0}", mangaPath);
return await Task.Run(async () =>
Expand All @@ -100,7 +100,7 @@ public async Task<IEnumerable<Chapter>> FindChapters(string mangaPath, IProgress
});
}

private async Task DownloadChapterInternal(DownloadChapterTask task, string mangaLocalPath, IProgress<int> progress)
private async Task DownloadChapter(DownloadChapterTask task, string mangaLocalPath, IProgress<int> progress)
{
var chapter = task.Chapter;
progress.Report(0);
Expand Down Expand Up @@ -142,6 +142,7 @@ private async Task DownloadImages(IEnumerable<string> inputImages, string destin
var countImage = 0;
foreach (var image in images)
{
_source.Token.ThrowIfCancellationRequested();
await DownloadImage(image, destination, countImage);
countImage++;
int i = Convert.ToInt32((float)countImage / images.Count() * 100 / 2);
Expand Down Expand Up @@ -189,7 +190,6 @@ private string GetFilenameFromUrl(string url, int imageNum)
imageNum++;
path = imageNum.ToString("0000") + "." + extension;
}

return path;
}

Expand Down
18 changes: 18 additions & 0 deletions MangaRipper.Core/Extensions/ExtensionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,23 @@ public static void CopyFolderAndAllSubItems(DirectoryInfo source, DirectoryInfo
foreach (FileInfo file in source.GetFiles())
file.CopyTo(Path.Combine(destination.FullName, file.Name));
}

/// <summary>
/// Replaces the user's name with a generic placeholder to protect their privacy.
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string SanitizeUserName(string input)
{
if (!string.IsNullOrWhiteSpace(input))
{
return input.Replace(System.Environment.UserName, "<user>");
}
else
{
throw new System.ArgumentNullException("Value cannot be null.");
}

}
}
}
2 changes: 1 addition & 1 deletion MangaRipper.Core/Helpers/ParserHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public IEnumerable<Chapter> ParseGroup(string regExp, string input, string nameG
list.Add(chapter);
}
var result = list.Distinct().ToList();
Logger.Info($@"Parse success. There are {result.Count()} item(s).");
Logger.Info($@"Parse success. There are {result.Count} item(s).");
return result;
}

Expand Down
14 changes: 8 additions & 6 deletions MangaRipper.Core/MangaRipper.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@
<HintPath>..\packages\CloudFlareUtilities.NETStandard.0.3.3.1\lib\netstandard1.1\CloudFlareUtilities.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Jurassic, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Jurassic.2.2.1\lib\net35\Jurassic.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.1\lib\net45\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.8\lib\net45\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -57,9 +60,8 @@
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down
8 changes: 1 addition & 7 deletions MangaRipper.Core/Models/Chapter.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
using System;
using MangaRipper.Core.Extensions;
using MangaRipper.Core.Extensions;

namespace MangaRipper.Core.Models
{
public class Chapter
{

public string OriginalName { get; }
public int Prefix { get; set; }

public string Name => Prefix > 0 ? $"[{Prefix:000}] {OriginalName.RemoveFileNameInvalidChar()}" : OriginalName.RemoveFileNameInvalidChar();

public string Url { get;}

public Chapter(string originalName, string url)
{
OriginalName = originalName;
Url = url;
}

}
}
Loading

0 comments on commit 378bb92

Please sign in to comment.