Chinese: support showLatestNovels (#733)
* improve: better chapterText * feat: support latest page
This commit is contained in:
+22
-28
@@ -9,21 +9,26 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
name = "69书吧";
|
name = "69书吧";
|
||||||
icon = "src/cn/69shu/icon.png";
|
icon = "src/cn/69shu/icon.png";
|
||||||
site = "https://www.69shu.xyz";
|
site = "https://www.69shu.xyz";
|
||||||
version = "0.1.0";
|
version = "0.2.0";
|
||||||
|
|
||||||
async popularNovels(
|
async popularNovels(
|
||||||
pageNo: number,
|
pageNo: number,
|
||||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
{
|
||||||
|
showLatestNovels,
|
||||||
|
filters,
|
||||||
|
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
let url: string;
|
let url: string;
|
||||||
if (filters.sort.value === 'none') {
|
if (showLatestNovels) {
|
||||||
|
url = `${this.site}/rank/lastupdate/${pageNo}.html`;
|
||||||
|
} else if (filters.sort.value === 'none') {
|
||||||
url = `${this.site}/rank/${filters.rank.value}/${pageNo}.html`;
|
url = `${this.site}/rank/${filters.rank.value}/${pageNo}.html`;
|
||||||
} else {
|
} else {
|
||||||
url = `${this.site}/sort/${filters.sort.value}/${pageNo}.html`;
|
url = `${this.site}/sort/${filters.sort.value}/${pageNo}.html`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = await fetchText(url);
|
const body = await fetchText(url);
|
||||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
if (body === '') throw Error('无法获取小说列表,请检查网络');
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -116,20 +121,28 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parseChapter(chapterUrl: string): Promise<string> {
|
async parseChapter(chapterUrl: string): Promise<string> {
|
||||||
const url = chapterUrl;
|
const body = await fetchText(chapterUrl);
|
||||||
const body = await fetchText(url);
|
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
const chapterText = loadedCheerio('#chaptercontent').html() || '';
|
const chapterText = loadedCheerio('#chaptercontent p')
|
||||||
|
.map((i, el) => loadedCheerio(el).text())
|
||||||
|
.get()
|
||||||
|
// remove empty lines and 69shu ads
|
||||||
|
.map((line: string) => line.trim())
|
||||||
|
.filter((line: string) => line !== '' && !line.includes('69书吧'))
|
||||||
|
.map((line: string) => `<p>${line}</p>`)
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
return chapterText;
|
return chapterText;
|
||||||
};
|
};
|
||||||
|
|
||||||
async searchNovels(
|
async searchNovels(
|
||||||
searchTerm: string,
|
searchTerm: string,
|
||||||
pageNo?: number | undefined
|
pageNo: number
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
|
if (pageNo > 1) return [];
|
||||||
|
|
||||||
const searchUrl = `${this.site}/search`;
|
const searchUrl = `${this.site}/search`;
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('searchkey', searchTerm);
|
formData.append('searchkey', searchTerm);
|
||||||
@@ -138,8 +151,7 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
if (body === '') throw Error('无法获取搜索结果,请检查网络');
|
||||||
|
|
||||||
|
|
||||||
let loadedCheerio = parseHTML(body);
|
let loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -174,21 +186,13 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
value: "allvisit",
|
value: "allvisit",
|
||||||
options: [
|
options: [
|
||||||
{ label: "总排行榜", value: "allvisit" },
|
{ label: "总排行榜", value: "allvisit" },
|
||||||
|
|
||||||
{ label: "月排行榜", value: "monthvisit" },
|
{ label: "月排行榜", value: "monthvisit" },
|
||||||
|
|
||||||
{ label: "周排行榜", value: "weekvisit" },
|
{ label: "周排行榜", value: "weekvisit" },
|
||||||
|
|
||||||
{ label: "日排行榜", value: "dayvisit" },
|
{ label: "日排行榜", value: "dayvisit" },
|
||||||
|
|
||||||
{ label: "收藏榜", value: "goodnum" },
|
{ label: "收藏榜", value: "goodnum" },
|
||||||
|
|
||||||
{ label: "字数榜", value: "words" },
|
{ label: "字数榜", value: "words" },
|
||||||
|
|
||||||
{ label: "推荐榜", value: "allvote" },
|
{ label: "推荐榜", value: "allvote" },
|
||||||
|
|
||||||
{ label: "新书榜", value: "postdate" },
|
{ label: "新书榜", value: "postdate" },
|
||||||
|
|
||||||
{ label: "更新榜", value: "lastupdate" },
|
{ label: "更新榜", value: "lastupdate" },
|
||||||
],
|
],
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
@@ -198,25 +202,15 @@ class Shu69 implements Plugin.PluginBase {
|
|||||||
value: "none",
|
value: "none",
|
||||||
options: [
|
options: [
|
||||||
{ label: "无", value: "none" },
|
{ label: "无", value: "none" },
|
||||||
|
|
||||||
{ label: "全部", value: "all" },
|
{ label: "全部", value: "all" },
|
||||||
|
|
||||||
{ label: "玄幻", value: "xuanhuan" },
|
{ label: "玄幻", value: "xuanhuan" },
|
||||||
|
|
||||||
{ label: "仙侠", value: "xianxia" },
|
{ label: "仙侠", value: "xianxia" },
|
||||||
|
|
||||||
{ label: "都市", value: "dushi" },
|
{ label: "都市", value: "dushi" },
|
||||||
|
|
||||||
{ label: "历史", value: "lishi" },
|
{ label: "历史", value: "lishi" },
|
||||||
|
|
||||||
{ label: "游戏", value: "youxi" },
|
{ label: "游戏", value: "youxi" },
|
||||||
|
|
||||||
{ label: "科幻", value: "kehuan" },
|
{ label: "科幻", value: "kehuan" },
|
||||||
|
|
||||||
{ label: "灵异", value: "kongbu" },
|
{ label: "灵异", value: "kongbu" },
|
||||||
|
|
||||||
{ label: "言情", value: "nvsheng" },
|
{ label: "言情", value: "nvsheng" },
|
||||||
|
|
||||||
{ label: "其它", value: "qita" },
|
{ label: "其它", value: "qita" },
|
||||||
],
|
],
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
|
|||||||
+17
-29
@@ -10,7 +10,7 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
name = "69书吧";
|
name = "69书吧";
|
||||||
icon = "src/cn/69xinshu/icon.png";
|
icon = "src/cn/69xinshu/icon.png";
|
||||||
site = "https://www.69xinshu.com";
|
site = "https://www.69xinshu.com";
|
||||||
version = "0.1.0";
|
version = "0.1.1";
|
||||||
|
|
||||||
async popularNovels(
|
async popularNovels(
|
||||||
pageNo: number,
|
pageNo: number,
|
||||||
@@ -24,7 +24,7 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const body = await fetchText(url, {}, 'gbk');
|
const body = await fetchText(url, {}, 'gbk');
|
||||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
if (body === '') throw Error('无法获取小说列表,请检查网络');
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -119,36 +119,36 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parseChapter(chapterUrl: string): Promise<string> {
|
async parseChapter(chapterUrl: string): Promise<string> {
|
||||||
const url = chapterUrl;
|
const body = await fetchText(chapterUrl, {}, 'gbk');
|
||||||
const body = await fetchText(url, {}, 'gbk');
|
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
const chapterText = loadedCheerio('div.txtnav').prop('innerText') ?? '';
|
const chapterText = (loadedCheerio('div.txtnav').prop('innerText') ?? '')
|
||||||
// remove empty lines
|
.split('\n')
|
||||||
let lines = chapterText.split('\n').map((line: string) => line.trim()).filter((line: string) => line.length > 0);
|
// remove empty lines
|
||||||
// remove the first two lines which are the chapter name and author name
|
.map((line: string) => line.trim())
|
||||||
lines = lines.slice(2);
|
.filter((line: string) => line !== '')
|
||||||
|
// remove the first two lines which are the chapter name and author name
|
||||||
|
.slice(2)
|
||||||
|
.map((line: string) => `<p>${line}</p>`)
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
let parsedText = '';
|
return chapterText;
|
||||||
for (let line of lines) {
|
|
||||||
parsedText += `<p>${line}</p>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parsedText;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async searchNovels(
|
async searchNovels(
|
||||||
searchTerm: string,
|
searchTerm: string,
|
||||||
pageNo?: number | undefined
|
pageNo: number
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
|
if (pageNo > 1) return [];
|
||||||
|
|
||||||
const searchUrl = `${this.site}/modules/article/search.php`;
|
const searchUrl = `${this.site}/modules/article/search.php`;
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('searchkey', encode(searchTerm, 'gbk'));
|
formData.append('searchkey', encode(searchTerm, 'gbk'));
|
||||||
formData.append('searchtype', 'all');
|
formData.append('searchtype', 'all');
|
||||||
|
|
||||||
const body = await fetchText(searchUrl, { method: 'post', body: formData, }, 'gbk');
|
const body = await fetchText(searchUrl, { method: 'post', body: formData, }, 'gbk');
|
||||||
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
if (body === '') throw Error('无法获取搜索结果,请检查网络');
|
||||||
|
|
||||||
let loadedCheerio = parseHTML(body);
|
let loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -179,29 +179,17 @@ class XinShu69 implements Plugin.PluginBase {
|
|||||||
value: "0",
|
value: "0",
|
||||||
options: [
|
options: [
|
||||||
{ label: "全部分类", value: "0" },
|
{ label: "全部分类", value: "0" },
|
||||||
|
|
||||||
{ label: "言情小说", value: "3" },
|
{ label: "言情小说", value: "3" },
|
||||||
|
|
||||||
{ label: "玄幻魔法", value: "1" },
|
{ label: "玄幻魔法", value: "1" },
|
||||||
|
|
||||||
{ label: "修真武侠", value: "2" },
|
{ label: "修真武侠", value: "2" },
|
||||||
|
|
||||||
{ label: "穿越时空", value: "11" },
|
{ label: "穿越时空", value: "11" },
|
||||||
|
|
||||||
{ label: "都市小说", value: "9" },
|
{ label: "都市小说", value: "9" },
|
||||||
|
|
||||||
{ label: "历史军事", value: "4" },
|
{ label: "历史军事", value: "4" },
|
||||||
|
|
||||||
{ label: "游戏竞技", value: "5" },
|
{ label: "游戏竞技", value: "5" },
|
||||||
|
|
||||||
{ label: "科幻空间", value: "6" },
|
{ label: "科幻空间", value: "6" },
|
||||||
|
|
||||||
{ label: "悬疑惊悚", value: "7" },
|
{ label: "悬疑惊悚", value: "7" },
|
||||||
|
|
||||||
{ label: "同人小说", value: "8" },
|
{ label: "同人小说", value: "8" },
|
||||||
|
|
||||||
{ label: "官场职场", value: "10" },
|
{ label: "官场职场", value: "10" },
|
||||||
|
|
||||||
{ label: "青春校园", value: "12" },
|
{ label: "青春校园", value: "12" },
|
||||||
],
|
],
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
|
|||||||
@@ -9,14 +9,20 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
name = "Linovelib";
|
name = "Linovelib";
|
||||||
icon = "src/cn/linovelib/icon.png";
|
icon = "src/cn/linovelib/icon.png";
|
||||||
site = "https://www.bilinovel.com";
|
site = "https://www.bilinovel.com";
|
||||||
version = "1.0.2";
|
version = "1.1.0";
|
||||||
|
|
||||||
async popularNovels(
|
async popularNovels(
|
||||||
pageNo: number,
|
pageNo: number,
|
||||||
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>
|
{
|
||||||
|
showLatestNovels,
|
||||||
|
filters,
|
||||||
|
}: Plugin.PopularNovelsOptions<typeof this.filters>
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
const url = `${this.site}/top/${filters.rank.value}/${pageNo}.html`;
|
const rank = showLatestNovels ? 'lastupdate' : filters.rank.value;
|
||||||
|
const url = `${this.site}/top/${rank}/${pageNo}.html`;
|
||||||
|
|
||||||
const body = await fetchText(url);
|
const body = await fetchText(url);
|
||||||
|
if (body === '') throw Error('无法获取小说列表,请检查网络');
|
||||||
|
|
||||||
const loadedCheerio = parseHTML(body);
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -47,7 +53,9 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
|
|
||||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||||
const url = novelUrl;
|
const url = novelUrl;
|
||||||
|
|
||||||
const body = await fetchText(url);
|
const body = await fetchText(url);
|
||||||
|
if (body === '') throw Error('无法获取小说内容,请检查网络');
|
||||||
|
|
||||||
let loadedCheerio = parseHTML(body);
|
let loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -427,10 +435,12 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
|
|
||||||
async searchNovels(
|
async searchNovels(
|
||||||
searchTerm: string,
|
searchTerm: string,
|
||||||
pageNo?: number | undefined
|
pageNo: number
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
const url = `${this.site}/search/${encodeURI(searchTerm)}_${pageNo}.html`;
|
const url = `${this.site}/search/${encodeURI(searchTerm)}_${pageNo}.html`;
|
||||||
|
|
||||||
const body = await fetchText(url);
|
const body = await fetchText(url);
|
||||||
|
if (body === '') throw Error('无法获取搜索结果,请检查网络');
|
||||||
|
|
||||||
const pageCheerio = parseHTML(body);
|
const pageCheerio = parseHTML(body);
|
||||||
|
|
||||||
@@ -529,27 +539,16 @@ class Linovelib implements Plugin.PluginBase {
|
|||||||
value: "monthvisit",
|
value: "monthvisit",
|
||||||
options: [
|
options: [
|
||||||
{ label: "月点击榜", value: "monthvisit" },
|
{ label: "月点击榜", value: "monthvisit" },
|
||||||
|
|
||||||
{ label: "周点击榜", value: "weekvisit" },
|
{ label: "周点击榜", value: "weekvisit" },
|
||||||
|
|
||||||
{ label: "月推荐榜", value: "monthvote" },
|
{ label: "月推荐榜", value: "monthvote" },
|
||||||
|
|
||||||
{ label: "周推荐榜", value: "weekvote" },
|
{ label: "周推荐榜", value: "weekvote" },
|
||||||
|
|
||||||
{ label: "月鲜花榜", value: "monthflower" },
|
{ label: "月鲜花榜", value: "monthflower" },
|
||||||
|
|
||||||
{ label: "周鲜花榜", value: "weekflower" },
|
{ label: "周鲜花榜", value: "weekflower" },
|
||||||
|
|
||||||
{ label: "月鸡蛋榜", value: "monthegg" },
|
{ label: "月鸡蛋榜", value: "monthegg" },
|
||||||
|
|
||||||
{ label: "周鸡蛋榜", value: "weekegg" },
|
{ label: "周鸡蛋榜", value: "weekegg" },
|
||||||
|
|
||||||
{ label: "最近更新", value: "lastupdate" },
|
{ label: "最近更新", value: "lastupdate" },
|
||||||
|
|
||||||
{ label: "最新入库", value: "postdate" },
|
{ label: "最新入库", value: "postdate" },
|
||||||
|
|
||||||
{ label: "收藏榜", value: "goodnum" },
|
{ label: "收藏榜", value: "goodnum" },
|
||||||
|
|
||||||
{ label: "新书榜", value: "newhot" },
|
{ label: "新书榜", value: "newhot" },
|
||||||
],
|
],
|
||||||
type: FilterTypes.Picker,
|
type: FilterTypes.Picker,
|
||||||
|
|||||||
Reference in New Issue
Block a user