Skip to content

Commit

Permalink
Added Animaregia #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Creckeryop committed Feb 4, 2020
1 parent a31ad38 commit 783fafa
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Spanish:
* LeoManga
* InManga

Portugal:
* Animaregia

## Manual Installation
Throw `*.lua` file to `ux0:data/noboru/parsers/` and launch app

Expand Down
131 changes: 131 additions & 0 deletions parsers/[PT]Animaregia.lua
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

0 comments on commit 783fafa

Please sign in to comment.