[go: up one dir, main page]

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

fix(ReadWN): Implemented better chapter assumption #622

Merged
merged 1 commit into from
May 8, 2023
Merged
Changes from all commits
Commits
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
30 changes: 27 additions & 3 deletions src/sources/multisrc/readwn/ReadwnScraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,38 @@ class ReadwnScraper {

let novelChapters = [];

const novelId = novelUrl.replace('.html', '');
const novelId = novelUrl.replace('.html', '').replace(baseUrl, '');

const latestChapterNo = loadedCheerio('.header-stats')
.find('span > strong')
.first()
.text()
.trim();

for (let i = 1; i <= latestChapterNo; i++) {
let lastChapterNo = 1;
loadedCheerio('.chapter-list li').each(function () {
const chapterName = loadedCheerio(this)
.find('a .chapter-title')
.text()
.trim();

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

const releaseDate = loadedCheerio(this)
.find('a .chapter-update')
.text()
.trim();

lastChapterNo = loadedCheerio(this).find('a .chapter-no').text().trim();

const chapter = { chapterName, releaseDate, chapterUrl };

novelChapters.push(chapter);
});

// Itterate once more before loop to finish off
lastChapterNo++;
for (let i = lastChapterNo; i <= latestChapterNo; i++) {
const chapterName = `Chapter ${i}`;
const chapterUrl = `${novelId}_${i}.html`;
const releaseDate = null;
Expand All @@ -112,7 +135,8 @@ class ReadwnScraper {
}

async parseChapter(novelUrl, chapterUrl) {
const url = chapterUrl;
const baseUrl = this.baseUrl;
const url = baseUrl + chapterUrl;
const sourceId = this.sourceId;

const result = await fetch(url);
Expand Down