Skip to content

Commit

Permalink
refactor: update sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Jan 1, 2024
1 parent be13553 commit e9d23df
Show file tree
Hide file tree
Showing 50 changed files with 551 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ internal class ReaperScansSource : SourceBase
protected override string Url => "https://reaperscans.com";
protected override bool HasCloudflareProtection => true;

public ReaperScansSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public ReaperScansSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}

Expand Down Expand Up @@ -128,15 +132,19 @@ protected override async Task<Result<SearchResult>> Search(string query)
continue;
}

items.Add(new SearchResultItem(url.ToBase64(), title, url, cover));
items.Add(
new SearchResultItem(
ConstructId(url),
title,
cover));
}

return Result.Ok(new SearchResult(items));
}

protected override async Task<Result<ChapterList>> GetChapterList(string mangaId)
{
string url = mangaId.FromBase64();
DeconstructId(mangaId, out string url, out _);

CustomHttpClient httpClient = GetHttpClient();
httpClient.AddHeader(CachingHandler.BypassCacheKey, "true");
Expand Down Expand Up @@ -253,12 +261,17 @@ private List<ChapterListItem> GetChaptersFromPage(IDocument document)
string chapterDate = element.QuerySelector<IHtmlParagraphElement>("div.mt-2 div p")?.TextContent.Trim()
.Replace("released", string.Empty) ?? string.Empty;

if (!TryParseRelativeDate(chapterDate, out DateTime dateTime))
{
dateTime = DateTime.MinValue;
}

items.Add(
new ChapterListItem(
url.ToBase64(),
ConstructId(url),
"Chapter " + number,
chapterNumber,
ParseRelativeDate(chapterDate),
dateTime.Date,
url));
}

Expand All @@ -267,7 +280,8 @@ private List<ChapterListItem> GetChaptersFromPage(IDocument document)

protected override async Task<Result<PageList>> GetPageList(string chapterId)
{
Result<string> result = await GetHttpClient().Get(chapterId.FromBase64());
DeconstructId(chapterId, out string url, out _);
Result<string> result = await GetHttpClient().Get(url);

if (result.IsFailed)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ internal class WebtoonsSource : SourceBase
protected override string Name => "LINE Webtoon";
protected override string Url => "https://www.webtoons.com/en/";

public WebtoonsSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public WebtoonsSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}

Expand Down Expand Up @@ -49,18 +53,20 @@ protected override async Task<Result<SearchResult>> Search(string query)
{
string url = "https://webtoons.com/episodeList?titleNo=" + item.titleNo;

items.Add(new SearchResultItem(url.ToBase64(),
item.title,
url,
"https://webtoon-phinf.pstatic.net" + item.thumbnailMobile));
items.Add(
new SearchResultItem(
ConstructId(url),
item.title,
"https://webtoon-phinf.pstatic.net" + item.thumbnailMobile));
}

return Result.Ok(new SearchResult(items));
}

