Migrate Japanese and Chinese plugins (#838)
* add Syosetu * add 69shu * add 69xinshu * add linovelib * clean up
This commit is contained in:
@@ -39,14 +39,12 @@ class Shu69 implements Plugin.PluginBase {
|
||||
|
||||
const novelName = loadedCheerio(el).find('h4.name').text().trim();
|
||||
const novelCover = loadedCheerio(el).find('a.cover > img').attr('src');
|
||||
const novelUrl = this.site + url;
|
||||
|
||||
if (!url) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
path: url,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
@@ -55,8 +53,8 @@ class Shu69 implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const body = await fetchText(url);
|
||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||
@@ -64,12 +62,11 @@ class Shu69 implements Plugin.PluginBase {
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url,
|
||||
path: novelPath,
|
||||
chapters: [],
|
||||
name: loadedCheerio('h1').text().trim()
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('h1').text().trim();
|
||||
|
||||
novel.cover = loadedCheerio('div.cover > img').attr('src');
|
||||
|
||||
novel.summary = loadedCheerio('#bookIntro').text().trim();
|
||||
@@ -95,23 +92,25 @@ class Shu69 implements Plugin.PluginBase {
|
||||
const chaptersLoadedCheerio = parseHTML(chaptersBody);
|
||||
|
||||
chaptersLoadedCheerio('dd').each((i, el) => {
|
||||
const chapterUrl = this.site + chaptersLoadedCheerio(el).find('a').attr('href');
|
||||
const chapterUrl = chaptersLoadedCheerio(el).find('a').attr('href');
|
||||
const chapterName = chaptersLoadedCheerio(el).find('a').text().trim();
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
url: chapterUrl,
|
||||
});
|
||||
if(chapterUrl){
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
path: chapterUrl,
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
loadedCheerio('div.panel.hidden-xs > dl.panel-chapterlist:nth-child(2) > dd').each((i, el) => {
|
||||
const chapterUrl = this.site + loadedCheerio(el).find('a').attr('href');
|
||||
const chapterUrl = loadedCheerio(el).find('a').attr('href');
|
||||
const chapterName = loadedCheerio(el).find('a').text().trim();
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
url: chapterUrl,
|
||||
});
|
||||
if(chapterUrl){
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
path: chapterUrl,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,8 +119,8 @@ class Shu69 implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchText(chapterUrl);
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const body = await fetchText(this.site + chapterPath);
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -162,14 +161,13 @@ class Shu69 implements Plugin.PluginBase {
|
||||
|
||||
const novelName = loadedCheerio(el).find('h4.name').text().trim();
|
||||
const novelCover = loadedCheerio(el).find('a.cover > img').attr('src');
|
||||
const novelUrl = this.site + url;
|
||||
|
||||
if (!url) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
path: url,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
@@ -9,7 +9,7 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
id = "69xinshu";
|
||||
name = "69书吧";
|
||||
icon = "src/cn/69xinshu/icon.png";
|
||||
site = "https://www.69xinshu.com";
|
||||
site = "https://www.69shu.pro";
|
||||
version = "0.1.1";
|
||||
|
||||
async popularNovels(
|
||||
@@ -31,19 +31,19 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
const novelsList = pageNo === 1 ? loadedCheerio('div.newbox > ul > li') : loadedCheerio('li');
|
||||
novelsList.each(function () {
|
||||
const novelUrl = loadedCheerio(this).find('li > div > h3 > a:nth-child(2)').attr('href');
|
||||
novelsList.each((i, e) => {
|
||||
const novelUrl = loadedCheerio(e).find('li > div > h3 > a:nth-child(2)').attr('href');
|
||||
|
||||
if (novelUrl) {
|
||||
const novelName = loadedCheerio(this).find('li > div > h3 > a:nth-child(2)').text();
|
||||
const novelCover = loadedCheerio(this)
|
||||
const novelName = loadedCheerio(e).find('li > div > h3 > a:nth-child(2)').text();
|
||||
const novelCover = loadedCheerio(e)
|
||||
.find('li > a > img')
|
||||
.attr('data-src');
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
@@ -53,8 +53,8 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const body = await fetchText(url, {}, 'gbk');
|
||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||
@@ -62,12 +62,11 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url,
|
||||
path: novelPath,
|
||||
chapters: [],
|
||||
name: loadedCheerio('h1 > a').text()
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('h1 > a').text();
|
||||
|
||||
novel.cover = loadedCheerio('div.bookimg2 > img').attr(
|
||||
'src',
|
||||
);
|
||||
@@ -99,15 +98,15 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
|
||||
const chaptersLoadedCheerio = parseHTML(chaptersBody);
|
||||
|
||||
chaptersLoadedCheerio('li').each(function () {
|
||||
const chapterUrl = chaptersLoadedCheerio(this).find('a').attr('href');
|
||||
chaptersLoadedCheerio('li').each((i, e) => {
|
||||
const chapterUrl = chaptersLoadedCheerio(e).find('a').attr('href');
|
||||
|
||||
if (chapterUrl?.startsWith("https://")) {
|
||||
const chapterName = chaptersLoadedCheerio(this).find('a').text().trim();
|
||||
const chapterName = chaptersLoadedCheerio(e).find('a').text().trim();
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
url: chapterUrl,
|
||||
path: chapterUrl.replace(this.site, ''),
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -118,8 +117,8 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchText(chapterUrl, {}, 'gbk');
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const body = await fetchText(this.site + chapterPath, {}, 'gbk');
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
@@ -154,14 +153,14 @@ class XinShu69 implements Plugin.PluginBase {
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
loadedCheerio('div.newbox > ul > li').each(function () {
|
||||
const novelUrl = loadedCheerio(this).find('a').attr('href')!;
|
||||
const novelName = loadedCheerio(this).find('div.newnav > h3').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
loadedCheerio('div.newbox > ul > li').each((i, e) => {
|
||||
const novelUrl = loadedCheerio(e).find('a').attr('href')!;
|
||||
const novelName = loadedCheerio(e).find('div.newnav > h3').text();
|
||||
const novelCover = loadedCheerio(e).find('img').attr('data-src');
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
path: novelUrl.replace(this.site, ''),
|
||||
cover: novelCover,
|
||||
};
|
||||
|
||||
@@ -35,14 +35,12 @@ class Linovelib implements Plugin.PluginBase {
|
||||
const novelCover = loadedCheerio(el)
|
||||
.find("div.book-cover > img")
|
||||
.attr("data-src");
|
||||
const novelUrl = this.site + url;
|
||||
|
||||
if (!url) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
path: url,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
@@ -51,8 +49,8 @@ class Linovelib implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const url = novelUrl;
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const url = this.site + novelPath;
|
||||
|
||||
const body = await fetchText(url);
|
||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||
@@ -60,12 +58,11 @@ class Linovelib implements Plugin.PluginBase {
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url,
|
||||
path: novelPath,
|
||||
chapters: [],
|
||||
name: loadedCheerio("#bookDetailWrapper .book-title").text()
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("#bookDetailWrapper .book-title").text();
|
||||
|
||||
novel.cover = loadedCheerio("#bookDetailWrapper img.book-cover").attr(
|
||||
"src"
|
||||
);
|
||||
@@ -118,7 +115,7 @@ class Linovelib implements Plugin.PluginBase {
|
||||
}
|
||||
}
|
||||
|
||||
const chapterUrl = `${this.site}/novel/${novelId}/${chapterId}.html`;
|
||||
const chapterUrl = `/novel/${novelId}/${chapterId}.html`;
|
||||
const chapterName =
|
||||
volumeName +
|
||||
" — " +
|
||||
@@ -130,7 +127,7 @@ class Linovelib implements Plugin.PluginBase {
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
path: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -139,7 +136,7 @@ class Linovelib implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
let chapterName,
|
||||
chapterText = "",
|
||||
hasNextPage,
|
||||
@@ -423,13 +420,13 @@ class Linovelib implements Plugin.PluginBase {
|
||||
return { pageCheerio, pageHasNextPage };
|
||||
};
|
||||
|
||||
let url = chapterUrl;
|
||||
let url = this.site + chapterPath;
|
||||
do {
|
||||
const page = await loadPage(url);
|
||||
hasNextPage = page.pageHasNextPage;
|
||||
if (hasNextPage === true) {
|
||||
pageNumber++;
|
||||
url = chapterUrl.replace(
|
||||
url = url.replace(
|
||||
/\.html/gi,
|
||||
`_${pageNumber}` + ".html"
|
||||
);
|
||||
@@ -516,13 +513,12 @@ class Linovelib implements Plugin.PluginBase {
|
||||
const novelCover = pageCheerio(el)
|
||||
.find("div.book-cover > img")
|
||||
.attr("data-src");
|
||||
const novelUrl = this.site + nUrl;
|
||||
|
||||
if (!nUrl) return;
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
path: nUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user