Fix RewayatAr (Closes LNReader/lnreader-sources#96)
This commit is contained in:
@@ -32,8 +32,6 @@ const popularNovels = async page => {
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
console.log(url);
|
||||
|
||||
return {totalPages, novels};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
import cheerio from 'react-native-cheerio';
|
||||
import {Status} from '../helpers/constants';
|
||||
|
||||
const sourceId = 54;
|
||||
const sourceName = 'RewayatAr';
|
||||
|
||||
const baseUrl = 'https://rewayat-ar.site/';
|
||||
|
||||
const popularNovels = async page => {
|
||||
const totalPages = 2;
|
||||
const url = baseUrl + 'novels/topview/page/' + page;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.update_item.list_category').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
sourceId,
|
||||
novelName,
|
||||
novelCover,
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return {totalPages, novels};
|
||||
};
|
||||
|
||||
const parseNovelAndChapters = async novelUrl => {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
sourceId,
|
||||
sourceName,
|
||||
url,
|
||||
novelUrl,
|
||||
novelName: '',
|
||||
novelCover: '',
|
||||
author: '',
|
||||
status: Status.UNKNOWN,
|
||||
genre: '',
|
||||
summary: '',
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.novelName = loadedCheerio('.truyen_info_right h1').text().trim();
|
||||
novel.novelCover = loadedCheerio('.info_image img').attr('src');
|
||||
novel.summary = loadedCheerio('#noidungm').text()?.trim();
|
||||
novel.author = loadedCheerio(
|
||||
'#main_body > div.cotgiua > div.truyen_info_wrapper > div.truyen_info > div.entry-header > div.truyen_if_wrap > ul > li:nth-child(2) > a',
|
||||
)
|
||||
.text()
|
||||
?.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
loadedCheerio('.chapter-list div.row').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('span:nth-child(2)')
|
||||
.text()
|
||||
.trim();
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
novelChapters.push({chapterName, releaseDate, chapterUrl});
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
const parseChapter = async (novelUrl, chapterUrl) => {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterName = loadedCheerio('h1.name_chapter').text();
|
||||
const chapterText = loadedCheerio('#vung_doc').html();
|
||||
|
||||
const chapter = {
|
||||
sourceId,
|
||||
novelUrl,
|
||||
chapterUrl,
|
||||
chapterName,
|
||||
chapterText,
|
||||
};
|
||||
|
||||
return chapter;
|
||||
};
|
||||
|
||||
const searchNovels = async searchTerm => {
|
||||
const url = `${baseUrl}search/${searchTerm}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.update_item.list_category').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
|
||||
const novel = {sourceId, novelName, novelCover, novelUrl};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
const RewayatArScraper = {
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
};
|
||||
|
||||
export default RewayatArScraper;
|
||||
@@ -5,9 +5,3 @@ export const KolNovelScraper = new WPMangaStreamScraper(
|
||||
'https://alightnovel.com/',
|
||||
'KolNovel',
|
||||
);
|
||||
|
||||
export const RewayatArScraper = new WPMangaStreamScraper(
|
||||
54,
|
||||
'https://rewayat-ar.site/',
|
||||
'RewayatAr',
|
||||
);
|
||||
|
||||
@@ -63,10 +63,7 @@ import WuxiaCityScraper from './en/wuxiacity';
|
||||
import NovelUpdatesScraper from './en/novelupdates';
|
||||
import RanobesScraper from './en/ranobes';
|
||||
import YushuboScraper from './ch/yushubo';
|
||||
import {
|
||||
KolNovelScraper,
|
||||
RewayatArScraper,
|
||||
} from './multisrc/wpmangastream/WPMangaStreamGenerator';
|
||||
import {KolNovelScraper} from './multisrc/wpmangastream/WPMangaStreamGenerator';
|
||||
import WLNUpdatesScraper from './en/wlnupdates';
|
||||
import ReaperScansScraper from './en/reaperscans';
|
||||
import ReadwnScraper from './en/readwn';
|
||||
@@ -89,6 +86,7 @@ import RiwayatScraper from './ar/riwayat';
|
||||
import NovelRinganScraper from './id/novelringan';
|
||||
import IndoWebNovelScraper from './id/indowebnovel';
|
||||
import ChireadsScraper from './fr/chireads';
|
||||
import RewayatArScraper from './ar/rewayatar';
|
||||
|
||||
export const getSource = sourceId => {
|
||||
const scrapers = {
|
||||
|
||||
Reference in New Issue
Block a user