Skip to content

Commit

Permalink
Added Submanga #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Creckeryop committed Mar 24, 2020
1 parent 24c6404 commit 652ac85
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions parsers/[ES]Submanga.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Submanga = Parser:new("Submanga", "https://submangas.net", "ESP", "SUBMANGASPA")

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

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

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

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

function Submanga:getChapters(manga, dest_table)
local content = downloadContent(manga.Link)
local t = {}
for Link, Name in content:gmatch("chapter%-title%-rtl\">[^<]-<a href=\"([^\"]-)\">([^<]-)</a>") do
t[#t + 1] = {
Name = Name,
Link = Link,
Pages = {},
Manga = manga
}
end
for i = #t, 1, -1 do
dest_table[#dest_table + 1] = t[i]
end
end

function Submanga:prepareChapter(chapter, dest_table)
local content = downloadContent(chapter.Link)
local t = dest_table
for Link in content:gmatch("img%-responsive\"[^>]-data%-src=' ([^']-) '") do
t[#t + 1] = Link
Console.write("Got " .. t[#t])
end
end

function Submanga:loadChapterPage(link, dest_table)
dest_table.Link = link
end

0 comments on commit 652ac85

Please sign in to comment.