Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9da0bdd

Browse files
committed
Better parsing
1 parent2eadad8 commit9da0bdd

File tree

2 files changed

+91
-3
lines changed

2 files changed

+91
-3
lines changed

‎src/CatManga/CatManga.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const BASE = "https://catmanga.org"
1515

1616
exportconstCatMangaInfo:SourceInfo={
1717
icon:"icon.png",
18-
version:"1.0.2",
18+
version:"1.1.0",
1919
name:"CatManga",
2020
author:"PythonCoderAS",
2121
authorWebsite:"https://github.com/PythonCoderAS",

‎src/CatManga/CatMangaParser.ts‎

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,39 @@ export class CatMangaParser {
7070
return[];
7171
}
7272

73-
parseChapterList($:CheerioStatic,mangaId:string){
73+
parseChapterList($:CheerioStatic,mangaId:string){
74+
constchapters=[]
75+
constjson=JSON.parse($("script#__NEXT_DATA__").html()||"{}");
76+
if(json){
77+
constprops=json.props;
78+
if(props){
79+
constpageProps=props.pageProps;
80+
if(pageProps){
81+
constseries=pageProps.series;
82+
if(series&&series.chapters&&(series.chapters.length||0)>0){
83+
for(leti=0;i<series.chapters.length;i++){
84+
constchapter=series.chapters[i];
85+
if(chapter.number){
86+
chapters.push(createChapter({
87+
chapNum:chapter.number,
88+
id:String(chapter.number),
89+
langCode:LanguageCode.ENGLISH,
90+
mangaId:mangaId,
91+
name:chapter.title,
92+
group:(chapter.groups||[]).join(", ")
93+
}))}
94+
}
95+
if(chapters.length>0){
96+
returnchapters;
97+
}
98+
}
99+
}
100+
}
101+
}
102+
returnthis.parseChapterListFallback($,mangaId);
103+
}
104+
105+
parseChapterListFallback($:CheerioStatic,mangaId:string){
74106
constchapters:Chapter[]=[];
75107
$('a[class^="chaptertile_element"]').map((index,element)=>{
76108
constchapNumString=$("p",element).first().text().replace("Chapter ","")
@@ -91,7 +123,63 @@ export class CatMangaParser {
91123
returnchapters
92124
}
93125

94-
parseManga($:CheerioStatic,mangaId:string){
126+
parseManga($:CheerioStatic,mangaId:string){
127+
constjson=JSON.parse($("script#__NEXT_DATA__").html()||"{}");
128+
if(json){
129+
constprops=json.props;
130+
if(props){
131+
constpageProps=props.pageProps;
132+
if(pageProps){
133+
constseries=pageProps.series;
134+
if(series&&series.genres&&(series.genres.length||0)>0&&series.title&&series.decription&&series.status&&series.cover_art&&series.conver_art.source){
135+
lettitles=[series.title]
136+
constcovers=[];
137+
consttags=[]
138+
if(series.alt_titles){
139+
titles=titles.concat(series.alt_titles)
140+
}
141+
if(series.all_covers){
142+
for(leti=0;i<series.all_covers.length;i++){
143+
constcover=series.all_covers[i];
144+
covers.push(`https://images.catmanga.org${cover.source||""}`)
145+
}
146+
}
147+
letstatus;
148+
if((series.status||"").toLowerCase().includes("ongoing")){
149+
status=MangaStatus.ONGOING;
150+
}else{
151+
status=MangaStatus.COMPLETED;
152+
}
153+
for(leti=0;i<series.genres.length;i++){
154+
consttag=series.genres[i];
155+
tags.push(createTag({
156+
id:tag,
157+
label:tag
158+
}))
159+
}
160+
returncreateManga({
161+
author:(series.authors||[]).join(", "),
162+
covers:covers,
163+
desc:series.description,
164+
id:mangaId,
165+
image:series.cover_art.source,
166+
rating:0,
167+
status:status,
168+
tags:[createTagSection({
169+
id:"genres",
170+
label:"Genres",
171+
tags:tags
172+
})],
173+
titles:titles
174+
})
175+
}
176+
}
177+
}
178+
}
179+
returnthis.parseMangaFallback($,mangaId);
180+
}
181+
182+
parseMangaFallback($:CheerioStatic,mangaId:string){
95183
consttags:Tag[]=[];
96184
$('div[class^="series_tags"] p').map((index,element)=>{
97185
consttext=$(element).text().trim();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp