Update lastest chapter logic (#853)
* update lastestchapter logic * update version
This commit is contained in:
+15
-26
@@ -16,7 +16,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
icon = 'src/en/ranobes/icon.png';
|
||||
site = 'https://ranobes.top';
|
||||
filters?: Filters | undefined;
|
||||
version = '1.0.0';
|
||||
version = '1.1.0';
|
||||
|
||||
async sleep(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
@@ -119,6 +119,17 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
novel.totalPages = Number(data.pages_count);
|
||||
novel.chapters = this.parseChapters(data);
|
||||
|
||||
const latestChapterUrl = data.chapters[0].link;
|
||||
const latestChapterName = data.chapters[0].title;
|
||||
const latestChapterDate = data.chapters[0].date;
|
||||
|
||||
novel.latestChapter = latestChapterUrl
|
||||
? {
|
||||
path: latestChapterUrl.replace(this.site, ''),
|
||||
name: latestChapterName,
|
||||
releaseTime: new Date(latestChapterDate).toISOString(),
|
||||
}
|
||||
: undefined;
|
||||
return novel;
|
||||
}
|
||||
|
||||
@@ -126,35 +137,13 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
const pagePath = novelPath.split('-')[0];
|
||||
const firstUrl = this.site + '/chapters' + pagePath.replace('novels/', '');
|
||||
const pageUrl = firstUrl + '/page/' + page;
|
||||
|
||||
const body = await fetchApi(firstUrl).then(r => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
let json = loadedCheerio('#dle-content main').next().html()!;
|
||||
let data = JSON.parse(json.replace('window.__DATA__ =', ''));
|
||||
|
||||
const latestChapterUrl = data.chapters[0].link;
|
||||
const latestChapterName = data.chapters[0].title;
|
||||
const latestChapterDate = data.chapters[0].date;
|
||||
|
||||
const latestChapter: Plugin.ChapterItem | undefined = latestChapterUrl
|
||||
? {
|
||||
path: latestChapterUrl.replace(this.site, ''),
|
||||
name: latestChapterName,
|
||||
releaseTime: new Date(latestChapterDate).toISOString(),
|
||||
}
|
||||
: undefined;
|
||||
|
||||
await this.sleep(1000);
|
||||
|
||||
const pageBody = await fetchApi(pageUrl).then(r => r.text());
|
||||
loadedCheerio = parseHTML(pageBody);
|
||||
json = loadedCheerio('#dle-content main').next().html()!;
|
||||
data = JSON.parse(json.replace('window.__DATA__ =', ''));
|
||||
const loadedCheerio = parseHTML(pageBody);
|
||||
const json = loadedCheerio('#dle-content main').next().html()!;
|
||||
const data = JSON.parse(json.replace('window.__DATA__ =', ''));
|
||||
const chapters = this.parseChapters(data);
|
||||
return {
|
||||
chapters,
|
||||
latestChapter,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class TuNovelaLigera implements Plugin.PagePlugin {
|
||||
name = 'TuNovelaLigera';
|
||||
icon = 'src/es/tunovelaligera/icon.png';
|
||||
site = 'https://tunovelaligera.com';
|
||||
version = '1.0.0';
|
||||
version = '1.1.0';
|
||||
|
||||
async sleep(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
@@ -122,17 +122,6 @@ class TuNovelaLigera implements Plugin.PagePlugin {
|
||||
novel.summary = loadedCheerio('div.summary__content > p').text().trim();
|
||||
|
||||
novel.chapters = this.parseChapters(loadedCheerio);
|
||||
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
|
||||
const novelUrl = this.site + novelPath;
|
||||
const pageUrl = this.site + novelPath + '?lcp_page0=' + page;
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
const latestChapterEle = loadedCheerio('#lcp_instance_0 li').first();
|
||||
const latestChapterUrl = loadedCheerio(latestChapterEle)
|
||||
.find('a')
|
||||
@@ -142,18 +131,22 @@ class TuNovelaLigera implements Plugin.PagePlugin {
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
const latestChapter: Plugin.ChapterItem | undefined = latestChapterUrl
|
||||
novel.latestChapter = latestChapterUrl
|
||||
? {
|
||||
path: latestChapterUrl.replace(this.site, ''),
|
||||
name: latestChapterName,
|
||||
}
|
||||
: undefined;
|
||||
await this.sleep(1000);
|
||||
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
|
||||
const pageUrl = this.site + novelPath + '?lcp_page0=' + page;
|
||||
const pageText = await fetchApi(pageUrl).then(res => res.text());
|
||||
const chapters = this.parseChapters(parseHTML(pageText));
|
||||
return {
|
||||
chapters,
|
||||
latestChapter,
|
||||
};
|
||||
}
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user