Skip to content

Commit

Permalink
tmanginformation, store moduleid for faster locate module in batch up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
riderkick committed Jul 25, 2015
1 parent 09689f5 commit f178d47
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
28 changes: 16 additions & 12 deletions baseunits/uData.pas
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ TMangaInformation = class(TObject)
isGenerateFolderChapterName: Boolean;
isRemoveUnicode: Boolean;
FHTTP: THTTPSend;
ModuleId: Integer;

procedure OnTag(NoCaseTag, ActualTag: String);
procedure OnText(Text: String);
Expand Down Expand Up @@ -1844,6 +1845,7 @@ constructor TMangaInformation.Create(AOwnerThread: TFMDThread;
if CreateInfo then
mangaInfo := TMangaInfo.Create;
isGetByUpdater := False;
ModuleId := -2;
end;

destructor TMangaInformation.Destroy;
Expand Down Expand Up @@ -1983,7 +1985,6 @@ function TMangaInformation.GetDirectoryPage(var Page: Integer;

begin
Page := 0;
WebsiteID := GetMangaSiteID(website);

//load User-Agent from INIAdvanced
if website <> '' then
Expand All @@ -2000,10 +2001,13 @@ function TMangaInformation.GetDirectoryPage(var Page: Integer;
else
begin
BROWSER_INVERT := False;
if Modules.ModuleAvailable(website, MMGetDirectoryPageNumber, p) then
Result := Modules.GetDirectoryPageNumber(Self, Page, p)
if ModuleId <> -1 then
ModuleId := Modules.LocateModule(website);
if Modules.ModuleAvailable(ModuleId, MMGetDirectoryPageNumber) then
Result := Modules.GetDirectoryPageNumber(Self, Page, ModuleId)
else
begin
WebsiteID := GetMangaSiteID(website);
Source := TStringList.Create;
if website = WebsiteRoots[ANIMEA_ID, 0] then
Result := GetAnimeADirectoryPageNumber
Expand Down Expand Up @@ -2173,7 +2177,6 @@ function TMangaInformation.GetNameAndLink(const names, links: TStringList;
Source: TStringList;
Parser: THTMLParser;
WebsiteID: Cardinal;
p: Integer;

{$I includes/Manga2u/names_and_links.inc}

Expand Down Expand Up @@ -2340,17 +2343,17 @@ function TMangaInformation.GetNameAndLink(const names, links: TStringList;
{$I includes/WPManga/names_and_links.inc}

begin
WebsiteID := GetMangaSiteID(website);

//load User-Agent from INIAdvanced
if website <> '' then
FHTTP.UserAgent := INIAdvanced.ReadString('UserAgent', website, '');

p := -1;
if Modules.ModuleAvailable(website, MMGetNameAndLink, p) then
Result := Modules.GetNameAndLink(Self, names, links, URL, p)
if ModuleId <> -1 then
ModuleId := Modules.LocateModule(website);
if Modules.ModuleAvailable(ModuleId, MMGetNameAndLink) then
Result := Modules.GetNameAndLink(Self, names, links, URL, ModuleId)
else
begin
WebsiteID := GetMangaSiteID(website);
Source := TStringList.Create;
if website = WebsiteRoots[ANIMEA_ID, 0] then
Result := AnimeAGetNamesAndLinks
Expand Down Expand Up @@ -2814,9 +2817,10 @@ function TMangaInformation.GetInfoFromURL(const website, URL: String;
mangaInfo.chapterName.Clear;
mangaInfo.chapterLinks.Clear;

j := -1;
if Modules.ModuleAvailable(website, MMGetInfo, j) then
Result := Modules.GetInfo(Self, URL, Reconnect, j)
if ModuleId <> -1 then
ModuleId := Modules.LocateModule(website);
if Modules.ModuleAvailable(ModuleId, MMGetInfo) then
Result := Modules.GetInfo(Self, URL, Reconnect, ModuleId)
else
begin
WebsiteID := GetMangaSiteID(website);
Expand Down
6 changes: 5 additions & 1 deletion baseunits/uUpdateThread.pas
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface

uses
Classes, SysUtils, typinfo, syncobjs, uData, LazFileUtils,
uBaseUnit, uFMDThread, uTranslation, uMisc;
uBaseUnit, uFMDThread, uTranslation, uMisc, WebsiteModules;

type
TUpdateMangaManagerThread = class;
Expand Down Expand Up @@ -60,6 +60,7 @@ TUpdateMangaManagerThread = class(TFMDThread)
mainDataProcess: TDBDataProcess;
names, links, websites: TStringList;
website, twebsite: String;
ModuleId: Integer;
workPtr, directoryCount,
// for fakku's doujinshi only
directoryCount2, numberOfThreads, websitePtr: Integer;
Expand Down Expand Up @@ -116,6 +117,7 @@ procedure TUpdateMangaThread.Execute;
else
Info := TMangaInformation.Create(Self, False);
Info.isGetByUpdater := True;
info.ModuleId := manager.ModuleId;

case CheckStyle of
CS_DIRECTORY_COUNT:
Expand Down Expand Up @@ -330,6 +332,7 @@ constructor TUpdateMangaManagerThread.Create;
threads := TFPList.Create;
SortedList := False;
NoMangaInfo := False;
ModuleId := -1;
end;

destructor TUpdateMangaManagerThread.Destroy;
Expand Down Expand Up @@ -579,6 +582,7 @@ procedure TUpdateMangaManagerThread.Execute;
while websitePtr < websites.Count do
begin
website := websites.Strings[websitePtr];
ModuleId := Modules.LocateModule(website);
SortedList := SitesWithSortedList(website);
NoMangaInfo := SitesWithoutInformation(website);
Inc(websitePtr);
Expand Down

0 comments on commit f178d47

Please sign in to comment.