From f178d472f2899984d2145264f7958e38adeb612a Mon Sep 17 00:00:00 2001 From: riderkick Date: Sun, 26 Jul 2015 00:44:57 +0800 Subject: [PATCH] tmanginformation, store moduleid for faster locate module in batch update --- baseunits/uData.pas | 28 ++++++++++++++++------------ baseunits/uUpdateThread.pas | 6 +++++- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/baseunits/uData.pas b/baseunits/uData.pas index 57eddd05c..fe12e9e7f 100644 --- a/baseunits/uData.pas +++ b/baseunits/uData.pas @@ -177,6 +177,7 @@ TMangaInformation = class(TObject) isGenerateFolderChapterName: Boolean; isRemoveUnicode: Boolean; FHTTP: THTTPSend; + ModuleId: Integer; procedure OnTag(NoCaseTag, ActualTag: String); procedure OnText(Text: String); @@ -1844,6 +1845,7 @@ constructor TMangaInformation.Create(AOwnerThread: TFMDThread; if CreateInfo then mangaInfo := TMangaInfo.Create; isGetByUpdater := False; + ModuleId := -2; end; destructor TMangaInformation.Destroy; @@ -1983,7 +1985,6 @@ function TMangaInformation.GetDirectoryPage(var Page: Integer; begin Page := 0; - WebsiteID := GetMangaSiteID(website); //load User-Agent from INIAdvanced if website <> '' then @@ -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 @@ -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} @@ -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 @@ -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); diff --git a/baseunits/uUpdateThread.pas b/baseunits/uUpdateThread.pas index 2c51481e9..0922eb762 100644 --- a/baseunits/uUpdateThread.pas +++ b/baseunits/uUpdateThread.pas @@ -12,7 +12,7 @@ interface uses Classes, SysUtils, typinfo, syncobjs, uData, LazFileUtils, - uBaseUnit, uFMDThread, uTranslation, uMisc; + uBaseUnit, uFMDThread, uTranslation, uMisc, WebsiteModules; type TUpdateMangaManagerThread = class; @@ -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; @@ -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: @@ -330,6 +332,7 @@ constructor TUpdateMangaManagerThread.Create; threads := TFPList.Create; SortedList := False; NoMangaInfo := False; + ModuleId := -1; end; destructor TUpdateMangaManagerThread.Destroy; @@ -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);