fix(source): WoopRead

This commit is contained in:
Rajarshee Chatterjee
2021-10-05 14:54:16 +05:30
parent fb5d5cf186
commit 5877448f9d
3 changed files with 20 additions and 49 deletions
+18 -41
View File
@@ -9,11 +9,11 @@ const popularNovels = async page => {
const result = await fetch(url);
const body = await result.text();
$ = cheerio.load(body);
const $ = cheerio.load(body);
let novels = [];
$('.page-item-detail').each(function (result) {
$('.page-item-detail').each(function () {
const novelName = $(this).find('.h5 > a').text();
const novelCover = $(this).find('img').attr('data-src');
@@ -39,7 +39,7 @@ const parseNovelAndChapters = async novelUrl => {
const result = await fetch(url);
const body = await result.text();
$ = cheerio.load(body);
let $ = cheerio.load(body);
let novel = {};
@@ -56,19 +56,11 @@ const parseNovelAndChapters = async novelUrl => {
.replace(/[\t\n]/g, '')
.trim();
novel.novelCover = $('.summary_image > a > img').attr('src');
novel.novelCover = $('.summary_image > a > img').attr('data-src');
$('.post-content_item').each(function (result) {
detailName = $(this)
.find('.summary-heading > h5')
.text()
.replace(/[\t\n]/g, '')
.trim();
detail = $(this)
.find('.summary-content')
.text()
.replace(/[\t\n]/g, '')
.trim();
$('.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)':
@@ -77,8 +69,8 @@ const parseNovelAndChapters = async novelUrl => {
case 'Author(s)':
novel.author = detail.trim();
break;
case 'Artist(s)':
novel.status = detail.trim();
case 'Status':
novel.status = detail.trim() === 'OnGoing' ? 'Ongoing' : 'Completed';
break;
}
});
@@ -90,30 +82,16 @@ const parseNovelAndChapters = async novelUrl => {
let novelChapters = [];
const novelId = $('.rating-post-id').attr('value');
let formData = new FormData();
formData.append('action', 'manga_get_chapters');
formData.append('manga', novelId);
const data = await fetch('https://woopread.com/wp-admin/admin-ajax.php', {
method: 'POST',
body: formData,
});
console.log(`${url}ajax/chapters/`);
const data = await fetch(`${url}ajax/chapters/`, {method: 'POST'});
const text = await data.text();
$ = cheerio.load(text);
$('.wp-manga-chapter.free-chap').each(function (result) {
chapterName = $(this)
.find('a')
.text()
.replace(/[\t\n]/g, '')
.trim();
releaseDate = $(this).find('span').text().replace('Free', '').trim();
chapterUrl = $(this).find('a').attr('href').replace(url, '');
$('.wp-manga-chapter.free-chap').each(function () {
const chapterName = $(this).find('a').text().trim();
const releaseDate = $(this).find('span').text().replace('Free', '').trim();
const chapterUrl = $(this).find('a').attr('href').replace(url, '');
novelChapters.push({chapterName, releaseDate, chapterUrl});
});
@@ -129,12 +107,11 @@ const parseChapter = async (novelUrl, chapterUrl) => {
const result = await fetch(url);
const body = await result.text();
$ = cheerio.load(body);
const $ = cheerio.load(body);
const chapterName = $('h1#chapter-heading').text();
let chapterText = $('.reading-content').html();
chapterText = chapterText.replace(/(?<=[[])[\n](?=[h])/g, '');
const chapter = {
sourceId: 21,
@@ -153,11 +130,11 @@ const searchNovels = async searchTerm => {
const result = await fetch(url);
const body = await result.text();
$ = cheerio.load(body);
const $ = cheerio.load(body);
let novels = [];
$('.c-tabs-item__content').each(function (result) {
$('.c-tabs-item__content').each(function () {
const novelName = $(this).find('.h4 > a').text();
const novelCover = $(this).find('img').attr('src');
@@ -23,7 +23,6 @@ const getPath = extensionId => {
63: {novels: 'novel', novel: 'novel', chapter: 'novel'},
75: {novels: 'series', novel: 'series', chapter: 'series'},
80: {novels: 'manga', novel: 'manga', chapter: 'manga'},
21: {novels: 'novellist', novel: 'series', chapter: 'series'},
};
return (
@@ -35,12 +34,7 @@ const getPath = extensionId => {
);
};
export const WoopReadScraper = new MadaraScraper(
21,
'https://woopread.com/',
'WoopRead',
getPath(21),
);
export const SkyNovelScraper = new MadaraScraper(
38,
+1 -1
View File
@@ -54,7 +54,6 @@ import {
SleepyTranslationsScraper,
WBNovelScraper,
WebNovelLoverScraper,
WoopReadScraper,
WuxiaWorldDotSiteScraper,
ZinnNovelScraper,
} from './multisrc/madara/MadaraGenerator';
@@ -82,6 +81,7 @@ import RainOfSnowScraper from './en/rainofsnow';
import ReaperScansBrScraper from './br/ReaperScansBr';
import ArthurScansScraper from './br/ArthurScans';
import IdMtlNovelScraper from './id/idmtlnovel';
import WoopReadScraper from './en/woopread';
export const getSource = sourceId => {
const scrapers = {