@@ -2,13 +2,16 @@ import {Chapter, LanguageCode, Manga, MangaStatus, MangaTile, Tag} from "paperba
22
33export class RainOfSnowParser {
44
5- parseMangaList ( $ : CheerioStatic , base : string ) {
5+ parseMangaList ( $ : CheerioStatic , base : string , filterElement : Cheerio | null = null ) {
6+ if ( filterElement === null ) {
7+ filterElement = $ . root ( )
8+ }
69 const mangaTiles : MangaTile [ ] = [ ] ;
7- $ ( "ul.boxhover1 li" ) . map ( ( ( index , element ) => {
8- const link = $ ( "h4 a" , element ) . first ( ) ;
10+ $ ( "div.col-xs-6.col-md-3.col-lg-2" , filterElement ) . map ( ( ( index , element ) => {
11+ const link = $ ( "h3 a" , element ) . first ( ) ;
912 const linkId = link . attr ( "href" ) ;
1013 const imgSrc = $ ( "a img" , element ) . first ( ) . attr ( "src" ) ;
11- if ( linkId ) {
14+ if ( linkId && linkId . includes ( "comic" ) ) {
1215 mangaTiles . push ( createMangaTile ( {
1316 id : linkId . replace ( `${ base } /comic/` , "" ) . slice ( 0 , - 1 ) ,
1417 image : imgSrc || "" ,
@@ -33,16 +36,18 @@ export class RainOfSnowParser {
3336
3437 parseChapterList ( $ : CheerioStatic , mangaId : string , base : string ) {
3538 const chapters : Chapter [ ] = [ ] ;
36- $ ( "ul.chapter1 li" ) . map ( ( index , element ) => {
39+ $ ( "div#chapter li" ) . map ( ( index , element ) => {
3740 const link = $ ( "a" , element ) . first ( ) ;
3841 const linkId = link . attr ( "href" ) ;
3942 if ( linkId ) {
43+ const chapParts = link . text ( ) . split ( "." ) ;
4044 chapters . push ( createChapter ( {
41- chapNum : Number ( link . text ( ) . split ( "." ) [ 0 ] ) ,
45+ chapNum : Number ( chapParts [ 0 ] ) ,
4246 id : linkId . replace ( base + "/comic_chapters/" , "" ) ,
4347 langCode : LanguageCode . ENGLISH ,
4448 mangaId : mangaId ,
4549 time : new Date ( $ ( "small" , element ) . first ( ) . text ( ) ) ,
50+ name : chapParts [ 1 ] || undefined
4651 } ) )
4752 }
4853 } )
@@ -56,14 +61,9 @@ export class RainOfSnowParser {
5661 }
5762
5863 parseManga ( $ : CheerioStatic , mangaId : string , base : string ) {
59- const items = $ ( "ul.rat1 li" ) ;
6064 const tagList : Tag [ ] = [ ] ;
61- let summary : string = ""
62- $ ( "div.summery div.text p" ) . map ( ( ( index , element ) => {
63- summary += $ ( element ) . text ( ) + "\n"
64- } ) )
65- summary = summary . trim ( ) ;
66- $ ( "a[rel=\"tag\"]" , items ) . map ( ( ( index , element ) => {
65+ const summary : string = $ ( "div#synop" ) . text ( ) . replace ( / \s { 2 , } / , "" ) . trim ( ) ;
66+ $ ( "a[rel=\"tag\"]" , $ ( "ul.vbtcolor1" ) . first ( ) ) . map ( ( ( index , element ) => {
6767 if ( "attribs" in element ) {
6868 tagList . push ( createTag ( {
6969 id : element . attribs [ "href" ] . replace ( `${ base } /tag/` , "" ) . slice ( 0 , - 1 ) ,
@@ -73,13 +73,13 @@ export class RainOfSnowParser {
7373 } ) )
7474 const chapterList = this . parseChapterList ( $ , mangaId , base )
7575 const mangaObj : Manga = {
76- author : $ ( ".n2 " , items . first ( ) ) . text ( ) ,
76+ author : $ ( "small " , $ ( "ul.vbtcolor1 li" ) . first ( ) ) . text ( ) . trim ( ) ,
7777 desc : summary ,
7878 id : mangaId ,
79- image : $ ( "div.imgbox img" ) . first ( ) . attr ( "src" ) || "" ,
79+ image : $ ( "img" , $ ( " div.container div.row" ) . first ( ) ) . first ( ) . attr ( "src" ) || "" ,
8080 rating : 0 ,
8181 status : MangaStatus . ONGOING ,
82- titles : [ $ ( "div.container h3 " ) . first ( ) . text ( ) ] ,
82+ titles : [ $ ( "div.text h2 " ) . first ( ) . text ( ) ] ,
8383 tags : [ createTagSection ( {
8484 id : "1" ,
8585 label : "1" ,
0 commit comments