forked from LNReader/lnreader-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin-template.ts
86 lines (74 loc) · 2.19 KB
/
plugin-template.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { fetchFile } from '@libs/fetch';
import { Plugin } from '@typings/plugin';
import { Filters } from '@libs/filterInputs';
import { load as loadCheerio } from 'cheerio';
import { defaultCover } from '@libs/defaultCover';
import { NovelStatus } from '@libs/novelStatus';
// import { isUrlAbsolute } from "@libs/isAbsoluteUrl";
// import { parseMadaraDate } from "@libs/parseMadaraDate";
class TemplatePlugin implements Plugin.PluginBase {
id = '';
name = '';
icon = '';
site = 'https://example.com';
version = '1.0.0';
filters: Filters | undefined = undefined;
imageRequestInit?: Plugin.ImageRequestInit | undefined = undefined;
async popularNovels(
pageNo: number,
{
showLatestNovels,
filters,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
): Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
/** Add your fetching code here */
novels.push({
name: 'Novel1',
path: '/novels/1',
cover: defaultCover,
});
return novels;
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
const novel: Plugin.SourceNovel = {
path: novelPath,
name: 'Untitled',
};
// TODO: get here data from the site and
// un-comment and fill-in the relevant fields
// novel.name = "";
// novel.artist = "";
// novel.author = "";
novel.cover = defaultCover;
// novel.genres = "";
// novel.status = NovelStatus.Completed;
// novel.summary = "";
let chapters: Plugin.ChapterItem[] = [];
// TODO: here parse the chapter list
// TODO: add each chapter to the list using
const chapter: Plugin.ChapterItem = {
name: '',
path: '',
releaseTime: '',
chapterNumber: 0,
};
chapters.push(chapter);
novel.chapters = chapters;
return novel;
}
async parseChapter(chapterPath: string): Promise<string> {
// parse chapter text here
const chapterText = '';
return chapterText;
}
async searchNovels(
searchTerm: string,
pageNo: number,
): Promise<Plugin.NovelItem[]> {
let novels: Plugin.NovelItem[] = [];
// get novels using the search term
return novels;
}
}
export default new TemplatePlugin();