Skip to content

Commit

Permalink
Merge pull request #34 from NguyenDanPhuong/dev
Browse files Browse the repository at this point in the history
Now support for Bato.to
  • Loading branch information
NguyenDanPhuong authored Jan 19, 2017
2 parents 9ba51f1 + a0e7cf3 commit ff22807
Show file tree
Hide file tree
Showing 54 changed files with 1,609 additions and 501 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
using NLog;
using MangaRipper.Core.DataTypes;
using MangaRipper.Core.Helpers;
using MangaRipper.Core.Models;
using MangaRipper.Core.Providers;
using MangaRipper.Core.Services;
using NLog;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MangaRipper.Core
namespace MangaRipper.Core.Controllers
{
/// <summary>
/// Worker support download manga chapters on back ground thread.
/// </summary>
public class Worker
public class WorkerController
{
private static Logger logger = LogManager.GetCurrentClassLogger();

CancellationTokenSource source;
SemaphoreSlim sema;

public Worker()
public WorkerController()
{
logger.Info("> Worker()");
source = new CancellationTokenSource();
Expand Down Expand Up @@ -62,7 +66,7 @@ await Task.Run(async () =>
task.IsBusy = false;
if (task.Formats.Contains(OutputFormat.CBZ))
{
PackageCbz.Create(Path.Combine(task.SaveToFolder, task.Chapter.NomalizeName), Path.Combine(task.SaveToFolder, task.Chapter.NomalizeName + ".cbz"));
PackageCbzHelper.Create(Path.Combine(task.SaveToFolder, task.Chapter.NomalizeName), Path.Combine(task.SaveToFolder, task.Chapter.NomalizeName + ".cbz"));
}
sema.Release();
}
Expand All @@ -74,7 +78,7 @@ await Task.Run(async () =>
/// <summary>
/// Find all chapters of a manga
/// </summary>
/// <param name="mangaPath">The url of manga</param>
/// <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)
Expand Down Expand Up @@ -103,13 +107,13 @@ private async Task DownloadChapterInternal(Chapter chapter, string mangaLocalPat
{
progress.Report(0);
// let service find all images of chapter
var service = Framework.GetService(chapter.Url);
var service = FrameworkProvider.GetService(chapter.Url);
var images = await service.FindImanges(chapter, new Progress<int>((count) =>
{
progress.Report(count / 2);
}), source.Token);
// create folder to keep images
var downloader = new Downloader();
var downloader = new DownloadService();
var folderName = chapter.NomalizeName;
var destinationPath = Path.Combine(mangaLocalPath, folderName);
Directory.CreateDirectory(destinationPath);
Expand Down Expand Up @@ -142,7 +146,7 @@ private async Task<IEnumerable<Chapter>> FindChaptersInternal(string mangaPath,
{
progress.Report(0);
// let service find all chapters in manga
var service = Framework.GetService(mangaPath);
var service = FrameworkProvider.GetService(mangaPath);
var chapters = await service.FindChapters(mangaPath, progress, source.Token);
progress.Report(100);
return chapters;
Expand Down
8 changes: 8 additions & 0 deletions MangaRipper.Core/DataTypes/OutputFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace MangaRipper.Core.DataTypes
{
public enum OutputFormat
{
Folder,
CBZ
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace MangaRipper.Core
namespace MangaRipper.Core.Extensions
{
public static class Extension
public static class ExtensionClearName
{
/// <summary>
/// Remove characters that cannot using to name folder, file.
Expand Down
69 changes: 0 additions & 69 deletions MangaRipper.Core/Framework.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Compression;
namespace MangaRipper.Core
using System.IO.Compression;
namespace MangaRipper.Core.Helpers
{
public class PackageCbz
public class PackageCbzHelper
{

/// <summary>
/// Create cbz file
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using NLog;
using System;
using MangaRipper.Core.Models;
using NLog;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace MangaRipper.Core
namespace MangaRipper.Core.Helpers
{
/// <summary>
/// Looking for manga/chapter information in html, using regex.
/// </summary>
class Parser
public class ParserHelper
{
private static Logger logger = LogManager.GetCurrentClassLogger();

Expand All @@ -21,7 +19,7 @@ class Parser
/// <param name="regExp">The regex with 2 captured groups.</param>
/// <param name="input">The html code.</param>
/// <param name="nameGroup">The group name that capture chapter name.</param>
/// <param name="valueGroup">The group name that capture chapter url.</param>
/// <param name="valueGroup">The group name that capture chapter URL.</param>
/// <returns></returns>
public IEnumerable<Chapter> ParseGroup(string regExp, string input, string nameGroup, string valueGroup)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using MangaRipper.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MangaRipper.Core
namespace MangaRipper.Core.Interfaces
{
/// <summary>
/// We have many manga services (web site), each service support finding chapters url and images url.
/// We have many manga services (web site), each service support finding chapters URL and images URL.
/// </summary>
public interface IMangaService
{
void Configuration(IEnumerable<KeyValuePair<string, object>> settings);
/// <summary>
/// The information of service
/// </summary>
Expand Down
68 changes: 0 additions & 68 deletions MangaRipper.Core/KissMangaService.cs

This file was deleted.

39 changes: 22 additions & 17 deletions MangaRipper.Core/MangaRipper.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<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>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.3.6\lib\net45\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.1\lib\net45\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -52,33 +56,34 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Chapter.cs" />
<Compile Include="DownloadChapterTask.cs" />
<Compile Include="Framework.cs" />
<Compile Include="IMangaService.cs" />
<Compile Include="Downloader.cs" />
<Compile Include="Extension.cs" />
<Compile Include="KissMangaService.cs" />
<Compile Include="MangaFoxService.cs" />
<Compile Include="MangaHereService.cs" />
<Compile Include="MangaReaderService.cs" />
<Compile Include="MangaShareService.cs" />
<Compile Include="OutputFormat.cs" />
<Compile Include="PackageCbz.cs" />
<Compile Include="Parser.cs" />
<Compile Include="Models\Chapter.cs" />
<Compile Include="Models\Configuration.cs" />
<Compile Include="Models\DownloadChapterTask.cs" />
<Compile Include="Providers\FrameworkProvider.cs" />
<Compile Include="Interfaces\IMangaService.cs" />
<Compile Include="Services\DownloadService.cs" />
<Compile Include="Extensions\ExtensionClearName.cs" />
<Compile Include="Services\PluginService.cs" />
<Compile Include="DataTypes\OutputFormat.cs" />
<Compile Include="Helpers\PackageCbzHelper.cs" />
<Compile Include="Helpers\ParserHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SiteInformation.cs" />
<Compile Include="Worker.cs" />
<Compile Include="Models\SiteInformation.cs" />
<Compile Include="Controllers\WorkerController.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="application.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Loading

0 comments on commit ff22807

Please sign in to comment.