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 novelName = loadedCheerio(el).find('h4.name').text().trim();
|
||||||
const novelCover = loadedCheerio(el).find('a.cover > img').attr('src');
|
const novelCover = loadedCheerio(el).find('a.cover > img').attr('src');
|
||||||
const novelUrl = this.site + url;
|
|
||||||
|
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
const novel = {
|
const novel = {
|
||||||
name: novelName,
|
name: novelName,
|
||||||
cover: novelCover,
|
cover: novelCover,
|
||||||
url: novelUrl,
|
path: url,
|
||||||
};
|
};
|
||||||
|
|
||||||
novels.push(novel);
|
novels.push(novel);
|
||||||
@@ -55,8 +53,8 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
return novels;
|
return novels;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||||
const url = novelUrl;
|
const url = this.site + novelPath;
|
||||||
|
|
||||||
const body = await fetchText(url);
|
const body = await fetchText(url);
|
||||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||||
@@ -64,12 +62,11 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
let loadedCheerio = parseHTML(body);
|
let loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
const novel: Plugin.SourceNovel = {
|
const novel: Plugin.SourceNovel = {
|
||||||
url,
|
path: novelPath,
|
||||||
chapters: [],
|
chapters: [],
|
||||||
|
name: loadedCheerio('h1').text().trim()
|
||||||
};
|
};
|
||||||
|
|
||||||
novel.name = loadedCheerio('h1').text().trim();
|
|
||||||
|
|
||||||
novel.cover = loadedCheerio('div.cover > img').attr('src');
|
novel.cover = loadedCheerio('div.cover > img').attr('src');
|
||||||
|
|
||||||
novel.summary = loadedCheerio('#bookIntro').text().trim();
|
novel.summary = loadedCheerio('#bookIntro').text().trim();
|
||||||
@@ -95,23 +92,25 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
const chaptersLoadedCheerio = parseHTML(chaptersBody);
|
const chaptersLoadedCheerio = parseHTML(chaptersBody);
|
||||||
|
|
||||||
chaptersLoadedCheerio('dd').each((i, el) => {
|
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();
|
const chapterName = chaptersLoadedCheerio(el).find('a').text().trim();
|
||||||
|
if(chapterUrl){
|
||||||
chapters.push({
|
chapters.push({
|
||||||
name: chapterName,
|
name: chapterName,
|
||||||
url: chapterUrl,
|
path: chapterUrl,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
loadedCheerio('div.panel.hidden-xs > dl.panel-chapterlist:nth-child(2) > dd').each((i, el) => {
|
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();
|
const chapterName = loadedCheerio(el).find('a').text().trim();
|
||||||
|
if(chapterUrl){
|
||||||
chapters.push({
|
chapters.push({
|
||||||
name: chapterName,
|
name: chapterName,
|
||||||
url: chapterUrl,
|
path: chapterUrl,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +119,8 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
return novel;
|
return novel;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseChapter(chapterUrl: string): Promise<string> {
|
async parseChapter(chapterPath: string): Promise<string> {
|
||||||
const body = await fetchText(chapterUrl);
|
const body = await fetchText(this.site + chapterPath);
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -162,14 +161,13 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
|
|
||||||
const novelName = loadedCheerio(el).find('h4.name').text().trim();
|
const novelName = loadedCheerio(el).find('h4.name').text().trim();
|
||||||
const novelCover = loadedCheerio(el).find('a.cover > img').attr('src');
|
const novelCover = loadedCheerio(el).find('a.cover > img').attr('src');
|
||||||
const novelUrl = this.site + url;
|
|
||||||
|
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
const novel = {
|
const novel = {
|
||||||
name: novelName,
|
name: novelName,
|
||||||
cover: novelCover,
|
cover: novelCover,
|
||||||
url: novelUrl,
|
path: url,
|
||||||
};
|
};
|
||||||
|
|
||||||
novels.push(novel);
|
novels.push(novel);
|
||||||
@@ -9,7 +9,7 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
id = "69xinshu";
|
id = "69xinshu";
|
||||||
name = "69书吧";
|
name = "69书吧";
|
||||||
icon = "src/cn/69xinshu/icon.png";
|
icon = "src/cn/69xinshu/icon.png";
|
||||||
site = "https://www.69xinshu.com";
|
site = "https://www.69shu.pro";
|
||||||
version = "0.1.1";
|
version = "0.1.1";
|
||||||
|
|
||||||
async popularNovels(
|
async popularNovels(
|
||||||
@@ -31,19 +31,19 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
const novels: Plugin.NovelItem[] = [];
|
const novels: Plugin.NovelItem[] = [];
|
||||||
|
|
||||||
const novelsList = pageNo === 1 ? loadedCheerio('div.newbox > ul > li') : loadedCheerio('li');
|
const novelsList = pageNo === 1 ? loadedCheerio('div.newbox > ul > li') : loadedCheerio('li');
|
||||||
novelsList.each(function () {
|
novelsList.each((i, e) => {
|
||||||
const novelUrl = loadedCheerio(this).find('li > div > h3 > a:nth-child(2)').attr('href');
|
const novelUrl = loadedCheerio(e).find('li > div > h3 > a:nth-child(2)').attr('href');
|
||||||
|
|
||||||
if (novelUrl) {
|
if (novelUrl) {
|
||||||
const novelName = loadedCheerio(this).find('li > div > h3 > a:nth-child(2)').text();
|
const novelName = loadedCheerio(e).find('li > div > h3 > a:nth-child(2)').text();
|
||||||
const novelCover = loadedCheerio(this)
|
const novelCover = loadedCheerio(e)
|
||||||
.find('li > a > img')
|
.find('li > a > img')
|
||||||
.attr('data-src');
|
.attr('data-src');
|
||||||
|
|
||||||
const novel = {
|
const novel = {
|
||||||
name: novelName,
|
name: novelName,
|
||||||
cover: novelCover,
|
cover: novelCover,
|
||||||
url: novelUrl,
|
path: novelUrl.replace(this.site, ''),
|
||||||
};
|
};
|
||||||
|
|
||||||
novels.push(novel);
|
novels.push(novel);
|
||||||
@@ -53,8 +53,8 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
return novels;
|
return novels;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||||
const url = novelUrl;
|
const url = this.site + novelPath;
|
||||||
|
|
||||||
const body = await fetchText(url, {}, 'gbk');
|
const body = await fetchText(url, {}, 'gbk');
|
||||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||||
@@ -62,12 +62,11 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
let loadedCheerio = parseHTML(body);
|
let loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
const novel: Plugin.SourceNovel = {
|
const novel: Plugin.SourceNovel = {
|
||||||
url,
|
path: novelPath,
|
||||||
chapters: [],
|
chapters: [],
|
||||||
|
name: loadedCheerio('h1 > a').text()
|
||||||
};
|
};
|
||||||
|
|
||||||
novel.name = loadedCheerio('h1 > a').text();
|
|
||||||
|
|
||||||
novel.cover = loadedCheerio('div.bookimg2 > img').attr(
|
novel.cover = loadedCheerio('div.bookimg2 > img').attr(
|
||||||
'src',
|
'src',
|
||||||
);
|
);
|
||||||
@@ -99,15 +98,15 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
|
|
||||||
const chaptersLoadedCheerio = parseHTML(chaptersBody);
|
const chaptersLoadedCheerio = parseHTML(chaptersBody);
|
||||||
|
|
||||||
chaptersLoadedCheerio('li').each(function () {
|
chaptersLoadedCheerio('li').each((i, e) => {
|
||||||
const chapterUrl = chaptersLoadedCheerio(this).find('a').attr('href');
|
const chapterUrl = chaptersLoadedCheerio(e).find('a').attr('href');
|
||||||
|
|
||||||
if (chapterUrl?.startsWith("https://")) {
|
if (chapterUrl?.startsWith("https://")) {
|
||||||
const chapterName = chaptersLoadedCheerio(this).find('a').text().trim();
|
const chapterName = chaptersLoadedCheerio(e).find('a').text().trim();
|
||||||
|
|
||||||
chapters.push({
|
chapters.push({
|
||||||
name: chapterName,
|
name: chapterName,
|
||||||
url: chapterUrl,
|
path: chapterUrl.replace(this.site, ''),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -118,8 +117,8 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
return novel;
|
return novel;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseChapter(chapterUrl: string): Promise<string> {
|
async parseChapter(chapterPath: string): Promise<string> {
|
||||||
const body = await fetchText(chapterUrl, {}, 'gbk');
|
const body = await fetchText(this.site + chapterPath, {}, 'gbk');
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -154,14 +153,14 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
|
|
||||||
const novels: Plugin.NovelItem[] = [];
|
const novels: Plugin.NovelItem[] = [];
|
||||||
|
|
||||||
loadedCheerio('div.newbox > ul > li').each(function () {
|
loadedCheerio('div.newbox > ul > li').each((i, e) => {
|
||||||
const novelUrl = loadedCheerio(this).find('a').attr('href')!;
|
const novelUrl = loadedCheerio(e).find('a').attr('href')!;
|
||||||
const novelName = loadedCheerio(this).find('div.newnav > h3').text();
|
const novelName = loadedCheerio(e).find('div.newnav > h3').text();
|
||||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
const novelCover = loadedCheerio(e).find('img').attr('data-src');
|
||||||
|
|
||||||
const novel = {
|
const novel = {
|
||||||
name: novelName,
|
name: novelName,
|
||||||
url: novelUrl,
|
path: novelUrl.replace(this.site, ''),
|
||||||
cover: novelCover,
|
cover: novelCover,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,14 +35,12 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
const novelCover = loadedCheerio(el)
|
const novelCover = loadedCheerio(el)
|
||||||
.find("div.book-cover > img")
|
.find("div.book-cover > img")
|
||||||
.attr("data-src");
|
.attr("data-src");
|
||||||
const novelUrl = this.site + url;
|
|
||||||
|
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
const novel = {
|
const novel = {
|
||||||
name: novelName,
|
name: novelName,
|
||||||
cover: novelCover,
|
cover: novelCover,
|
||||||
url: novelUrl,
|
path: url,
|
||||||
};
|
};
|
||||||
|
|
||||||
novels.push(novel);
|
novels.push(novel);
|
||||||
@@ -51,8 +49,8 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
return novels;
|
return novels;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||||
const url = novelUrl;
|
const url = this.site + novelPath;
|
||||||
|
|
||||||
const body = await fetchText(url);
|
const body = await fetchText(url);
|
||||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||||
@@ -60,12 +58,11 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
let loadedCheerio = parseHTML(body);
|
let loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
const novel: Plugin.SourceNovel = {
|
const novel: Plugin.SourceNovel = {
|
||||||
url,
|
path: novelPath,
|
||||||
chapters: [],
|
chapters: [],
|
||||||
|
name: loadedCheerio("#bookDetailWrapper .book-title").text()
|
||||||
};
|
};
|
||||||
|
|
||||||
novel.name = loadedCheerio("#bookDetailWrapper .book-title").text();
|
|
||||||
|
|
||||||
novel.cover = loadedCheerio("#bookDetailWrapper img.book-cover").attr(
|
novel.cover = loadedCheerio("#bookDetailWrapper img.book-cover").attr(
|
||||||
"src"
|
"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 =
|
const chapterName =
|
||||||
volumeName +
|
volumeName +
|
||||||
" — " +
|
" — " +
|
||||||
@@ -130,7 +127,7 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
chapter.push({
|
chapter.push({
|
||||||
name: chapterName,
|
name: chapterName,
|
||||||
releaseTime: releaseDate,
|
releaseTime: releaseDate,
|
||||||
url: chapterUrl,
|
path: chapterUrl,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -139,7 +136,7 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
return novel;
|
return novel;
|
||||||
}
|
}
|
||||||
|
|
||||||
async parseChapter(chapterUrl: string): Promise<string> {
|
async parseChapter(chapterPath: string): Promise<string> {
|
||||||
let chapterName,
|
let chapterName,
|
||||||
chapterText = "",
|
chapterText = "",
|
||||||
hasNextPage,
|
hasNextPage,
|
||||||
@@ -423,13 +420,13 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
return { pageCheerio, pageHasNextPage };
|
return { pageCheerio, pageHasNextPage };
|
||||||
};
|
};
|
||||||
|
|
||||||
let url = chapterUrl;
|
let url = this.site + chapterPath;
|
||||||
do {
|
do {
|
||||||
const page = await loadPage(url);
|
const page = await loadPage(url);
|
||||||
hasNextPage = page.pageHasNextPage;
|
hasNextPage = page.pageHasNextPage;
|
||||||
if (hasNextPage === true) {
|
if (hasNextPage === true) {
|
||||||
pageNumber++;
|
pageNumber++;
|
||||||
url = chapterUrl.replace(
|
url = url.replace(
|
||||||
/\.html/gi,
|
/\.html/gi,
|
||||||
`_${pageNumber}` + ".html"
|
`_${pageNumber}` + ".html"
|
||||||
);
|
);
|
||||||
@@ -516,13 +513,12 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
const novelCover = pageCheerio(el)
|
const novelCover = pageCheerio(el)
|
||||||
.find("div.book-cover > img")
|
.find("div.book-cover > img")
|
||||||
.attr("data-src");
|
.attr("data-src");
|
||||||
const novelUrl = this.site + nUrl;
|
|
||||||
|
|
||||||
if (!nUrl) return;
|
if (!nUrl) return;
|
||||||
|
|
||||||
novels.push({
|
novels.push({
|
||||||
name: novelName,
|
name: novelName,
|
||||||
url: novelUrl,
|
path: nUrl,
|
||||||
cover: novelCover,
|
cover: novelCover,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -13,6 +13,7 @@ class Syosetu implements Plugin.PluginBase {
|
|||||||
name = "Syosetu";
|
name = "Syosetu";
|
||||||
icon = "src/jp/syosetu/icon.png";
|
icon = "src/jp/syosetu/icon.png";
|
||||||
site = "https://yomou.syosetu.com/";
|
site = "https://yomou.syosetu.com/";
|
||||||
|
novelPrefix = "https://ncode.syosetu.com";
|
||||||
version = "1.1.0";
|
version = "1.1.0";
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent":
|
"User-Agent":
|
||||||
@@ -67,7 +68,7 @@ class Syosetu implements Plugin.PluginBase {
|
|||||||
if (!url) return;
|
if (!url) return;
|
||||||
const name = anchor.text();
|
const name = anchor.text();
|
||||||
const novel: NovelItem = {
|
const novel: NovelItem = {
|
||||||
url,
|
path: url.replace(this.novelPrefix, ''),
|
||||||
name,
|
name,
|
||||||
cover: defaultCover,
|
cover: defaultCover,
|
||||||
};
|
};
|
||||||
@@ -78,15 +79,15 @@ class Syosetu implements Plugin.PluginBase {
|
|||||||
const novels = await getNovelsFromPage(pageNo);
|
const novels = await getNovelsFromPage(pageNo);
|
||||||
return novels;
|
return novels;
|
||||||
}
|
}
|
||||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||||
let chapters: Plugin.ChapterItem[] = [];
|
let chapters: Plugin.ChapterItem[] = [];
|
||||||
const result = await fetch(novelUrl, { headers: this.headers });
|
const result = await fetch(this.novelPrefix + novelPath, { headers: this.headers });
|
||||||
const body = await result.text();
|
const body = await result.text();
|
||||||
const loadedCheerio = loadCheerio(body, { decodeEntities: false });
|
const loadedCheerio = loadCheerio(body, { decodeEntities: false });
|
||||||
|
|
||||||
// create novel object
|
// create novel object
|
||||||
let novel: Plugin.SourceNovel = {
|
let novel: Plugin.SourceNovel = {
|
||||||
url: novelUrl,
|
path: novelPath,
|
||||||
name: loadedCheerio(".novel_title").text(),
|
name: loadedCheerio(".novel_title").text(),
|
||||||
author: loadedCheerio(".novel_writername")
|
author: loadedCheerio(".novel_writername")
|
||||||
.text()
|
.text()
|
||||||
@@ -111,13 +112,15 @@ class Syosetu implements Plugin.PluginBase {
|
|||||||
.text() // get text
|
.text() // get text
|
||||||
.replace(/(.)/g, "") // remove "(edited)" mark
|
.replace(/(.)/g, "") // remove "(edited)" mark
|
||||||
.trim(), // trim spaces
|
.trim(), // trim spaces
|
||||||
"https://ncode.syosetu.com" + chapterA.attr("href"),
|
chapterA.attr("href"),
|
||||||
];
|
];
|
||||||
chapters.push({
|
if(chapterUrl) {
|
||||||
name: chapterName,
|
chapters.push({
|
||||||
releaseTime: releaseDate,
|
name: chapterName,
|
||||||
url: chapterUrl,
|
releaseTime: releaseDate,
|
||||||
});
|
path: chapterUrl,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
@@ -148,14 +151,14 @@ class Syosetu implements Plugin.PluginBase {
|
|||||||
releaseTime: loadedCheerio("head")
|
releaseTime: loadedCheerio("head")
|
||||||
.find("meta[name='WWWC']")
|
.find("meta[name='WWWC']")
|
||||||
.attr("content"), // get date from metadata
|
.attr("content"), // get date from metadata
|
||||||
url: novelUrl, // set chapterUrl to oneshot so that chapterScraper knows it's a one-shot,
|
path: novelPath, // set chapterUrl to oneshot so that chapterScraper knows it's a one-shot,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
novel.chapters = chapters;
|
novel.chapters = chapters;
|
||||||
return novel;
|
return novel;
|
||||||
}
|
}
|
||||||
async parseChapter(chapterUrl: string): Promise<string> {
|
async parseChapter(chapterPath: string): Promise<string> {
|
||||||
const result = await fetch(chapterUrl, { headers: this.headers });
|
const result = await fetch(this.novelPrefix + chapterPath, { headers: this.headers });
|
||||||
const body = await result.text();
|
const body = await result.text();
|
||||||
|
|
||||||
// create cheerioQuery
|
// create cheerioQuery
|
||||||
@@ -178,7 +181,6 @@ class Syosetu implements Plugin.PluginBase {
|
|||||||
const getNovelsFromPage = async (pagenumber: number) => {
|
const getNovelsFromPage = async (pagenumber: number) => {
|
||||||
// load page
|
// load page
|
||||||
const url = this.searchUrl(pagenumber) + `&word=${searchTerm}`;
|
const url = this.searchUrl(pagenumber) + `&word=${searchTerm}`;
|
||||||
console.log(url);
|
|
||||||
const result = await fetch(url, { headers: this.headers });
|
const result = await fetch(url, { headers: this.headers });
|
||||||
const body = await result.text();
|
const body = await result.text();
|
||||||
// Cheerio it!
|
// Cheerio it!
|
||||||
@@ -186,17 +188,20 @@ class Syosetu implements Plugin.PluginBase {
|
|||||||
|
|
||||||
let pageNovels: Plugin.NovelItem[] = [];
|
let pageNovels: Plugin.NovelItem[] = [];
|
||||||
// find class=searchkekka_box
|
// find class=searchkekka_box
|
||||||
cheerioQuery(".searchkekka_box").each(function (i, e) {
|
cheerioQuery(".searchkekka_box").each((i, e) => {
|
||||||
// get div with link and name
|
// get div with link and name
|
||||||
const novelDIV = cheerioQuery(this).find(".novel_h");
|
const novelDIV = cheerioQuery(e).find(".novel_h");
|
||||||
// get link element
|
// get link element
|
||||||
const novelA = novelDIV.children()[0];
|
const novelA = novelDIV.children()[0];
|
||||||
// add new novel to array
|
// add new novel to array
|
||||||
pageNovels.push({
|
const novelPath = novelA.attribs.href.replace(this.novelPrefix, '');
|
||||||
name: novelDIV.text(), // get the name
|
if(novelPath){
|
||||||
url: novelA.attribs.href, // get last part of the link
|
pageNovels.push({
|
||||||
cover: defaultCover,
|
name: novelDIV.text(), // get the name
|
||||||
});
|
path: novelPath, // get last part of the link
|
||||||
|
cover: defaultCover,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// return all novels from this page
|
// return all novels from this page
|
||||||
return pageNovels;
|
return pageNovels;
|
||||||
@@ -223,6 +228,9 @@ class Syosetu implements Plugin.PluginBase {
|
|||||||
async fetchImage(url: string): Promise<string | undefined> {
|
async fetchImage(url: string): Promise<string | undefined> {
|
||||||
return fetchFile(url);
|
return fetchFile(url);
|
||||||
}
|
}
|
||||||
|
resolveUrl(path: string, isNovel?: boolean | undefined): string {
|
||||||
|
return this.novelPrefix + path;
|
||||||
|
}
|
||||||
filters = {
|
filters = {
|
||||||
ranking: {
|
ranking: {
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
Reference in New Issue
Block a user