Skip to content

Commit

Permalink
Added LeoMangas #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Creckeryop committed Nov 6, 2022
1 parent 10b775b commit 9128ef9
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions parsers/[ES]LeoMangas.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LeoMangas=Parser:new("LeoMangas","https://leomangas.xyz","ESP","LEOMANGASSPA",1)local function a(b)return b:gsub("&#([^;]-);",function(c)local d=tonumber("0"..c)or tonumber(c)return d and u8c(d)or"&#"..c..";"end):gsub("&(.-);",function(c)return HTML_entities and HTML_entities[c]and u8c(HTML_entities[c])or"&"..c..";"end)end;local function e(f)local g={}Threads.insertTask(g,{Type="StringRequest",Link=f,Table=g,Index="text"})while Threads.check(g)do coroutine.yield(false)end;return g.text or""end;function LeoMangas:getManga(f,h)local i=e(f)h.NoPages=true;for j,k,l in i:gmatch('<a href="[^"]-/manga/([^"]-)"[^>]->[^>]-src=\'/*([^\']-)\' alt=\'([^\']-)\'>[^<]-</a>')do h[#h+1]=CreateManga(a(l),j,"https://"..k,self.ID,j)h.NoPages=false;coroutine.yield(false)end end;function LeoMangas:getPopularManga(m,h)self:getManga(self.Link.."/filterList?sortBy=views&asc=false&page="..m,h)end;function LeoMangas:searchManga(n,m,h)self:getManga(self.Link.."/filterList?alpha="..n.."&sortBy=views&asc=false&page="..m,h)end;function LeoMangas:getChapters(o,h)local i=e(self.Link.."/manga/"..o.Link)local p={}for j,l in i:gmatch('chapter%-title%-rtl">%s*<a href="[^"]-([^/"]*)">([^<]-)</a>')do p[#p+1]={Name=a(l),Link=j,Pages={},Manga=o}end;for q=#p,1,-1 do h[#h+1]=p[q]end end;function LeoMangas:prepareChapter(r,h)local i=e(self.Link.."/manga/"..r.Manga.Link.."/"..r.Link)for j in i:gmatch('img%-responsive"[^>]-data%-src=\'%s*/*([^\']-)%s*\'')do h[#h+1]="https://"..j end end;function LeoMangas:loadChapterPage(f,h)h.Link=f end
79 changes: 79 additions & 0 deletions source/[ES]LeoMangas.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
LeoMangas = Parser:new("LeoMangas", "https://leomangas.xyz", "ESP", "LEOMANGASSPA", 1)

local function stringify(string)
return string:gsub(
"&#([^;]-);",
function(a)
local number = tonumber("0" .. a) or tonumber(a)
return number and u8c(number) or "&#" .. a .. ";"
end
):gsub(
"&(.-);",
function(a)
return HTML_entities and HTML_entities[a] and u8c(HTML_entities[a]) or "&" .. a .. ";"
end
)
end

local function downloadContent(link)
local f = {}
Threads.insertTask(
f,
{
Type = "StringRequest",
Link = link,
Table = f,
Index = "text"
}
)
while Threads.check(f) do
coroutine.yield(false)
end
return f.text or ""
end

function LeoMangas:getManga(link, dt)
local content = downloadContent(link)
dt.NoPages = true
for Link, ImageLink, Name in content:gmatch('<a href="[^"]-/manga/([^"]-)"[^>]->[^>]-src=\'/*([^\']-)\' alt=\'([^\']-)\'>[^<]-</a>') do
dt[#dt + 1] = CreateManga(stringify(Name), Link, "https://" .. ImageLink, self.ID, Link)
dt.NoPages = false
coroutine.yield(false)
end
end

function LeoMangas:getPopularManga(page, dt)
self:getManga(self.Link .. "/filterList?sortBy=views&asc=false&page=" .. page, dt)
end

function LeoMangas:searchManga(search, page, dt)
self:getManga(self.Link .. "/filterList?alpha=" .. search .. "&sortBy=views&asc=false&page=" .. page, dt)
end

function LeoMangas:getChapters(manga, dt)
local content = downloadContent(self.Link .. "/manga/" .. manga.Link)
local t = {}

for Link, Name in content:gmatch('chapter%-title%-rtl">%s*<a href="[^"]-([^/"]*)">([^<]-)</a>') do
t[#t + 1] = {
Name = stringify(Name),
Link = Link,
Pages = {},
Manga = manga
}
end
for i = #t, 1, -1 do
dt[#dt + 1] = t[i]
end
end

function LeoMangas:prepareChapter(chapter, dt)
local content = downloadContent(self.Link .. "/manga/" .. chapter.Manga.Link .. "/" .. chapter.Link)
for Link in content:gmatch('img%-responsive"[^>]-data%-src=\'%s*/*([^\']-)%s*\'') do
dt[#dt + 1] = "https://" .. Link
end
end

function LeoMangas:loadChapterPage(link, dt)
dt.Link = link
end

0 comments on commit 9128ef9

Please sign in to comment.