Skip to content

Commit 4c00b2b

Browse files
authored
fix(source): Arnovel (#671)
* fix arnovel * update 1stkissnovel url * fix images 1stkissnovel * QoL fixes for Agitoon and Pawread * Partial fix for sakuranovel/indowebnovel chapnames * Experimental lnp and pawread array * I know how commas work * fix inoveltranslation actual * startCase * fix bug
1 parent 414ca51 commit 4c00b2b

File tree

10 files changed

+88
-96
lines changed

10 files changed

+88
-96
lines changed

src/sources/en/lightnovelpub.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,43 +53,28 @@ const parseNovelAndChapters = async novelUrl => {
5353
sourceName: 'LightNovelPub',
5454
};
5555

56-
novel.novelName = loadedCheerio('h1.novel-title')
57-
.text()
58-
.replace(/[\t\n]/g, '')
59-
.trim();
56+
novel.novelName = loadedCheerio('h1.novel-title').text().trim();
6057

6158
novel.novelCover = loadedCheerio('figure.cover > img').attr('data-src');
6259

63-
novel.genre = '';
60+
novel.genre = loadedCheerio('.categories li')
61+
.find('a')
62+
.map((i, el) => loadedCheerio(el).text())
63+
.toArray()
64+
.join(',');
6465

65-
loadedCheerio('div.categories > ul > li').each(function () {
66-
novel.genre +=
67-
loadedCheerio(this)
68-
.text()
69-
.replace(/[\t\n]/g, '') + ',';
70-
});
71-
72-
loadedCheerio('div.header-stats > span').each(function () {
73-
if (loadedCheerio(this).find('small').text() === 'Status') {
74-
novel.status = loadedCheerio(this).find('strong').text();
75-
}
76-
});
77-
78-
novel.genre = novel.genre.slice(0, -1);
66+
novel.status = loadedCheerio('small:contains("Status")').prev().text().trim();
7967

8068
novel.author = loadedCheerio('.author > a > span').text();
8169

70+
loadedCheerio('.expand').remove();
8271
novel.summary = loadedCheerio('.summary > .content').text().trim();
8372

8473
const delay = ms => new Promise(res => setTimeout(res, ms));
8574

8675
let lastPage = 1;
8776

88-
lastPage = loadedCheerio(
89-
'#novel > header > div.header-body.container > div.novel-info > div.header-stats > span:nth-child(1) > strong',
90-
)
91-
.text()
92-
?.trim();
77+
lastPage = loadedCheerio('small:contains("Chapters")').prev().text().trim();
9378

9479
lastPage = Math.ceil(lastPage / 100);
9580

src/sources/en/novelhall.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,16 @@ const parseNovelAndChapters = async novelUrl => {
5656
.text()
5757
?.replace('back<<', '');
5858

59-
novel.author = loadedCheerio('span.blue')
60-
.first()
59+
loadedCheerio('p[style="display: none;"]').remove();
60+
novel.author = loadedCheerio('span.blue:contains("Author")')
6161
.text()
62-
.replace('Author:', '');
62+
.replace(/Author|\n+\t+/g, '');
6363

6464
novel.genre = loadedCheerio('a.red').text();
6565

6666
novel.artist = null;
6767

68-
novel.status = loadedCheerio('span.blue')
69-
.first()
70-
.next()
68+
novel.status = loadedCheerio('span.blue:contains("Status")')
7169
.text()
7270
.replace('Status:', '');
7371

src/sources/en/novelupdates.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,15 @@ const parseChapter = async (novelUrl, chapterUrl) => {
258258
} else if (isLightNovelsTls) {
259259
chapterText = loadedCheerio('.text_story').html();
260260
} else if (isiNovelTranslation) {
261-
chapterText = loadedCheerio('.chakra-skeleton').html();
261+
const link = 'https://api.' + result.url.slice(8);
262+
const json = await fetchApi({
263+
url: link,
264+
sourceId,
265+
}).then(r => r.json());
266+
chapterText =
267+
json.content.replace(/\n/g, '<br>') +
268+
'<br><hr><br>TL Notes:<br>' +
269+
json.notes.replace(/\n/g, '<br>');
262270
} else if (isWordPress) {
263271
/**
264272
* Remove wordpress bloat tags

src/sources/en/pawread.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,28 @@ const parseNovelAndChapters = async novelUrl => {
4747
.attr('style')
4848
.replace(/.*\((.*?)\)/g, '$1');
4949

50-
novel.author = loadedCheerio(
51-
'#views_info > div:nth-child(4) > span:nth-child(2)',
52-
)
50+
novel.author = loadedCheerio('#views_info > div:last > span:last')
5351
.text()
54-
.replace(/(Author: )/g, '');
52+
.replace('Author: ', '');
5553

5654
novel.status = loadedCheerio('.label').text().trim();
5755

58-
novel.genre = loadedCheerio('div.mt20:nth-child(4)')
59-
.text()
60-
.trim()
61-
.replace(/\s/g, ',');
56+
novel.genre = loadedCheerio('.col-md-9 .mt20')
57+
.find('a')
58+
.map((i, el) => loadedCheerio(el).text())
59+
.toArray()
60+
.join(',');
6261

6362
novel.summary = loadedCheerio('#simple-des').text().trim();
6463

6564
let chapters = [];
6665

67-
loadedCheerio('div.filtr-item').each(function () {
66+
loadedCheerio('.item-box').each(function () {
6867
const chapterName = loadedCheerio(this).find('.c_title').text();
69-
const releaseDate = loadedCheerio(this)
70-
.find('.c_title')
71-
.next()
72-
.next()
73-
.text();
68+
const releaseDate = loadedCheerio(this).find('span:last').text();
7469
const chapterUrl =
7570
novelUrl +
7671
loadedCheerio(this)
77-
.find('.item-box')
7872
.attr('onclick')
7973
.replace(/.*'(.*)'.*/g, '$1') +
8074
'.html';
@@ -95,9 +89,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
9589

9690
let loadedCheerio = cheerio.load(body);
9791

98-
const chapterName = loadedCheerio(
99-
'div.panel:nth-child(2) > div > div > h3',
100-
).text();
92+
const chapterName = loadedCheerio('.chapter-content h3').text();
93+
94+
const steal = ['bit.ly', 'tinyurl', 'pawread'];
95+
steal.map(tag => loadedCheerio(`p:icontains(${tag})`).remove());
10196
const chapterText = loadedCheerio('#chapter_item').html();
10297

10398
const chapter = {

src/sources/id/indowebnovel.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as cheerio from 'cheerio';
22
import { fetchHtml } from '@utils/fetch/fetch';
3+
import { startCase } from 'lodash-es';
34

45
const sourceId = 87;
56
const sourceName = 'IndoWebNovel';
@@ -50,7 +51,7 @@ const parseNovelAndChapters = async novelUrl => {
5051
novelUrl,
5152
};
5253

53-
novel.novelName = loadedCheerio('.series-title h2').text().trim();
54+
novel.novelName = startCase(loadedCheerio('.series-title h2').text().trim());
5455

5556
novel.novelCover = loadedCheerio('.series-thumb img').attr('src');
5657

@@ -78,22 +79,18 @@ const parseNovelAndChapters = async novelUrl => {
7879

7980
let chapters = [];
8081

81-
loadedCheerio('.series-chapterlist li').each(function () {
82-
const chapterName = loadedCheerio(this)
83-
.find('a span')
84-
.first()
85-
.text()
86-
.replace(/.*?(Chapter.|[0-9])/g, '$1')
87-
.replace(/Bahasa Indonesia/g, '')
88-
.replace(/\s+/g, ' ')
89-
.trim();
90-
91-
const releaseDate = loadedCheerio(this)
92-
.find('a span')
93-
.first()
94-
.next()
95-
.text();
96-
const chapterUrl = loadedCheerio(this).find('a').attr('href');
82+
loadedCheerio('.series-chapterlist li a').each(function () {
83+
let titles = startCase(
84+
loadedCheerio(this)
85+
.attr('title')
86+
.replace(/Bahasa Indonesia/g, '')
87+
.replace(/\s\s+/g, ' ')
88+
.trim(),
89+
);
90+
91+
const chapterName = titles.replace(`${novel.novelName}`, '');
92+
const releaseDate = loadedCheerio(this).find('span:last').text();
93+
const chapterUrl = loadedCheerio(this).attr('href');
9794

9895
chapters.push({ chapterName, releaseDate, chapterUrl });
9996
});

src/sources/id/sakuranovel.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { fetchHtml } from '@utils/fetch/fetch';
22
import * as cheerio from 'cheerio';
3+
import { startCase } from 'lodash-es';
34

45
const sourceId = 103;
56
const sourceName = 'SakuraNovel';
@@ -45,7 +46,7 @@ const parseNovelAndChapters = async novelUrl => {
4546
novelUrl,
4647
};
4748

48-
novel.novelName = loadedCheerio('.series-title h2').text().trim();
49+
novel.novelName = startCase(loadedCheerio('.series-title h2').text().trim());
4950

5051
novel.novelCover = loadedCheerio('.series-thumb img').attr('src');
5152

@@ -73,22 +74,18 @@ const parseNovelAndChapters = async novelUrl => {
7374

7475
let chapters = [];
7576

76-
loadedCheerio('.series-chapterlist li').each(function () {
77-
const chapterName = loadedCheerio(this)
78-
.find('a span')
79-
.first()
80-
.text()
81-
.replace(/.*?(Chapter.|[0-9])/g, '$1')
82-
.replace(/Bahasa Indonesia/g, '')
83-
.replace(/\s+/g, ' ')
84-
.trim();
85-
86-
const releaseDate = loadedCheerio(this)
87-
.find('a span')
88-
.first()
89-
.next()
90-
.text();
91-
const chapterUrl = loadedCheerio(this).find('a').attr('href');
77+
loadedCheerio('.series-chapterlist li a').each(function () {
78+
let titles = startCase(
79+
loadedCheerio(this)
80+
.attr('title')
81+
.replace(/Bahasa Indonesia/g, '')
82+
.replace(/\s\s+/g, ' ')
83+
.trim(),
84+
);
85+
86+
const chapterName = titles.replace(`${novel.novelName}`, '');
87+
const releaseDate = loadedCheerio(this).find('span:last').text();
88+
const chapterUrl = loadedCheerio(this).attr('href');
9289

9390
chapters.push({ chapterName, releaseDate, chapterUrl });
9491
});

src/sources/kr/Agitoon.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,10 @@ const parseChapter = async (novelUrl, chapterUrl) => {
102102
const loadedCheerio = cheerio.load(body);
103103

104104
const title = loadedCheerio('div > div.col-12 > h2').text();
105-
const contentTag = loadedCheerio('#id_wr_content > p');
106-
107-
let content = '';
108-
contentTag.each((_, element) => {
109-
content += loadedCheerio(element).text();
110-
content += '<br />';
111-
});
105+
let chapterText = loadedCheerio('#id_wr_content').html();
112106

113107
// gets rid of the popup thingy
114-
content = content.replace(
108+
chapterText = chapterText.replace(
115109
'팝업메뉴는 빈공간을 더치하거나 스크룰시 사라집니다',
116110
'',
117111
);
@@ -121,7 +115,7 @@ const parseChapter = async (novelUrl, chapterUrl) => {
121115
novelUrl,
122116
chapterUrl,
123117
chapterName: title,
124-
chapterText: content,
118+
chapterText,
125119
};
126120

127121
return chapter;

src/sources/multisrc/madara/MadaraGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const FreeNovelMeScraper = new MadaraScraper(
5353

5454
export const FirstKissNovelScraper = new MadaraScraper(
5555
46,
56-
'https://1stkissnovel.love/',
56+
'https://1stkissnovel.org/',
5757
'FirstKissNovel',
5858
{ 'useNewChapterEndpoint': true },
5959
);

src/sources/multisrc/madara/MadaraScraper.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ class MadaraScraper {
4444
.attr('href')
4545
.split('/')[4];
4646

47+
if (sourceId === 59) {
48+
novelUrl = loadedCheerio(this)
49+
.find('.post-title')
50+
.find('a')
51+
.attr('href')
52+
.split('/')[5];
53+
}
54+
4755
const novel = {
4856
sourceId,
4957
novelName,
@@ -79,11 +87,12 @@ class MadaraScraper {
7987
novel.novelName = loadedCheerio('.post-title h1').text().trim();
8088

8189
novel.novelCover =
90+
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
8291
loadedCheerio('.summary_image > a > img').attr('data-src') ||
8392
loadedCheerio('.summary_image > a > img').attr('src') ||
8493
defaultCoverUri;
8594

86-
loadedCheerio('.post-content_item', '.post-content').each(function () {
95+
loadedCheerio('.post-content_item, .post-content').each(function () {
8796
const detailName = loadedCheerio(this).find('h5').text().trim();
8897
const detail = loadedCheerio(this).find('.summary-content').text().trim();
8998

@@ -94,6 +103,7 @@ class MadaraScraper {
94103
break;
95104
case 'Author(s)':
96105
case 'المؤلف':
106+
case 'المؤلف (ين)':
97107
novel.author = detail;
98108
break;
99109
case 'Status':
@@ -106,7 +116,7 @@ class MadaraScraper {
106116
}
107117
});
108118

109-
loadedCheerio('div.summary__content .code-block').remove();
119+
loadedCheerio('div.summary__content .code-block,script').remove();
110120
novel.summary = loadedCheerio('div.summary__content').text().trim();
111121

112122
let novelChapters = [];
@@ -237,6 +247,14 @@ class MadaraScraper {
237247
.attr('href')
238248
.split('/')[4];
239249

250+
if (sourceId === 59) {
251+
novelUrl = loadedCheerio(this)
252+
.find('.post-title')
253+
.find('a')
254+
.attr('href')
255+
.split('/')[5];
256+
}
257+
240258
const novel = {
241259
sourceId,
242260
novelName,

src/sources/multisrc/madara/MadaraSources.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
{
5050
"sourceId": 46,
51-
"baseUrl": "https://1stkissnovel.love/",
51+
"baseUrl": "https://1stkissnovel.org/",
5252
"sourceName": "FirstKissNovel",
5353
"options": {
5454
"useNewChapterEndpoint": true

0 commit comments

Comments
 (0)