Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions baseunits/WebsiteModules.pas
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ TModuleContainer = class;

TOnLogin = function(const AHTTP: THTTPSendThread; const AModule: TModuleContainer): Boolean;
TOnAccountState = function(const AModule: TModuleContainer): Boolean;
TOnCheckSite = function(const AModule: TModuleContainer): Boolean;

TModuleMethod = (MMGetDirectoryPageNumber, MMGetNameAndLink, MMGetInfo,
MMTaskStart, MMGetPageNumber, MMGetImageURL, MMBeforeDownloadImage,
Expand Down Expand Up @@ -149,6 +150,7 @@ TModuleContainer = class
OnAfterImageSaved: TOnAfterImageSaved;
OnLogin: TOnLogin;
OnAccountState: TOnAccountState;
OnCheckSite: TOnCheckSite;
constructor Create;
destructor Destroy; override;
public
Expand Down
40 changes: 40 additions & 0 deletions baseunits/lua/LuaMangaCheck.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
unit LuaMangaCheck;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, {$ifdef luajit}lua{$else}{$ifdef lua54}lua54{$else}lua53{$endif}{$endif};

procedure luaMangaCheckAddMetaTable(const L: Plua_State; const Obj: Pointer;
const MetaTable, UserData: Integer);

implementation

uses
uBaseUnit, LuaClass, LuaStrings;

procedure luaMangaCheckAddMetaTable(const L: Plua_State; const Obj: Pointer;
const MetaTable, UserData: Integer);
begin
with TMangaCheck(Obj) do
begin
luaClassAddStringProperty(L, MetaTable, 'MangaURL', @MangaURL);
luaClassAddStringProperty(L, MetaTable, 'MangaTitle', @MangaTitle);
luaClassAddStringProperty(L, MetaTable, 'ChapterURL', @ChapterURL);
luaClassAddStringProperty(L, MetaTable, 'ChapterURLPrefix',
@ChapterURLPrefix);
luaClassAddStringProperty(L, MetaTable, 'ChapterTitle', @ChapterTitle);
luaClassAddBooleanProperty(L, MetaTable, 'MangaURLAddRootHost',
@MangaURLAddRootHost);
luaClassAddBooleanProperty(L, MetaTable, 'ChapterURLAddRootHost',
@ChapterURLAddRootHost);
end;
end;

initialization
luaClassRegister(TMangaCheck, @luaMangaCheckAddMetaTable);

end.

24 changes: 23 additions & 1 deletion baseunits/lua/LuaWebsiteModules.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TLuaWebsiteModule = class
OnAfterImageSaved: String;
OnLogin: String;
OnAccountState: String;
OnCheckSite: String;
Storage: TStringsStorage;
LastUpdated: String;
Container: TLuaWebsiteModulesContainer;
Expand Down Expand Up @@ -143,7 +144,7 @@ implementation
uses
FMDOptions, FileUtil, MultiLog, LuaClass, LuaBase, LuaMangaInfo, LuaHTTPSend,
LuaXQuery, LuaUtils, LuaDownloadTask, LuaUpdateListManager, LuaStrings,
LuaCriticalSection, LuaPackage, uData,
LuaCriticalSection, LuaPackage, uData, LuaMangaCheck,
uDownloadsManager, xquery, httpsendthread, FMDVars, uBaseUnit, LuaWebsiteBypass,
LuaWebsiteModuleHandler;

Expand Down Expand Up @@ -445,6 +446,24 @@ function DoAccountState(const AModule: TModuleContainer): Boolean;
end;
end;

function DoCheckSite(const AModule: TModuleContainer): Boolean;
var
L: TLuaWebsiteModuleHandler;
begin
Result := False;
with TLuaWebsiteModule(AModule.LuaModule) do
try
L := GetLuaWebsiteModuleHandler(AModule);
LuaPushAccountStatus(L.Handle);

L.CallFunction(OnCheckSite);
Result := lua_toboolean(L.Handle, -1);
except
on E: Exception do
SendLogException('LUA>DoCheckSite("' + ExtractFileName(Container.FileName) + '")>', E);
end;
end;

function _newwebsitemodule(L: Plua_State): Integer; cdecl;
begin
luaClassPushObject(L, TLuaWebsiteModule.Create, '', False, @luaWebsiteModuleAddMetaTable);
Expand Down Expand Up @@ -560,6 +579,8 @@ procedure TLuaWebsiteModulesLoaderThread.LoadLuaWebsiteModule(
Module.OnLogin := @DoLogin;
if OnAccountState <> '' then
Module.OnAccountState := @DoAccountState;
if OnCheckSite <> '' then
Module.OnCheckSite := @DoCheckSite;
end;
finally
Modules.Unlock;
Expand Down Expand Up @@ -1002,6 +1023,7 @@ procedure luaWebsiteModuleAddMetaTable(const L: Plua_State; const Obj: Pointer;
luaClassAddStringProperty(L, MetaTable, 'OnAccountState', @OnAccountState);
luaClassAddStringProperty(L, MetaTable, 'LastUpdated', @LastUpdated);
luaClassAddIntegerProperty(L, MetaTable, 'CurrentDirectoryIndex', @Module.CurrentDirectoryIndex);
luaClassAddStringProperty(L, MetaTable, 'OnCheckSite', @OnCheckSite);

luaClassAddProperty(L, MetaTable, UserData, 'TotalDirectory', @lua_gettotaldirectory, @lua_settotaldirectory);
luaClassAddProperty(L, MetaTable, UserData, 'AccountSupport', @lua_getaccountsupport, @lua_setaccountsupport);
Expand Down
74 changes: 73 additions & 1 deletion baseunits/uBaseUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,30 @@ TMangaInfo = class
function Clone: TMangaInfo;
end;

PMangaCheck = ^TMangaCheck;

{ TMangaCheck }

TMangaCheck = class
public
MangaURL,
MangaTitle,
ChapterURL,
ChapterTitle,
ChapterURLPrefix: String;
TestToCheck: Integer;
MangaURLAddRootHost: Boolean;
ChapterURLAddRootHost: Boolean;
Module: Pointer;
constructor Create;
destructor Destroy; override;
function ModuleID: String; inline;
function ModuleName: String; inline;
function ModuleFilename: String; inline;
procedure Clear;
function Clone: TMangaCheck;
end;

PDownloadInfo = ^TDownloadInfo;

{ TDownloadInfo }
Expand Down Expand Up @@ -638,7 +662,8 @@ procedure SendLogException(const AText: String; AException: Exception); inline;
implementation

uses
frmMain, WebsiteModules, webp, DCPrijndael, DCPsha512, FPWriteJPEG;
frmMain, WebsiteModules, webp, DCPrijndael, DCPsha512, FPWriteJPEG,
LuaWebsiteModules;

{$IFDEF WINDOWS}
// thanks Leledumbo for the code
Expand Down Expand Up @@ -3013,6 +3038,53 @@ function TMangaInfo.Clone: TMangaInfo;
Result.Module := Module;
end;

{ TMangaCheck }

constructor TMangaCheck.Create;
begin
inherited Create;
ChapterURLPrefix := '';
MangaURLAddRootHost := True;
ChapterURLAddRootHost := True;
end;

destructor TMangaCheck.Destroy;
begin
inherited Destroy;
end;
function TMangaCheck.ModuleID: String;
begin
Result := TModuleContainer(Module).ID;
end;
function TMangaCheck.ModuleName: String;
begin
Result := TModuleContainer(Module).Name;
end;
function TMangaCheck.ModuleFilename: String;
begin
Result := ExtractFileName(TLuaWebsiteModule(
TModuleContainer(Module).LuaModule).Container.FileName);
end;

procedure TMangaCheck.Clear;
begin
MangaURL := '';
MangaTitle := '';
ChapterURL := '';
ChapterTitle := '';
Module := nil;
end;

function TMangaCheck.Clone: TMangaCheck;
begin
Result := TMangaCheck.Create;
Result.MangaURL := MangaURL;
Result.MangaTitle := MangaTitle;
Result.ChapterURL := ChapterURL;
Result.ChapterTitle := ChapterTitle;
Result.Module := Module;
end;

constructor TDownloadPageThread.Create(CreateSuspended: Boolean);
begin
inherited Create(CreateSuspended);
Expand Down
4 changes: 4 additions & 0 deletions baseunits/uData.pas
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TMangaInformation = class(TObject)
public
HTTP: THTTPSendThread;
MangaInfo: TMangaInfo;
MangaCheck: TMangaCheck;
isGetByUpdater: Boolean;
isGenerateFolderChapterName: Boolean;
isRemoveUnicode: Boolean;
Expand Down Expand Up @@ -58,6 +59,7 @@ constructor TMangaInformation.Create(const AOwnerThread: TBaseThread);
FOwner := AOwnerThread;
HTTP := THTTPSendThread.Create(AOwnerThread);
MangaInfo := TMangaInfo.Create;
MangaCheck := TMangaCheck.Create;
isGetByUpdater := False;
isRemoveHostFromChapterLinks := True;
end;
Expand All @@ -66,6 +68,8 @@ destructor TMangaInformation.Destroy;
begin
if Assigned(MangaInfo) then
MangaInfo.Free;
if Assigned(MangaCheck) then
MangaCheck.Free;
HTTP.Free;
inherited Destroy;
end;
Expand Down
8 changes: 8 additions & 0 deletions lua/modules/KDTScans.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function Init()
m.OnGetInfo = 'GetInfo'
m.OnGetPageNumber = 'GetPageNumber'
m.OnBeforeDownloadImage = 'BeforeDownloadImage'
m.OnCheckSite = 'CheckSite'
end

----------------------------------------------------------------------------------------------------
Expand All @@ -24,6 +25,13 @@ local Template = require 'templates.MangaThemesia'
-- Event Functions
----------------------------------------------------------------------------------------------------

function CheckSite()
MANGACHECK.MangaURL = "https://www.silentquill.net/the-rise-of-the-errand-boy-who-was-kicked-out-of-the-guild-worlds-strongest-with-ultra-versatile-living-skills/"
MANGACHECK.MangaTitle = 'The Rise of the Errand Boy Who was Kicked Out of the Guild: World’s Strongest with Ultra-Versatile Living Skills'
MANGACHECK.ChapterURL = "https://www.silentquill.net/the-rise-of-the-errand-boy-who-was-kicked-out-of-the-guild-worlds-strongest-with-ultra-versatile-living-skills-ch-1/"
MANGACHECK.ChapterTitle = 'Chapter 1'
end

-- Get links and names from the manga list of the current website.
function GetNameAndLink()
Template.GetNameAndLink()
Expand Down
8 changes: 7 additions & 1 deletion lua/modules/WeebCentral.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function Init()
m.MaxTaskLimit = 2
m.MaxConnectionLimit = 4
m.SortedList = true
m.OnCheckSite = 'CheckSite'
end

----------------------------------------------------------------------------------------------------
Expand All @@ -28,7 +29,12 @@ local DirectoryPageLimit = 32
----------------------------------------------------------------------------------------------------
-- Event Functions
----------------------------------------------------------------------------------------------------

function CheckSite()
MANGACHECK.MangaURL = "/series/01J76XYGGM22WZP7T4TKA4ZFAF/Kagurabachi"
MANGACHECK.MangaTitle = 'Kagurabachi'
MANGACHECK.ChapterURL = "/chapters/01K4JBY7YN9XEZ35F5GECH6ZWP"
MANGACHECK.ChapterTitle = 'Chapter 92.5'
end
-- Get the page count of the manga list of the current website.
function GetDirectoryPageNumber()
local u = MODULE.RootURL .. DirectoryPagination .. 0
Expand Down
5 changes: 3 additions & 2 deletions mangadownloader/forms/frmAccountManager.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ object AccountManagerForm: TAccountManagerForm
Colors.FocusedSelectionBorderColor = clHotLight
Colors.SelectionRectangleBorderColor = clHotLight
Colors.UnfocusedSelectionBorderColor = clBtnShadow
Header.AutoSizeIndex = 0
Header.AutoSizeIndex = -1
Header.Columns = <
item
MinWidth = 25
Expand All @@ -149,10 +149,11 @@ object AccountManagerForm: TAccountManagerForm
item
Position = 3
Text = 'Status'
Width = 174
end>
Header.DefaultHeight = 17
Header.Height = 23
Header.Options = [hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
NodeDataSize = 1
TabOrder = 0
TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoTristateTracking, toAutoDeleteMovedNodes, toDisableAutoscrollOnFocus]
Expand Down
Loading