mirror of
https://github.com/dazedcat19/FMD2.git
synced 2024-11-27 05:41:08 +00:00
HentaiHand: Fixed all (Issue #923)
This commit is contained in:
parent
f36d22f5ce
commit
d142655041
@ -1,68 +1,137 @@
|
||||
function getinfo()
|
||||
mangainfo.url=MaybeFillHost(module.RootURL, url)
|
||||
if http.get(mangainfo.url) then
|
||||
x=TXQuery.Create(http.document)
|
||||
mangainfo.title=x.xpathstring('//h1')
|
||||
if module.website == 'NHentai' then
|
||||
mangainfo.coverlink=x.xpathstring('//*[@id="cover"]//img/@data-src')
|
||||
mangainfo.artists=x.xpathstringall('//*[@id="tags"]//a[contains(@href,"/artist/")]/text()')
|
||||
else
|
||||
mangainfo.coverlink=x.xpathstring('//*[@id="cover"]//img/@src')
|
||||
mangainfo.artists=x.xpathstringall('//*[@id="tags"]//a[contains(@href,"/artists/")]/text()')
|
||||
end
|
||||
mangainfo.genres=x.xpathstringall('//*[@id="tags"]//a/text()')
|
||||
mangainfo.summary=x.xpathstring('//div[contains(@class, "drop-discription")]/p/text()')
|
||||
mangainfo.chapterlinks.add(url)
|
||||
mangainfo.chapternames.add(mangainfo.title)
|
||||
return no_error
|
||||
else
|
||||
return net_problem
|
||||
end
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- Scripting Parameters
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
local LuaDebug = require 'LuaDebugging'
|
||||
-- LuaDebugging = true --> Override the global LuaDebugging variable by uncommenting this line.
|
||||
-- LuaStatistics = true --> Override the global LuaStatistics variable by uncommenting this line.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- Local Constants
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
DirectoryPagination = '/?page='
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- Event Functions
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
-- Get info and chapter list for current manga.
|
||||
function GetInfo()
|
||||
local x = nil
|
||||
local u = MaybeFillHost(module.RootURL, url)
|
||||
|
||||
--[[Debug]] LuaDebug.WriteLogWithHeader('GetInfo', 'url -> ' .. u)
|
||||
if not http.Get(u) then return net_problem end
|
||||
|
||||
x = TXQuery.Create(http.Document)
|
||||
mangainfo.Title = x.XPathString('//h1')
|
||||
mangainfo.CoverLink = x.XPathString('//div[@id="cover"]//img/@data-src')
|
||||
if mangainfo.CoverLink == '' then mangainfo.CoverLink = x.XPathString('//div[@id="cover"]//img/@src') end
|
||||
mangainfo.Artists = x.XPathString('//section[@id="tags"]//a[contains(@href, "artist")]/text()')
|
||||
mangainfo.Genres = x.XPathStringAll('//section[@id="tags"]//a/text()')
|
||||
mangainfo.Summary = x.XPathString('//div[contains(@class, "drop-discription")]/p/text()')
|
||||
|
||||
mangainfo.ChapterLinks.Add(url)
|
||||
mangainfo.ChapterNames.Add(mangainfo.Title)
|
||||
|
||||
--[[Debug]] LuaDebug.PrintMangaInfo()
|
||||
--[[Debug]] LuaDebug.WriteStatistics('Chapters', mangainfo.ChapterLinks.Count .. ' (' .. mangainfo.Title .. ')')
|
||||
|
||||
|
||||
return no_error
|
||||
end
|
||||
|
||||
function getpagenumber()
|
||||
if http.get(MaybeFillHost(module.rooturl,url)) then
|
||||
TXQuery.Create(http.Document).xpathstringall('//*[@class="thumb-container"]//img/@data-src/replace(.,"//t\\.(.+\\d+)t\\.","//i.$1.")',task.pagelinks)
|
||||
|
||||
-- Get the page count of the manga list of the current website.
|
||||
function GetDirectoryPageNumber()
|
||||
local u = module.RootURL .. DirectoryPagination .. 1
|
||||
|
||||
--[[Debug]] LuaDebug.WriteLogWithHeader('GetDirectoryPageNumber', 'url -> ' .. u)
|
||||
if not http.Get(u) then return net_problem end
|
||||
|
||||
if module.website == 'NHentai' then
|
||||
page = tonumber(TXQuery.Create(http.Document).XPathString('//a[@class="last"]/@href/substring-after(.,"=")'))
|
||||
else
|
||||
page = tonumber(TXQuery.Create(http.Document).XPathString('//section[@class="pagination"]/li[last()]/a/@href'):match('?page=(%d+)&order='))
|
||||
end
|
||||
|
||||
--[[Debug]] LuaDebug.WriteStatistics('DirectoryPages', page)
|
||||
|
||||
return no_error
|
||||
end
|
||||
|
||||
|
||||
-- Get links and names from the manga list of the current website.
|
||||
function GetNameAndLink()
|
||||
local x = nil
|
||||
local u = module.RootURL .. DirectoryPagination .. IncStr(url)
|
||||
|
||||
--[[Debug]] LuaDebug.WriteLogWithHeader('GetNameAndLink', 'url -> ' .. u)
|
||||
if not http.Get(u) then return net_problem end
|
||||
|
||||
x = TXQuery.Create(http.Document)
|
||||
x.XPathHREFAll('//div[@id="content"]/div/div[@class="gallery"]/a', links, names)
|
||||
|
||||
--[[Debug]] LuaDebug.PrintMangaDirectoryEntries(IncStr(url))
|
||||
|
||||
return no_error
|
||||
end
|
||||
|
||||
|
||||
-- Get the page count for the current chapter.
|
||||
function GetPageNumber()
|
||||
local x = nil
|
||||
local u = MaybeFillHost(module.RootURL, url)
|
||||
|
||||
--[[Debug]] LuaDebug.WriteLogWithHeader('GetPageNumber', 'url -> ' .. u)
|
||||
if not http.Get(u) then return net_problem end
|
||||
|
||||
x = TXQuery.Create(http.Document)
|
||||
x.XPathStringAll('//a[@class="gallerythumb"]/@href', task.PageContainerLinks)
|
||||
task.PageNumber = task.PageContainerLinks.Count
|
||||
|
||||
--[[Debug]] LuaDebug.PrintChapterPageLinks()
|
||||
--[[Debug]] LuaDebug.WriteStatistics('ChapterPages', task.PageContainerLinks.Count .. ' (' .. u .. ')')
|
||||
|
||||
return no_error
|
||||
end
|
||||
|
||||
|
||||
-- Extract/Build/Repair image urls before downloading them.
|
||||
function GetImageURL()
|
||||
local u = MaybeFillHost(module.RootURL, task.PageContainerLinks[workid])
|
||||
|
||||
if http.Get(u) then
|
||||
task.PageLinks[workid] = TXQuery.Create(http.document).XPathString('//section[@id="image-container"]//img/@src')
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
return true
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function getdirectorypagenumber()
|
||||
if http.get(module.rooturl) then
|
||||
page=tonumber(TXQuery.Create(http.document).xpathstring('//a[@class="last"]/@href/substring-after(.,"=")'))
|
||||
return no_error
|
||||
else
|
||||
return net_problem
|
||||
end
|
||||
end
|
||||
|
||||
function getnameandlink()
|
||||
if http.get(module.rooturl..'/?page='..IncStr(url)) then
|
||||
TXQuery.Create(http.document).xpathhrefall('//*[@id="content"]/div/div[@class="gallery"]/a',links,names)
|
||||
return no_error
|
||||
else
|
||||
return net_problem
|
||||
end
|
||||
end
|
||||
|
||||
function AddWebsiteModule(name, url, cat)
|
||||
local m=NewModule()
|
||||
m.category=cat
|
||||
m.website=name
|
||||
m.rooturl=url
|
||||
m.ongetinfo='getinfo'
|
||||
m.ongetpagenumber='getpagenumber'
|
||||
m.ongetdirectorypagenumber='getdirectorypagenumber'
|
||||
m.ongetnameandlink='getnameandlink'
|
||||
m.sortedlist=true
|
||||
return m
|
||||
end
|
||||
----------------------------------------------------------------------------------------------------
|
||||
-- Module Initialization
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
function Init()
|
||||
local cat = 'H-Sites'
|
||||
AddWebsiteModule('NHentai', 'https://nhentai.net', cat)
|
||||
AddWebsiteModule('HentaiHand', 'https://hentaihand.com', cat)
|
||||
AddWebsiteModule('NHentai', 'https://nhentai.net', 'H-Sites')
|
||||
AddWebsiteModule('HentaiHand', 'https://hentaihand.com', 'H-Sites')
|
||||
end
|
||||
|
||||
function AddWebsiteModule(name, url, category)
|
||||
local m = NewModule()
|
||||
m.Website = name
|
||||
m.RootURL = url
|
||||
m.Category = category
|
||||
m.OnGetInfo = 'GetInfo'
|
||||
m.OnGetDirectoryPageNumber = 'GetDirectoryPageNumber'
|
||||
m.OnGetNameAndLink = 'GetNameAndLink'
|
||||
m.OnGetPageNumber = 'GetPageNumber'
|
||||
m.OnGetImageURL = 'GetImageURL'
|
||||
m.SortedList = True
|
||||
return m
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user