Skip to content

Commit

Permalink
fix: Source Updates (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
K1ngfish3r authored May 6, 2023
1 parent 7221070 commit f0d0696
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 59 deletions.
91 changes: 35 additions & 56 deletions src/sources/en/novelhall.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,52 @@
import * as cheerio from 'cheerio';
import { fetchHtml } from '@utils/fetch/fetch';
import { defaultCoverUri } from '../helpers/constants';

const baseUrl = 'https://www.novelhall.com/';

const sourceId = 6;

const sourceName = 'NovelHall';

const popularNovels = async page => {
const url = baseUrl + 'completed-' + page + '.html';
const url = `${baseUrl}all2022-${page}.html`;

const result = await fetch(url);
const body = await result.text();
const body = await fetchHtml({ url, sourceId });

const loadedCheerio = cheerio.load(body);

let novels = [];

loadedCheerio('div.section3')
.find('tr')
.each(function () {
const novelName = loadedCheerio(this).find('.w70 > a').text();
const novelCover = defaultCoverUri;
const novelUrl = loadedCheerio(this)
.find('.w70 > a')
.attr('href')
.substring(1);

const novel = {
sourceId,
novelName,
novelCover,
novelUrl,
};
loadedCheerio('li.btm').each(function () {
const novelName = loadedCheerio(this).find('a').text();
const novelCover = defaultCoverUri;
const novelUrl =
baseUrl + loadedCheerio(this).find('a').attr('href').slice(1);

novels.push(novel);
});
const novel = {
sourceId,
novelName,
novelCover,
novelUrl,
};

novels.push(novel);
});

return { novels };
};

const parseNovelAndChapters = async novelUrl => {
const url = `${baseUrl}${novelUrl}/`;

const result = await fetch(url);
const body = await result.text();
const body = await fetchHtml({ url: novelUrl, sourceId });

const loadedCheerio = cheerio.load(body);

let novel = {};

novel.sourceId = 6;

novel.sourceName = 'NovelHall';
let loadedCheerio = cheerio.load(body);

novel.url = url;

novel.novelUrl = novelUrl;
let novel = {
sourceId,
sourceName,
url: novelUrl,
novelUrl,
};

novel.novelName = loadedCheerio('h1').text();

Expand Down Expand Up @@ -88,11 +80,7 @@ const parseNovelAndChapters = async novelUrl => {

let releaseDate = null;

let chapterUrl = loadedCheerio(this).find('a').attr('href');

if (chapterUrl) {
chapterUrl = chapterUrl.replace(`/${novelUrl}/`, '');
}
let chapterUrl = baseUrl + loadedCheerio(this).find('a').attr('href');

const chapter = {
chapterName,
Expand All @@ -109,12 +97,9 @@ const parseNovelAndChapters = async novelUrl => {
};

const parseChapter = async (novelUrl, chapterUrl) => {
const url = `${baseUrl}${novelUrl}/${chapterUrl}`;
const body = await fetchHtml({ url: chapterUrl, sourceId });

const result = await fetch(url);
const body = await result.text();

const loadedCheerio = cheerio.load(body);
let loadedCheerio = cheerio.load(body);

const chapterName = loadedCheerio('h1').text();
const chapterText = loadedCheerio('div.entry-content').html();
Expand All @@ -134,24 +119,18 @@ const searchNovels = async searchTerm => {

const url = `${searchUrl}${searchTerm}`;

const result = await fetch(url);
const body = await result.text();
const body = await fetchHtml({ url, sourceId });

const loadedCheerio = cheerio.load(body);

let novels = [];

loadedCheerio('tr').each(function () {
let novelName = loadedCheerio(this).find('td:nth-child(2)').text();
novelName = novelName.replace(/[\t\n]/g, '');

const novelName = loadedCheerio(this).find('td:nth-child(2) > a').text();
const novelCover = 'https://cdn.novelupdates.com/imgmid/noimagemid.jpg';

let novelUrl = loadedCheerio(this).find('td:nth-child(2) >').attr('href');
if (novelUrl) {
novelUrl = novelUrl.slice(1);
}

const novelUrl =
baseUrl +
loadedCheerio(this).find('td:nth-child(2) > a').attr('href').slice(1);
const novel = {
sourceId,
novelName,
Expand Down
5 changes: 3 additions & 2 deletions src/sources/en/pawread.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ const parseNovelAndChapters = async novelUrl => {
.next()
.text();
const chapterUrl =
baseUrl +
novelUrl +
loadedCheerio(this)
.find('.item-box')
.attr('onclick')
.replace(/.*?(novel.*html).*/g, '$1');
.replace(/.*'(.*)'.*/g, '$1') +
'.html';

chapters.push({ chapterName, releaseDate, chapterUrl });
});
Expand Down
2 changes: 1 addition & 1 deletion src/sources/id/sakuranovel.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const parseChapter = async (novelUrl, chapterUrl) => {
let loadedCheerio = cheerio.load(body);

const chapterName = loadedCheerio('.title-chapter').text();
const chapterText = loadedCheerio('.reader').html();
const chapterText = loadedCheerio('.readers').html();

const chapter = {
sourceId,
Expand Down

0 comments on commit f0d0696

Please sign in to comment.