protected override async Task<Result<ChapterList>> GetChapterList(string mangaId)
{
Result<string> result = await GetHttpClient().Get(mangaId.FromBase64());
DeconstructId(mangaId, out string url, out _);
Result<string> result = await GetHttpClient().Get(url);

if (result.IsFailed)
{
Expand Down Expand Up @@ -111,7 +117,7 @@ protected override async Task<Result<ChapterList>> GetChapterList(string mangaId

items.Add(
new ChapterListItem(
anchor.Href.ToBase64(),
ConstructId(anchor.Href),
titleElement.TextContent,
chapterNumber,
DateTime.Parse(dateElement.TextContent).Date,
Expand All @@ -131,7 +137,8 @@ protected override async Task<Result<ChapterList>> GetChapterList(string mangaId

protected override async Task<Result<PageList>> GetPageList(string chapterId)
{
Result<string> result = await GetHttpClient().Get(chapterId.FromBase64());
DeconstructId(chapterId, out string chapterUrl, out _);
Result<string> result = await GetHttpClient().Get(chapterUrl);

if (result.IsFailed)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ internal class ZeroScansSource : SourceBase
protected override string Name => "Zero Scans";
protected override string Url => "https://zeroscans.com";

public ZeroScansSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public ZeroScansSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}

Expand Down Expand Up @@ -54,9 +58,8 @@ protected override async Task<Result<SearchResult>> Search(string query)
}

items.Add(new SearchResultItem(
(comic.slug + "|" + comic.id).ToBase64(),
(Url + "/comics/" + comic.slug + "|" + comic.slug + "|" + comic.id).ToBase64(),
comic.name,
Url + "/comics/" + comic.slug,
comic.cover.horizontal ?? comic.cover.vertical ?? string.Empty));
}

Expand All @@ -66,8 +69,9 @@ protected override async Task<Result<SearchResult>> Search(string query)
protected override async Task<Result<ChapterList>> GetChapterList(string mangaId)
{
string[] splits = mangaId.FromBase64().Split('|');
string slug = splits[0];
string id = splits[1];
string chapterUrl = splits[0];
string slug = splits[1];
string id = splits[2];

List<ChapterListItem> items = new();

Expand All @@ -92,11 +96,16 @@ protected override async Task<Result<ChapterList>> GetChapterList(string mangaId

foreach (ChapterResult.Data.Item item in result.Value.data.data)
{
if (!TryParseRelativeDate(item.created_at, out DateTime dateTime))
{
dateTime = DateTime.MinValue;
}

items.Add(new ChapterListItem(
(slug + "/" + item.id).ToBase64(),
"Chapter " + item.name,
item.name,
ParseRelativeDate(item.created_at).Date,
dateTime.Date,
Url + "/comics/" + slug + "/" + item.id));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ internal class AquaMangaSource : MadaraSourceBase
protected override string Name => "Aqua Manga";
protected override string Url => "https://aquamanga.org";

public AquaMangaSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
protected override bool UseAjaxChapterListMethod => true;

public AquaMangaSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ internal class ArthurScanSource : MadaraSourceBase
protected override string Url => "https://arthurscan.xyz";
protected override bool UseAjaxChapterListMethod => true;

public ArthurScanSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public ArthurScanSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ internal class BibiMangaSource : MadaraSourceBase
protected override string Name => "Bibi Manga";
protected override string Url => "https://bibimanga.com";

public BibiMangaSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public BibiMangaSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ internal class CoffeeMangaSource : MadaraSourceBase
protected override string Url => "https://coffeemanga.io";
protected override bool UseAjaxChapterListMethod => true;

public CoffeeMangaSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public CoffeeMangaSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ internal class DarkScansSource : MadaraSourceBase
protected override string Url => "https://darkscans.com";
protected override bool UseAjaxChapterListMethod => true;

public DarkScansSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public DarkScansSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ internal class HiperDexSource : MadaraSourceBase
protected override string Url => "https://hiperdex.com";
protected override bool UseAjaxChapterListMethod => true;

public HiperDexSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public HiperDexSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ internal class ImmortalUpdatesSource : MadaraSourceBase
protected override string Name => "Immortal Updates";
protected override string Url => "https://immortalupdates.com";

public ImmortalUpdatesSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public ImmortalUpdatesSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ internal class KnightNoScanlationSource : MadaraSourceBase
protected override string Name => "Knight No Scanlation";
protected override string Url => "https://knightnoscanlation.com";

public KnightNoScanlationSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public KnightNoScanlationSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ internal class KunMangaSource : MadaraSourceBase
protected override string Name => "Kun Manga";
protected override string Url => "https://kunmanga.com";

public KunMangaSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public KunMangaSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ internal class LSComicSource : MadaraSourceBase

protected override bool UseAjaxChapterListMethod => true;

public LSComicSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public LSComicSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ internal class LilyMangaSource : MadaraSourceBase
protected override bool UseAjaxChapterListMethod => true;
protected override bool HasCloudflareProtection => true;

public LilyMangaSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public LilyMangaSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ internal class MadaraDexSource : MadaraSourceBase
protected override string Url => "https://madaradex.org";
protected override bool HasCloudflareProtection => true;

public MadaraDexSource(GenericHttpClient genericHttpClient, CloudflareHttpClient cloudflareHttpClient)
: base(genericHttpClient, cloudflareHttpClient)
public MadaraDexSource(
GenericHttpClient genericHttpClient,
CloudflareHttpClient cloudflareHttpClient,
ILoggerFactory loggerFactory
)
: base(genericHttpClient, cloudflareHttpClient, loggerFactory)
{
}
}
Loading

0 comments on commit e9d23df

Please sign in to comment.