Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source Updates #807

Merged
merged 43 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
35ed8c0
dev woopread
K1ngfish3r Oct 11, 2023
5d61671
check if input breaks chapterText
K1ngfish3r Oct 11, 2023
b505ad3
AsuraLightNovel dev
K1ngfish3r Oct 11, 2023
07b9e19
add Titan.wf to novelupdates
K1ngfish3r Oct 12, 2023
eeb84d6
rough fix novelpub
K1ngfish3r Oct 13, 2023
7d0b1fb
remove userAgent check
K1ngfish3r Oct 13, 2023
c93e62e
i forgot one
K1ngfish3r Oct 13, 2023
a441dcf
lnmtl ChapterText fix
K1ngfish3r Oct 14, 2023
223b510
fix author, genre and status lnmtl
K1ngfish3r Oct 14, 2023
e723172
xperimental
K1ngfish3r Oct 15, 2023
0c42b38
grounded quotation marks lnmtl
K1ngfish3r Oct 15, 2023
b0c8547
fix woopread missing chapter
K1ngfish3r Oct 16, 2023
e198ec2
refactor wuxia.blog
K1ngfish3r Oct 16, 2023
a7e47c2
copypasta lightnovelpub
K1ngfish3r Oct 16, 2023
9d4e2bd
until stylesheets are added
K1ngfish3r Oct 16, 2023
df2a13a
remove console.log
K1ngfish3r Oct 16, 2023
c35a18c
Merge branch 'LNReader:main' into main
K1ngfish3r Oct 16, 2023
487bd69
revert armtl and wuxiablog search delete
K1ngfish3r Oct 18, 2023
8f6fab0
fix eslint check?
K1ngfish3r Oct 18, 2023
5af4b4b
fastnovel to novelbin
K1ngfish3r Oct 18, 2023
8b9a199
Blossom Translation Dev
K1ngfish3r Oct 26, 2023
14b1d8e
skynovel fix chapter spacing
K1ngfish3r Oct 29, 2023
f4892db
oops
K1ngfish3r Oct 29, 2023
1eded4d
linovelib fix?
K1ngfish3r Oct 29, 2023
b9f29e3
search fix linovelib
K1ngfish3r Oct 29, 2023
3e4e4eb
update dictionary linovelib
K1ngfish3r Oct 29, 2023
3f7926f
update dictionary 2: electric bugaloo
K1ngfish3r Oct 29, 2023
a936825
skillgg dict and multipage chapter + search fix
K1ngfish3r Oct 29, 2023
efcf49e
fix sakuranovel again
K1ngfish3r Nov 1, 2023
168f982
Merge branch 'LNReader:main' into main
K1ngfish3r Nov 2, 2023
c2d499e
The_Lazy_Guy Dev + TuNovelaLigera Dev
K1ngfish3r Nov 3, 2023
dce4f87
TuNovelaLigera, ch cleanup
K1ngfish3r Nov 3, 2023
4d19cb2
under review
K1ngfish3r Nov 12, 2023
1fd5e92
remove green dictionary
K1ngfish3r Nov 12, 2023
9c124e1
text()
K1ngfish3r Nov 12, 2023
670d2ec
add delay
K1ngfish3r Nov 12, 2023
ec6a93f
cleanup
K1ngfish3r Nov 13, 2023
b11626a
allnovelfull cleanup
K1ngfish3r Nov 16, 2023
e241715
update selector
K1ngfish3r Nov 18, 2023
b567c5c
update selectors SUPER
K1ngfish3r Nov 18, 2023
7bbbbbd
fix chapter name lightnovelpub
K1ngfish3r Nov 19, 2023
90d0caf
update dictionary 3: revenge of the dict
K1ngfish3r Nov 20, 2023
f18c23c
indowebnovel
K1ngfish3r Nov 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sources/en/lightnovelpub.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const parseNovelAndChapters = async novelUrl => {
const chaptersHtml = await fetchHtml({
url: chaptersUrl,
init: { headers },
sourceId,
});

loadedCheerio = cheerio.load(chaptersHtml);
Expand Down
71 changes: 37 additions & 34 deletions src/sources/en/lnmtl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as cheerio from 'cheerio';
import { showToast } from '../../hooks/showToast';
import { htmlToText } from '../helpers/htmlToText';

const baseUrl = 'https://lnmtl.com/';

Expand Down Expand Up @@ -56,23 +55,26 @@ const parseNovelAndChapters = async novelUrl => {

novel.novelName = loadedCheerio('.novel-name').text();

novel.novelCover = loadedCheerio('div.novel').find('img').attr('src');
novel.novelCover = loadedCheerio('.novel').find('img').attr('src');

novel.summary = loadedCheerio('div.description').text().trim();
novel.summary = loadedCheerio('.description').text().trim();

novel.author = loadedCheerio(
'main > div:nth-child(3) > div > div.col-lg-3.col-md-4 > div:nth-child(2) > div.panel-body > dl:nth-child(1) > dd > a > span',
).text();
loadedCheerio('.panel-body > dl').each(function () {
let detailName = loadedCheerio(this).find('dt').text().trim();
let detail = loadedCheerio(this).find('dd').text().trim();

novel.status = loadedCheerio(
'main > div:nth-child(3) > div > div.col-lg-3.col-md-4 > div:nth-child(2) > div.panel-body > dl:last-child > dd',
)
.text()
.trim();
switch (detailName) {
case 'Authors':
novel.author = detail;
break;
case 'Current status':
novel.status = detail;
break;
}
});

novel.genre = loadedCheerio(
'main > div.container > div > div.col-lg-3.col-md-4 > div:nth-child(4) > div.panel-body > ul',
)
novel.genre = loadedCheerio('.panel-heading:contains(" Genres ")')
.next()
.text()
.trim()
.replace(/\s\s/g, ',');
Expand Down Expand Up @@ -128,17 +130,15 @@ const parseChapter = async (novelUrl, chapterUrl) => {

let chapterName = loadedCheerio('h3 > span.chapter-title').text().trim();

loadedCheerio('.original').remove();
loadedCheerio('.original, script').remove();
loadedCheerio('sentence.translated').wrap('<p></p>');

let chapterText = loadedCheerio('.chapter-body').html();
let chapterText = loadedCheerio('.chapter-body').html().replace(/„/g, '“');

if (!chapterText) {
chapterText = loadedCheerio('.alert.alert-warning').text();
}

chapterText =
chapterName + '\n\n' + htmlToText(chapterText, { removeLineBreaks: false });

const chapter = {
sourceId: 37,
novelUrl,
Expand All @@ -151,32 +151,35 @@ const parseChapter = async (novelUrl, chapterUrl) => {
};

const searchNovels = async searchTerm => {
const url = 'https://lnmtl.com/term';

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

const loadedCheerio = cheerio.load(body);

let novels = loadedCheerio('footer')
const list = loadedCheerio('footer')
.next()
.next()
.html()
.match(/local: \[(.*?)\]/)[0]
.replace('local: ', '');
.match(/prefetch: '\/(.*json)/)[1];

novels = JSON.parse(novels);
const search = await fetch(`${baseUrl}${list}`);
const data = await search.json();

novels = novels.filter(novel =>
novel.name.toLowerCase().includes(searchTerm.toLowerCase()),
let nov = data.filter(res =>
res.name.toLowerCase().includes(searchTerm.toLowerCase()),
);

novels = novels.map(novel => ({
sourceId: 37,
novelName: novel.name,
novelUrl: novel.slug,
novelCover: novel.image,
}));
const novels = [];

nov.map(res => {
const novelName = res.name;
const novelUrl = res.slug;
const novelCover = res.image;

const novel = { sourceId: 37, novelName, novelUrl, novelCover };

novels.push(novel);
});

return novels;
};
Expand Down
77 changes: 36 additions & 41 deletions src/sources/en/novelpub.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as cheerio from 'cheerio';
import { fetchHtml } from '@utils/fetch/fetch';
import { fetchApi, fetchHtml } from '@utils/fetch/fetch';

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

Expand All @@ -9,18 +9,12 @@ const sourceId = 94;
const headers = new Headers({
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
});

const popularNovels = async page => {
let url = baseUrl + 'browse/all/popular/all/' + page;

const body = await fetchHtml({
url,
sourceId,
init: { headers: { 'User-Agent': userAgent } },
});
const body = await fetchHtml({ url, sourceId });

const loadedCheerio = cheerio.load(body);

Expand All @@ -46,48 +40,39 @@ const popularNovels = async page => {
const parseNovelAndChapters = async novelUrl => {
const url = novelUrl;

const body = await fetchHtml({
url,
sourceId,
init: { headers: { 'User-Agent': userAgent } },
});
const body = await fetchHtml({ url, sourceId });

let loadedCheerio = cheerio.load(body);

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

novel.novelName = loadedCheerio('h1.novel-title').text().trim();

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

loadedCheerio('div.categories > ul > li').each(function () {
novel.genre +=
loadedCheerio(this)
.text()
.replace(/[\t\n]/g, '') + ',';
});
novel.genre = loadedCheerio('.categories li')
.find('a')
.map((i, el) => loadedCheerio(el).text())
.toArray()
.join(',');

loadedCheerio('div.header-stats > span').each(function () {
if (loadedCheerio(this).find('small').text() === 'Status') {
novel.status = loadedCheerio(this).find('strong').text();
}
});

novel.genre = novel.genre.slice(0, -1);
novel.status = loadedCheerio('small:contains("Status")').prev().text().trim();

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

loadedCheerio('.expand').remove();
novel.summary = loadedCheerio('.summary > .content').text().trim();

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

let lastPage = 1;

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

lastPage = Math.ceil(lastPage / 100);

Expand All @@ -97,8 +82,11 @@ const parseNovelAndChapters = async novelUrl => {
for (let i = 1; i <= lastPage; i++) {
const chaptersUrl = `${novelUrl}/chapters/page-${i}`;

const chaptersRequest = await fetch(chaptersUrl, { headers });
const chaptersHtml = await chaptersRequest.text();
const chaptersHtml = await fetchHtml({
url: chaptersUrl,
init: { headers },
sourceId,
});

loadedCheerio = cheerio.load(chaptersHtml);

Expand Down Expand Up @@ -133,11 +121,7 @@ const parseNovelAndChapters = async novelUrl => {
const parseChapter = async (novelUrl, chapterUrl) => {
const url = chapterUrl;

const body = await fetchHtml({
url,
sourceId,
init: { headers: { 'User-Agent': userAgent } },
});
const body = await fetchHtml({ url, sourceId });

const loadedCheerio = cheerio.load(body);

Expand All @@ -150,12 +134,23 @@ const parseChapter = async (novelUrl, chapterUrl) => {
};

const searchNovels = async searchTerm => {
const url = `${baseUrl}lnwsearchlive?inputContent=${searchTerm}`;
const url = `${baseUrl}lnsearchlive`;
const link = `${baseUrl}search`;
const response = await fetchApi({ url: link, sourceId }).then(r => r.text());
const token = cheerio.load(response);
let verifytoken = token('#novelSearchForm > input').attr('value');

let formData = new FormData();
formData.append('inputContent', searchTerm);

const body = await fetchHtml({
url,
init: {
method: 'POST',
headers: { 'LNRequestVerifyToken': verifytoken },
body: formData,
},
sourceId,
init: { headers: { 'User-Agent': userAgent } },
});

let loadedCheerio = cheerio.load(body);
Expand Down
4 changes: 2 additions & 2 deletions src/sources/en/novelupdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const parseChapter = async (novelUrl, chapterUrl) => {
if (isWuxiaWorld) {
chapterText = loadedCheerio('#chapter-content').html();
} else if (isRainOfSnow) {
chapterText = loadedCheerio('div.content').html();
chapterText = loadedCheerio('.content').html();
} else if (isTumblr) {
chapterText = loadedCheerio('.post').html();
} else if (isBlogspot) {
Expand All @@ -250,7 +250,7 @@ const parseChapter = async (novelUrl, chapterUrl) => {
} else if (isHostedNovel) {
chapterText = loadedCheerio('.chapter').html();
} else if (isScribbleHub) {
chapterText = loadedCheerio('div.chp_raw').html();
chapterText = loadedCheerio('.chp_raw').html();
} else if (isWattpad) {
chapterText = loadedCheerio('.container pre').html();
} else if (isTravisTranslation) {
Expand Down
14 changes: 7 additions & 7 deletions src/sources/en/woopread.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ const parseNovelAndChapters = async novelUrl => {
};

const parseChapter = async (novelUrl, chapterUrl) => {
const url = `${baseUrl}series/${novelUrl}/${chapterUrl}/`;
const url = `${baseUrl}series/${novelUrl}${chapterUrl}`;

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

const loadedCheerio = cheerio.load(body);

const chapterName = loadedCheerio('h1#chapter-heading').text();

const chapterName = loadedCheerio('.reading-content b:first').text();
loadedCheerio('input, .reading-content b:first').remove();
let chapterText = loadedCheerio('.reading-content').html();

const chapter = {
Expand All @@ -144,11 +144,11 @@ const searchNovels = async searchTerm => {

let novels = [];

loadedCheerio('.c-tabs-item__content').each(function () {
const novelName = loadedCheerio(this).find('.h4 > a').text();
const novelCover = loadedCheerio(this).find('img').attr('src');
loadedCheerio('.tab-thumb').each(function () {
const novelName = loadedCheerio(this).find('a').attr('title');
const novelCover = loadedCheerio(this).find('img').attr('data-src');

let novelUrl = loadedCheerio(this).find('.h4 > a').attr('href');
let novelUrl = loadedCheerio(this).find('a').attr('href');
novelUrl = novelUrl.replace(`${baseUrl}series/`, '');

const novel = {
Expand Down
Loading
Loading