-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a31ad38
commit 783fafa
Showing
2 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
Animeregia = Parser:new("Animeregia", "https://animaregia.net", "PRT", "ANIMEREGIAPTG") | ||
|
||
local pt = { | ||
["À"] = "À", | ||
["Á"] = "Á", | ||
["Â"] = "Â", | ||
["Ã"] = "Ã", | ||
["Ç"] = "Ç", | ||
["È"] = "È", | ||
["É"] = "É", | ||
["Ê"] = "Ê", | ||
["Ì"] = "Ì", | ||
["Í"] = "Í", | ||
["Ï"] = "Ï", | ||
["Ò"] = "Ò", | ||
["Ó"] = "Ó", | ||
["Õ"] = "Õ", | ||
["Ù"] = "Ù", | ||
["Ú"] = "Ú", | ||
["Ü"] = "Ü", | ||
["à"] = "à", | ||
["á"] = "á", | ||
["â"] = "â", | ||
["ã"] = "ã", | ||
["ç"] = "ç", | ||
["è"] = "è", | ||
["é"] = "é", | ||
["ê"] = "ê", | ||
["ì"] = "ì", | ||
["í"] = "í", | ||
["ï"] = "ï", | ||
["ò"] = "ò", | ||
["ó"] = "ó", | ||
["õ"] = "õ", | ||
["ù"] = "ù", | ||
["ú"] = "ú", | ||
["ü"] = "ü", | ||
["ª"] = "ª", | ||
["º"] = "º", | ||
|
||
} | ||
local function stringify(str) | ||
for k, v in pairs(pt) do | ||
str = str:gsub(k, v) | ||
end | ||
return str | ||
end | ||
|
||
function Animeregia:getManga(link, dest_table) | ||
local file = {} | ||
Threads.insertTask(file, { | ||
Type = "StringRequest", | ||
Link = link, | ||
Table = file, | ||
Index = "string" | ||
}) | ||
while Threads.check(file) do | ||
coroutine.yield(false) | ||
end | ||
local content = file.string or "" | ||
local t = dest_table | ||
local done = true | ||
for Link, ImageLink, Name in content:gmatch("<a href=\"([^\"]-)\" class=\"thumbnail\">[^>]-src='([^']-)' alt='([^']-)'>[^<]-</a>") do | ||
local manga = CreateManga(Name, Link, self.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 Animeregia:getPopularManga(page, dest_table) | ||
self:getManga(self.Link.."/filterList?sortBy=views&page="..page, dest_table) | ||
end | ||
|
||
function Animeregia:searchManga(search, page, dest_table) | ||
self:getManga(self.Link.."/filterList?alpha="..search.."&sortBy=views&page="..page, dest_table) | ||
end | ||
|
||
function Animeregia:getChapters(manga, dest_table) | ||
local file = {} | ||
Threads.insertTask(file, { | ||
Type = "StringRequest", | ||
Link = manga.Link, | ||
Table = file, | ||
Index = "string" | ||
}) | ||
while Threads.check(file) do | ||
coroutine.yield(false) | ||
end | ||
local content = file.string or "" | ||
local t = {} | ||
for Link, Name in content:gmatch("chapter%-title%-rtl\">[^<]-<a href=\"([^\"]-)\">([^<]-)</a>") do | ||
t[#t + 1] = { | ||
Name = stringify(Name), | ||
Link = Link, | ||
Pages = {}, | ||
Manga = manga | ||
} | ||
end | ||
for i = #t, 1, -1 do | ||
dest_table[#dest_table + 1] = t[i] | ||
end | ||
end | ||
|
||
function Animeregia:prepareChapter(chapter, dest_table) | ||
local file = {} | ||
Threads.insertTask(file, { | ||
Type = "StringRequest", | ||
Link = chapter.Link, | ||
Table = file, | ||
Index = "string" | ||
}) | ||
while Threads.check(file) do | ||
coroutine.yield(false) | ||
end | ||
local content = file.string or "" | ||
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 Animeregia:loadChapterPage(link, dest_table) | ||
dest_table.Link = link | ||
end |