@@ -2,13 +2,16 @@ import {Chapter, LanguageCode, Manga, MangaStatus, MangaTile, Tag} from "paperba
2
2
3
3
export class RainOfSnowParser {
4
4
5
- parseMangaList ( $ : CheerioStatic , base : string ) {
5
+ parseMangaList ( $ : CheerioStatic , base : string , filterElement : Cheerio | null = null ) {
6
+ if ( filterElement === null ) {
7
+ filterElement = $ . root ( )
8
+ }
6
9
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 ( ) ;
9
12
const linkId = link . attr ( "href" ) ;
10
13
const imgSrc = $ ( "a img" , element ) . first ( ) . attr ( "src" ) ;
11
- if ( linkId ) {
14
+ if ( linkId && linkId . includes ( "comic" ) ) {
12
15
mangaTiles . push ( createMangaTile ( {
13
16
id : linkId . replace ( `${ base } /comic/` , "" ) . slice ( 0 , - 1 ) ,
14
17
image : imgSrc || "" ,
@@ -33,16 +36,18 @@ export class RainOfSnowParser {
33
36
34
37
parseChapterList ( $ : CheerioStatic , mangaId : string , base : string ) {
35
38
const chapters : Chapter [ ] = [ ] ;
36
- $ ( "ul.chapter1 li" ) . map ( ( index , element ) => {
39
+ $ ( "div#chapter li" ) . map ( ( index , element ) => {
37
40
const link = $ ( "a" , element ) . first ( ) ;
38
41
const linkId = link . attr ( "href" ) ;
39
42
if ( linkId ) {
43
+ const chapParts = link . text ( ) . split ( "." ) ;
40
44
chapters . push ( createChapter ( {
41
- chapNum : Number ( link . text ( ) . split ( "." ) [ 0 ] ) ,
45
+ chapNum : Number ( chapParts [ 0 ] ) ,
42
46
id : linkId . replace ( base + "/comic_chapters/" , "" ) ,
43
47
langCode : LanguageCode . ENGLISH ,
44
48
mangaId : mangaId ,
45
49
time : new Date ( $ ( "small" , element ) . first ( ) . text ( ) ) ,
50
+ name : chapParts [ 1 ] || undefined
46
51
} ) )
47
52
}
48
53
} )
@@ -56,14 +61,9 @@ export class RainOfSnowParser {
56
61
}
57
62
58
63
parseManga ( $ : CheerioStatic , mangaId : string , base : string ) {
59
- const items = $ ( "ul.rat1 li" ) ;
60
64
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 ) => {
67
67
if ( "attribs" in element ) {
68
68
tagList . push ( createTag ( {
69
69
id : element . attribs [ "href" ] . replace ( `${ base } /tag/` , "" ) . slice ( 0 , - 1 ) ,
@@ -73,13 +73,13 @@ export class RainOfSnowParser {
73
73
} ) )
74
74
const chapterList = this . parseChapterList ( $ , mangaId , base )
75
75
const mangaObj : Manga = {
76
- author : $ ( ".n2 " , items . first ( ) ) . text ( ) ,
76
+ author : $ ( "small " , $ ( "ul.vbtcolor1 li" ) . first ( ) ) . text ( ) . trim ( ) ,
77
77
desc : summary ,
78
78
id : mangaId ,
79
- image : $ ( "div.imgbox img" ) . first ( ) . attr ( "src" ) || "" ,
79
+ image : $ ( "img" , $ ( " div.container div.row" ) . first ( ) ) . first ( ) . attr ( "src" ) || "" ,
80
80
rating : 0 ,
81
81
status : MangaStatus . ONGOING ,
82
- titles : [ $ ( "div.container h3 " ) . first ( ) . text ( ) ] ,
82
+ titles : [ $ ( "div.text h2 " ) . first ( ) . text ( ) ] ,
83
83
tags : [ createTagSection ( {
84
84
id : "1" ,
85
85
label : "1" ,
0 commit comments