feat(source): Add ReaperScans Br

LNReader/lnreader-sources#71
This commit is contained in:
Rajarshee Chatterjee
2021-09-23 10:40:26 +05:30
parent 91168a335b
commit dc9529c322
3 changed files with 176 additions and 0 deletions
+167
View File
@@ -0,0 +1,167 @@
import cheerio from "react-native-cheerio";
import { Status } from "../helpers/constants";
const baseUrl = "https://reaperscans.com.br/";
const sourceId = 79;
const sourceName = "ReaperScans (Br)";
const popularNovels = async (page) => {
let url =
baseUrl +
"/all-series/todas-as-series/page/" +
page +
"/?m_orderby=rating";
const totalPages = 1;
const result = await fetch(url);
const body = await result.text();
$ = cheerio.load(body);
let novels = [];
$(".page-item-detail").each(function (result) {
const novelName = $(this).find(".item-summary h3").text().trim();
const novelCover = $(this).find(".img-responsive").attr("data-src");
let novelUrl = $(this).find("div > a").attr("href");
const novel = {
sourceId,
novelName,
novelCover,
novelUrl,
};
novels.push(novel);
});
console.log(novels);
return { totalPages, novels };
};
const parseNovelAndChapters = async (novelUrl) => {
const url = novelUrl;
const result = await fetch(url);
const body = await result.text();
$ = cheerio.load(body);
let novel = { sourceId, url, sourceName };
$(".post-title > h3 > span").remove();
novel.novelUrl = novelUrl;
novel.novelName = $(".post-title > h1").text().trim();
novel.novelCover = $(".summary_image > a > img").attr("data-src");
$(".post-content_item").each(function () {
const detailName = $(this).find(".summary-heading > h5").text().trim();
const detail = $(this).find(".summary-content").text().trim();
switch (detailName) {
case "Genre(s)":
novel.genre = detail.replace(/[\t\n]/g, ",");
break;
case "Author(s)":
novel.author = detail;
break;
case "Status":
novel.status = detail.includes("OnGoing")
? Status.ONGOING
: Status.COMPLETED;
break;
}
});
$(".description-summary > div.summary__content").find("em").remove();
$(".premium-block").remove();
novel.summary = $("div.summary__content").text().trim();
let novelChapters = [];
$(".wp-manga-chapter").each(function () {
$("i").remove();
const chapterName = $(this).find("a").text().trim();
const releaseDate = null;
const chapterUrl = $(this).find("a").attr("href");
const chapter = { chapterName, releaseDate, chapterUrl };
novelChapters.push(chapter);
});
novel.chapters = novelChapters.reverse();
return novel;
};
const parseChapter = async (novelUrl, chapterUrl) => {
const url = chapterUrl;
console.log(url);
const result = await fetch(url);
const body = await result.text();
$ = cheerio.load(body);
const chapterName = $("#chapter-heading").text();
let chapterText = $(".reading-content").html();
const chapter = {
sourceId,
novelUrl,
chapterUrl,
chapterName,
chapterText,
};
return chapter;
};
const searchNovels = async (searchTerm) => {
const url = `${baseUrl}?s=${searchTerm}&post_type=wp-manga`;
const result = await fetch(url);
const body = await result.text();
$ = cheerio.load(body);
let novels = [];
$(".c-tabs-item__content").each(function (result) {
const novelName = $(this).find(".post-title > h3").text().trim();
const novelCover = $(this).find("div > div > a > img").attr("data-src");
let novelUrl = $(this).find("div > div > a").attr("href");
novelUrl = novelUrl.replace(`${baseUrl}/`, "");
const novel = {
sourceId,
novelName,
novelCover,
novelUrl,
};
novels.push(novel);
});
return novels;
};
const ReaperScansBrScraper = {
popularNovels,
parseNovelAndChapters,
parseChapter,
searchNovels,
};
export default ReaperScansBrScraper;
+2
View File
@@ -79,6 +79,7 @@ import EpikNovelScraper from "./tr/epiknovel";
import TravisTranslationsScraper from "./en/travistranslations";
import NovelDeGlaceScraper from "./fr/noveldeglace";
import RainOfSnowScraper from "./en/rainofsnow";
import ReaperScansBrScraper from "./br/ReaperScansBr";
export const getSource = (sourceId) => {
const scrapers = {
@@ -159,6 +160,7 @@ export const getSource = (sourceId) => {
76: TravisTranslationsScraper,
77: NovelDeGlaceScraper,
78: RainOfSnowScraper,
79: ReaperScansBrScraper,
};
return scrapers[sourceId];
+7
View File
@@ -537,5 +537,12 @@
"sourceName": "RainOfSnow",
"icon": "https://github.com/LNReader/lnreader-sources/blob/main/src/en/rainofsnow/icon.png?raw=true",
"lang": "French"
},
{
"sourceId": 79,
"url": "https://reaperscans.com.br/",
"sourceName": "ReaperScans (BR)",
"icon": "https://github.com/LNReader/lnreader-sources/blob/main/src/en/reaperscans/icon.png?raw=true",
"lang": "Portuguese (Brazil)"
}
]