Refactored ScanLibrary to produce page numbers on the Manga File, Format and to update existing series/volumes rather than always create new entries.
This commit is contained in:
parent
6b4617bab3
commit
59a4921ba9
12 changed files with 709 additions and 38 deletions
|
|
@ -1,12 +1,14 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using API.Entities;
|
||||
|
||||
namespace API.Parser
|
||||
{
|
||||
public static class Parser
|
||||
{
|
||||
public static readonly string MangaFileExtensions = @"\.cbz|\.cbr|\.png|\.jpeg|\.jpg|\.zip|\.rar";
|
||||
public static readonly string ImageFileExtensions = @"\.png|\.jpeg|\.jpg|\.gif";
|
||||
|
||||
//?: is a non-capturing group in C#, else anything in () will be a group
|
||||
private static readonly Regex[] MangaVolumeRegex = new[]
|
||||
|
|
@ -100,9 +102,17 @@ namespace API.Parser
|
|||
Chapters = ParseChapter(filePath),
|
||||
Series = ParseSeries(filePath),
|
||||
Volumes = ParseVolume(filePath),
|
||||
File = filePath
|
||||
Filename = filePath,
|
||||
Format = ParseFormat(filePath)
|
||||
};
|
||||
}
|
||||
|
||||
public static MangaFormat ParseFormat(string filePath)
|
||||
{
|
||||
if (IsArchive(filePath)) return MangaFormat.Archive;
|
||||
if (IsImage(filePath)) return MangaFormat.Image;
|
||||
return MangaFormat.Unknown;
|
||||
}
|
||||
|
||||
public static string ParseSeries(string filename)
|
||||
{
|
||||
|
|
@ -231,8 +241,13 @@ namespace API.Parser
|
|||
public static bool IsArchive(string filePath)
|
||||
{
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
|
||||
return MangaFileExtensions.Contains(fileInfo.Extension);
|
||||
}
|
||||
|
||||
public static bool IsImage(string filePath)
|
||||
{
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
return ImageFileExtensions.Contains(fileInfo.Extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue