@@ -8,55 +8,28 @@ export class CatMangaParser {
88} )
99}
1010
11- parseTileList ( $ :CheerioStatic , className :string , className2 :string | null = null ) {
12- if ( className2 === null ) {
13- className2 = className ;
14- }
15- const mangaTiles :MangaTile [ ] = [ ] ;
16- $ ( `div[class^=${ className } _grid] *[class^=${ className2 } _element]` ) . map ( ( index , element ) => {
17- const linkId = element . attribs [ "href" ] ;
18- if ( linkId ) {
19- const tile :MangaTile = {
20- id :linkId . replace ( `/series/` , "" ) . split ( "/" ) [ 0 ] ,
21- title :createIconText ( {
22- text :this . decodeHTMLEntity ( $ ( "p" , element ) . first ( ) . text ( ) . trim ( ) )
23- } ) ,
24- image :$ ( "img" , element ) . attr ( "src" ) || ""
25- }
26- if ( $ ( "p" , element ) . length > 1 ) {
27- tile . primaryText = createIconText ( {
28- text :this . decodeHTMLEntity ( $ ( "p" , element ) . last ( ) . text ( ) . trim ( ) )
29- } ) ;
30- }
31- mangaTiles . push ( createMangaTile ( tile ) ) ;
32- }
33- } )
34- return mangaTiles ;
35- }
36-
37- parseFeatured ( $ :CheerioStatic , base :string ) {
38- const seen :string [ ] = [ ] ;
11+ parseHomeTiles ( $ :CheerioStatic , base :string ) {
3912const mangaTiles :MangaTile [ ] = [ ] ;
40- $ ( "ul.slider li.slide " ) . map ( ( index , element ) => {
41- const link = $ ( "a" , element ) ;
42- const linkId = link . attr ( "href" )
43- if ( linkId ) {
44- const id = linkId . replace ( `/series/` , "" ) . split ( "/" ) [ 0 ] ;
45- if ( ! seen . includes ( id ) ) {
46- seen . push ( id ) ;
47- mangaTiles . push ( createMangaTile ( {
48- id : id ,
49- title : createIconText ( {
50- text : this . decodeHTMLEntity ( $ ( "h1" , element ) . first ( ) . text ( ) . trim ( ) )
51- } ) ,
52- image : base + $ ( "img" , element ) . attr ( "src" ) || "" ,
53- primaryText : createIconText ( {
54- text : this . decodeHTMLEntity ( $ ( "div p" , $ ( "a" , element ) . parent ( ) ) . first ( ) . text ( ) . trim ( ) )
55- } )
56- } ) )
13+ const json = JSON . parse ( $ ( "script#__NEXT_DATA__ " ) . html ( ) || "{}" ) ;
14+ if ( json ) {
15+ const props = json . props ;
16+ if ( props ) {
17+ const pageProps = props . pageProps ;
18+ if ( pageProps ) {
19+ const series = pageProps . series ;
20+ for ( let i = 0 ; i < series . length ; i ++ ) {
21+ const item = series [ i ] ;
22+ mangaTiles . push ( createMangaTile ( {
23+ id : item . series_id ,
24+ image : item . cover_art . source ,
25+ title : createIconText ( {
26+ text : this . decodeHTMLEntity ( item . title )
27+ } )
28+ } ) )
29+ }
5730}
5831}
59- } )
32+ }
6033return mangaTiles ;
6134}
6235
@@ -138,7 +111,7 @@ export class CatMangaParser {
138111const pageProps = props . pageProps ;
139112if ( pageProps ) {
140113const series = pageProps . series ;
141- if ( series && series . genres && ( series . genres . length || 0 ) > 0 && series . title && series . decription && series . status && series . cover_art && series . conver_art . source ) {
114+ if ( series && series . genres && ( series . genres . length || 0 ) > 0 && series . title && series . description && series . status && series . cover_art && series . cover_art . source ) {
142115let titles = [ series . title ]
143116const covers = [ ] ;
144117const tags = [ ]
@@ -189,7 +162,7 @@ export class CatMangaParser {
189162}
190163}
191164}
192- return this . parseMangaFallback ( $ , mangaId ) ;
165+ throw new Error ( "Bug!" )
193166}
194167
195168parseMangaFallback ( $ :CheerioStatic , mangaId :string ) {