1+ /*
2+ @header ({
3+ searchable: 1,
4+ filterable: 0,
5+ quickSearch: 1,
6+ title: '努努书坊[书]',
7+ author: 'EylinSir',
8+ '类型': '小说',
9+ logo: 'https://www.nunubook.com/favicon.ico',
10+ lang: 'ds'
11+ })
12+ */
13+
14+ var rule = {
15+ 类型 : '小说' ,
16+ author : 'EylinSir' ,
17+ title : '努努书坊[书]' ,
18+ host : 'https://www.nunubook.com' ,
19+ url : '/fyclass/##fypage' ,
20+ logo : 'https://www.nunubook.com/favicon.ico' ,
21+ class_name : '玄幻小说&魔幻小说&悬疑小说&历史架空&都市小说&言情小说&武侠小说&官场小说&现代小说&战争军事&侦探推理&外国小说&纪实小说&诗歌戏曲&宗教哲学&文学理论&寓言童话&科普学习&社会心理&作品集&传记回忆&杂文随笔' ,
22+ class_url : 'xuanhuan&mohuan&xuanyi&lishi&dushi&yanqing&wuxia&guanchang&xiandaixiaoshuo&zhanzhengjunshi&zhentantuili&waiguo&jishi&shigexiqu&zhexue&wenxuelilun&yuyantonghua&kepuxuexi&shehuixinli&zuopinji&zhuanjihuiyi&zawen' ,
23+ searchUrl : '/e/search/index.php?tbname=bookname&show=title&tempid=1&keyboard=**' ,
24+ searchable : 1 ,
25+ quickSearch : 1 ,
26+ filterable : 0 ,
27+ timeout : 10000 ,
28+ play_parse : true ,
29+ headers : { 'User-Agent' : 'MOBILE_UA' } ,
30+
31+ 一级 : async function ( ) {
32+ let [ cateUrl , pg ] = this . input . split ( '##' ) ;
33+ let list = [ ] ;
34+ let cateKey = cateUrl . split ( '/' ) . filter ( Boolean ) . pop ( ) || '' ;
35+ let cl = this . class_url . split ( '&' ) . findIndex ( k => k === cateKey ) + 1 || undefined ;
36+ if ( pg === '1' ) {
37+ let html = await request ( cateUrl ) ;
38+ let selectors = [ '.listBig-li' , 'li.listBig-li' , '.book-item' , '.list-item' ] ;
39+ let items = selectors . map ( sel => this . pdfa ( html , sel ) ) . find ( Boolean ) ;
40+ items ?. forEach ( item => {
41+ let urlSelectors = [ 'a:eq(0)&&href' , 'a&&href' ] ;
42+ let url = urlSelectors . map ( sel => this . pd ( item , sel ) ) . find ( Boolean ) || this . pdfh ( item , 'a&&href' ) ;
43+ if ( url ) {
44+ url = url . startsWith ( 'http' ) ? url : `${ this . host } ${ url } ` ;
45+ let title = this . pdfh ( item , 'h3&&Text' ) || this . pdfh ( item , 'h2&&Text' ) || '未知标题' ;
46+ let desc = this . pdfh ( item , 'p:eq(0)&&Text' ) || '无简介' ;
47+ list . push ( {
48+ title,
49+ url,
50+ desc,
51+ pic_url : this . pd ( item , 'img&&src' ) || '' ,
52+ content : this . pdfh ( item , '.text&&Text' ) || desc
53+ } ) ;
54+ }
55+ } ) ;
56+ } else if ( cl ) {
57+ let apiUrl = `${ this . host } /e/extend/more/lsmore.php?page=${ pg } &line=10&cl=${ cl } ` ;
58+ let json = JSON . parse ( await request ( apiUrl ) ) ;
59+ list . push ( ...json . map ( item => ( {
60+ title : item . title ,
61+ url : item . url ,
62+ pic_url : item . pic ,
63+ desc : item . smalltext ,
64+ content : `${ item . smalltext } \n作者:${ item . writer } `
65+ } ) ) ) ;
66+ }
67+ return setResult ( list ) ;
68+ } ,
69+
70+ 二级 : async function ( ) {
71+ let html = await request ( this . input ) ;
72+ let VOD = {
73+ vod_name : this . pdfh ( html , 'h1&&Text' ) ,
74+ vod_pic : this . pdfh ( html , '[property$=image]&&content' ) ,
75+ vod_content : this . pdfh ( html , '[property$=description]&&content' ) ,
76+ vod_actor : this . pdfh ( html , '[property$=author]&&content' )
77+ } ;
78+ let id = this . input . match ( / \/ ( \d + ) ( \/ | \. h t m l ) / ) ?. [ 1 ] ;
79+ if ( id ) {
80+ let baseUrl = `${ this . host } /e/extend/bookpage/pages.php?id=${ id } &dz=asc&pageNum=` ;
81+ let firstPage = JSON . parse ( await request ( baseUrl + '0' ) ) ;
82+ let chapters = firstPage . list || [ ] ;
83+ if ( firstPage . totalPage > 0 ) {
84+ let reqs = [ ] ;
85+ for ( let i = 1 ; i <= firstPage . totalPage ; i ++ ) reqs . push ( request ( baseUrl + i ) ) ;
86+ let res = await Promise . all ( reqs ) ;
87+ res . forEach ( r => { chapters = chapters . concat ( JSON . parse ( r ) . list || [ ] ) } ) ;
88+ }
89+ VOD . vod_play_from = '努努书坊' ;
90+ VOD . vod_play_url = chapters . map ( c => {
91+ let url = c . pic || c . url ;
92+ return c . title + '$' + ( url . startsWith ( 'http' ) ? url : `${ this . host } ${ url } ` ) ;
93+ } ) . join ( '#' ) ;
94+ }
95+ return VOD ;
96+ } ,
97+
98+ 搜索 : async function ( ) {
99+ let [ url , params ] = this . input . split ( '?' ) ;
100+ let html = await post ( url , { body : params } ) ;
101+ let list = [ ] ;
102+ if ( ! html . includes ( '没有搜索到' ) ) {
103+ ( this . pdfa ( html , '.search-wrap-first' ) || [ ] ) . forEach ( item => {
104+ let url = this . pd ( item , 'a&&href' ) ;
105+ if ( url ) list . push ( {
106+ title : this . pdfh ( item , 'h3&&Text' ) . replace ( '小说' , '' ) ,
107+ url : url . startsWith ( 'http' ) ? url : `${ this . host } ${ url } ` ,
108+ pic_url : this . pd ( item , 'img&&src' ) ,
109+ content : this . pdfh ( item , 'p&&Text' )
110+ } ) ;
111+ } ) ;
112+ }
113+ return setResult ( list ) ;
114+ } ,
115+
116+ lazy : async function ( ) {
117+ let { input, pdfh } = this ;
118+ let html = await request ( input ) ;
119+ let content = pdfh ( html , '#text&&Html' ) || '' ;
120+ if ( content ) {
121+ content = content
122+ . replace ( / < s c r i p t [ ^ > ] * ?> .* ?< \/ s c r i p t > / gs, '' )
123+ . replace ( / < \/ p > / g, '\n\n' )
124+ . replace ( / < b r \s * \/ ? > / gi, '\n' )
125+ . replace ( / < [ ^ > ] + > / g, '' )
126+ . replace ( / & n b s p ; / g, ' ' )
127+ . replace ( / \n \s * \n / g, '\n\n' )
128+ . trim ( ) ;
129+ }
130+ return {
131+ parse : 0 ,
132+ url : `novel://${ JSON . stringify ( { title : pdfh ( html , 'h1&&Text' ) || '' , content } ) } ` ,
133+ js : ''
134+ } ;
135+ }
136+ } ;
0 commit comments