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

Commit4038bef

Browse files
committed
Doing (get more)s (FixPythonCoderAS#5)
1 parent3a9c570 commit4038bef

File tree

2 files changed

+61
-6
lines changed

2 files changed

+61
-6
lines changed

‎src/RainOfSnow/RainOfSnow.ts‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const BASE = "https://rainofsnow.com"
1515

1616
exportconstRainOfSnowInfo:SourceInfo={
1717
icon:"icon.png",
18-
version:"1.3.3",
18+
version:"1.4.0",
1919
name:"RainOfSnow",
2020
author:"PythonCoderAS",
2121
authorWebsite:"https://github.com/PythonCoderAS",
@@ -95,11 +95,39 @@ export class RainOfSnow extends Source {
9595
});
9696
letresponse=awaitthis.requestManager.schedule(options,1);
9797
let$=this.cheerio.load(response.data);
98+
letmore:boolean=true;
99+
letpages:string[]=this.parser.parsePages($,$("div.bb-item[style=\"display: block;\"]").first().toArray()[0])
100+
letmore_data=this.parser.parseMoreData($);
101+
letoffset;
102+
if(!more_data){
103+
more=false;
104+
}else{
105+
offset=more_data.offset;
106+
}
107+
while(more){
108+
constajax:Request=createRequestObject({
109+
url:`${BASE}/wp-admin/admin-ajax.php`,
110+
method:'POST',
111+
data:Object.entries(this.urlEncodeObject({
112+
action:"my_repeater_show_more",
113+
post_id:Number(more_data?.post_id),
114+
offset:Number(offset),
115+
nonce:more_data?.nonce
116+
})).map(e=>e.join('=')).join('&')
117+
// This is important because otherwise it gives me a 400, and I don't know why
118+
});
119+
letajaxResponse=awaitthis.requestManager.schedule(ajax,1);
120+
letajaxData=typeofajaxResponse.data==="string" ?JSON.parse(ajaxResponse.data) :ajaxResponse.data
121+
let$ajax=this.cheerio.load(ajaxData.content);
122+
pages=pages.concat(this.parser.parsePages($ajax,$ajax.root().toArray()[0]))
123+
more=ajaxData.more;
124+
offset=ajaxData.offset;
125+
}
98126
returncreateChapterDetails({
99127
id:chapterId,
100128
longStrip:true,
101129
mangaId:mangaId,
102-
pages:this.parser.parsePages($)
130+
pages:pages
103131
})
104132
}
105133

‎src/RainOfSnow/RainOfSnowParser.ts‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import{Chapter,LanguageCode,Manga,MangaStatus,MangaTile,Tag}from"paperback-extensions-common";
22

3+
interfacemorePageData{
4+
post_id:string,
5+
offset:string,
6+
nonce:string
7+
}
8+
39
exportclassRainOfSnowParser{
410

511
decodeHTMLEntity(str:string):string{
@@ -30,11 +36,32 @@ export class RainOfSnowParser {
3036
returnmangaTiles;
3137
}
3238

33-
parsePages($:CheerioStatic){
39+
privatestaticrepeater_field_regex(field_name:string){
40+
returnnewRegExp(`(var|let|const) my_repeater_field_${field_name}\\s*=\\s*["'\`]?([^"'\`\\n;]+)["'\`]?`,"i")
41+
}
42+
43+
parseMoreData($:CheerioStatic):morePageData|null{
44+
constdata=$("div.bb-item[style=\"display: block;\"] script").first().html()
45+
if(data){
46+
constpost_id=data.match(RainOfSnowParser.repeater_field_regex("post_id"))
47+
constoffset=data.match(RainOfSnowParser.repeater_field_regex("offset"))
48+
constnonce=data.match(RainOfSnowParser.repeater_field_regex("nonce"))
49+
if(post_id&&offset&&nonce){
50+
return{
51+
post_id:post_id[2],
52+
offset:offset[2],
53+
nonce:nonce[2]
54+
}
55+
}
56+
}
57+
returnnull;
58+
}
59+
60+
parsePages($:CheerioStatic,element:CheerioElement){
3461
constpages:string[]=[];
35-
$("div.bb-item[style=\"display: block;\"]img").map((index,element)=>{
36-
if("attribs"inelement&&element.attribs["src"]){
37-
pages.push(element.attribs["src"])
62+
$("img",element).map((index,element1)=>{
63+
if("attribs"inelement1&&element1.attribs["src"]){
64+
pages.push(element1.attribs["src"])
3865
}
3966
});
4067
returnpages;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp