From 4bb902e9f4e4fef11703c7dd409c58ebfc5c06f9 Mon Sep 17 00:00:00 2001 From: doomsdayrs Date: Wed, 26 Oct 2022 13:48:01 -0400 Subject: [PATCH 1/3] Begin ReaperScans rewrite --- src/en/ReaperScans.lua | 110 +++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 49 deletions(-) diff --git a/src/en/ReaperScans.lua b/src/en/ReaperScans.lua index 18ea18a7..9d30edc4 100644 --- a/src/en/ReaperScans.lua +++ b/src/en/ReaperScans.lua @@ -1,51 +1,63 @@ --- {"id":4223,"ver":"1.0.4","libVer":"1.0.0","author":"MechTechnology","dep":["Madara>=2.3.0"]} +-- {"id":4223,"ver":"2.0.0","libVer":"1.0.0","author":"Doomsdayrs"} -return Require("Madara")("https://reaperscans.com", { +local baseURL = "https://reaperscans.com" + +local function shrinkURL(url) + return url:match(baseURL .. "/novels/(.+)/") +end + +local function expandURL(url) + return baseURL .. "/novels/" .. url +end + +local function getPassage(){ +} + +local parseNovel(){ +} + +return { id = 4223, - name = "Reaper Scans", - imageURL = "https://github.com/shosetsuorg/extensions/raw/dev/icons/ReaperScans.png", - chaptersScriptLoaded = false, - chaptersListSelector= "li.wp-manga-chapter.free-chap", - latestNovelSel = ".col-4.col-md-2.badge-pos-2", - novelListingURLPath = "all-series/novels", - shrinkURLNovel = "series", - searchHasOper = true, - - genres = { - "Action", - "Adult", - "Adventure", - "Comedy", - "Crime", - "Drama", - "Ecchi", - "Fantasy", - "Harem", - "Historical", - "Horror", - "Isekai", - "Manhua", - "Manhwa", - "Martial Arts", - "Mature", - "Mecha", - "Mystery", - "Novel", - "Psychological", - "Romance", - "School Life", - "Sci-fi", - "Seinen", - "Shoujo", - "Shounen", - ["slice-of-life"] = "Slice of Life", - "Sports", - "Supernatural", - "Tragedy", - ["complete"] = "Completed", - ["on-going"] = "Ongoing", - "Canceled", - "On Hold", - "On Hold", - } -}) + name = "MTLNovel", + baseURL = baseURL, + imageURl imageURL = "https://github.com/shosetsuorg/extensions/raw/dev/icons/ReaperScans.png", + hasSearch = true, + chapterType = ChapterType.HTML, + + shrinkURL = shrinkURL, + expandURL = expandURL, + + listings = { + Listing("Latest", true, function(data) + local url = baseURL .. "/latest/novels" + + local d = GETDocument(url) + + return map(d:select("div.relative.flex.space-x-2"), function(v) + local lis = Novel() + lis:setImageURL(v:selectFirst("img"):attr("src")) + local title = v:selectFirst("p.text-sm"):selectFirst("a") + lis:setLink(shrinkURL(title:attr("href"))) + lis:setTitle(title:text()) + return lis + end) + end), + Listing("All", true, function(data) + local url = baseURL .. "/novels" + + local d = GETDocument(url) + + return map(d:select("li.col-span-1"), function(v) + local lis = Novel() + lis:setImageURL(v:selectFirst("img"):attr("src")) + local title = v:selectFirst("p.text-sm") + lis:setLink(shrinkURL(title:attr("href"))) + lis:setTitle(title:text()) + return lis + end) + end), + }, + getPassage = getPassage, + parseNovel = parseNovel, + search = search +} From 4ff09211cdfa32791db26a6c5d0a57540c68ffaf Mon Sep 17 00:00:00 2001 From: doomsdayrs Date: Wed, 26 Oct 2022 18:21:40 -0400 Subject: [PATCH 2/3] Add chapter func --- src/en/ReaperScans.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/en/ReaperScans.lua b/src/en/ReaperScans.lua index 9d30edc4..423a9220 100644 --- a/src/en/ReaperScans.lua +++ b/src/en/ReaperScans.lua @@ -10,10 +10,18 @@ local function expandURL(url) return baseURL .. "/novels/" .. url end -local function getPassage(){ +local function getPassage(chapterURL){ + local url = baseURL .. "/" .. chapterURL + local document = GETDocument(url) + local htmlElement = document:selectFirst("section.p-2") + + return pageOfElem(htmlElement, true) } -local parseNovel(){ +local parseNovel(novelURL){ + local url = baseURL .. "/" .. novelURL + local document = GETDocument(url):selectFirst("article.post") + } return { From 90afe55170aa55354f1d15225b2e1a51ab06e3e0 Mon Sep 17 00:00:00 2001 From: doomsdayrs Date: Fri, 28 Oct 2022 00:46:07 -0400 Subject: [PATCH 3/3] Add parseNovel function, search next --- src/en/ReaperScans.lua | 85 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 7 deletions(-) diff --git a/src/en/ReaperScans.lua b/src/en/ReaperScans.lua index 423a9220..e741575d 100644 --- a/src/en/ReaperScans.lua +++ b/src/en/ReaperScans.lua @@ -10,25 +10,95 @@ local function expandURL(url) return baseURL .. "/novels/" .. url end -local function getPassage(chapterURL){ +local function getPassage(chapterURL) local url = baseURL .. "/" .. chapterURL local document = GETDocument(url) local htmlElement = document:selectFirst("section.p-2") return pageOfElem(htmlElement, true) -} +end -local parseNovel(novelURL){ +local function parseNovel(novelURL) local url = baseURL .. "/" .. novelURL local document = GETDocument(url):selectFirst("article.post") + local novelInfo = NovelInfo() -} + local headerNChapters = document:selectFirst("div.p-2.space-y-4") + + -- Header + local headerElement = headerNChapters:selectFirst("div.mx-auto") + + local titleElement = headerNChapters:selectFirst("h1") + novelInfo:setTitle(titleElement:text()) + + local imageElement = headerElement:selectFirst("img") + novelInfo:setImageURL(imageElement:attr("src")) + + -- About + local aboutElement = document:selectFirst("div.lg\:col-span-1") + + local descriptionElement = aboutElement:selectFirst("p") + novelInfo:setDescription(descriptionElement:text():gsub("
","\n")) + + local otherElements = document:selectFirst("dl.mt-2"):select("dd") + + local languageElement = otherElements[0] + novelInfo:setLanguage(languageElement:text()) + + local statusElement = otherElements[1] + local status = statusElement:text() + novelInfo:setStatus(NovelStatus(status == "Completed" and 1 or status == "Ongoing" and 0 or 3)) + + -- Chapters + local chaptersBoxElement = headerNChapters:selectFirst("pb-4"):selectFirst("ul") + + local pages = 0 + pages = chaptersBoxElement:selectFirst("div.releative.z-0"):select("button"):size() + + -- After the following loop, this array will contain a list of chapters reversed. + local chapterElements = {} + chapterElements.concat(chaptersBoxElement:select("li")) + + for page = 0, pages, 1 + do + document = GETDocument(url .. "?page=" .. page):selectFirst("article.post") + headerNChapters = document:selectFirst("div.p-2.space-y-4") + chaptersBoxElement = headerNChapters:selectFirst("pb-4"):selectFirst("ul") + chapterElements.concat(chaptersBoxElement:select("li")) + end + + local count = 0 + local chapters = map( + chapterElements, + function(chapter) + local c = NovelChapter() + c:setTitle(chapter:selectFirst("p"):text()) + c:setLink(chapter:selectFirst("a"):attr("href")) + + -- count the chapters + count = count + 1 + return c + end + ) + chapters = map( + chapters, + function(chapter) + chapter:setOrder(count) + count = count - 1 + return chapter + end + ) + Reverse(chapters) + novelInfo:setChapters(chapters) + + return novelInfo +end return { id = 4223, - name = "MTLNovel", + name = "Reaper Scans", baseURL = baseURL, - imageURl imageURL = "https://github.com/shosetsuorg/extensions/raw/dev/icons/ReaperScans.png", + imageURL = "https://github.com/shosetsuorg/extensions/raw/dev/icons/ReaperScans.png", hasSearch = true, chapterType = ChapterType.HTML, @@ -67,5 +137,6 @@ return { }, getPassage = getPassage, parseNovel = parseNovel, - search = search + hasSearch = false + --search = search }