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

Commit2a12325

Browse files
committed
VoidScans fixes
1 parentd220999 commit2a12325

File tree

3 files changed

+63
-19
lines changed

3 files changed

+63
-19
lines changed

‎src/VoidScans/VoidScans.ts‎

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const BASE = "https://voidscans.net"
1515

1616
exportconstVoidScansInfo:SourceInfo={
1717
icon:"icon.svg",
18-
version:"1.2.1",
18+
version:"1.3.0",
1919
name:"VoidScans",
2020
author:"PythonCoderAS",
2121
authorWebsite:"https://github.com/PythonCoderAS",
@@ -53,25 +53,14 @@ export class VoidScans extends Source {
5353
});
5454
}
5555

56-
asyncgetChapterPage(mangaId:string,chapterId:string,page:number=1):Promise<string|null>{
56+
asyncgetChapterDetails(mangaId:string,chapterId:string):Promise<ChapterDetails>{
5757
constoptions:Request=createRequestObject({
58-
url:`${BASE}/read/${mangaId}/${chapterId}/${page}`,
58+
url:`${BASE}/read/${mangaId}/${chapterId}`,
5959
method:'GET'
6060
});
6161
letresponse=awaitthis.requestManager.schedule(options,1);
6262
let$=this.cheerio.load(response.data);
63-
returnthis.parser.parsePage($)
64-
}
65-
66-
asyncgetChapterDetails(mangaId:string,chapterId:string):Promise<ChapterDetails>{
67-
constpages:string[]=[];
68-
letpage=awaitthis.getChapterPage(mangaId,chapterId);
69-
letnum=2;
70-
while(page&&!pages.includes(page)){
71-
pages.push(page)
72-
page=awaitthis.getChapterPage(mangaId,chapterId,num);
73-
num++;
74-
}
63+
constpages=this.parser.parsePages($)
7564
returncreateChapterDetails({
7665
id:chapterId,
7766
longStrip:true,
@@ -119,8 +108,14 @@ export class VoidScans extends Source {
119108

120109

121110
asyncfilterUpdatedManga(mangaUpdatesFoundCallback:(updates:MangaUpdates)=>void,time:Date,ids:string[]):Promise<void>{
111+
constoptions:Request=createRequestObject({
112+
url:`${BASE}`,
113+
method:'GET'
114+
});
115+
letresponse=awaitthis.requestManager.schedule(options,1);
116+
let$=this.cheerio.load(response.data);
122117
mangaUpdatesFoundCallback(createMangaUpdates({
123-
ids:ids
118+
ids:this.parser.parseUpdatedManga($,BASE,time)
124119
}));
125120
}
126121
}

‎src/VoidScans/VoidScansParser.ts‎

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class VoidScansParser {
1010
mangaTiles.push(createMangaTile({
1111
id:linkId.replace(`${base}/library/`,""),
1212
title:createIconText({
13-
text:""
13+
text:$("h2",element).text()
1414
}),
1515
image:$("img",element).attr("src")||"",
1616
primaryText:createIconText({
@@ -22,8 +22,50 @@ export class VoidScansParser {
2222
returnmangaTiles;
2323
}
2424

25-
parsePage($:CheerioStatic):string|null{
26-
return$("img").attr("src")||null;
25+
parseUpdatedManga($:CheerioStatic,base:string,dateToCheck:Date){
26+
constids:string[]=[];
27+
$("div.col").map((index,element)=>{
28+
constlink=$("a.btn",element);
29+
constlinkId=link.attr("href");
30+
if(linkId){
31+
constdateUpdated=$("small.text-muted").text();
32+
constparts=dateUpdated.split(" ");
33+
if(parts.length===2){
34+
constdate=parts[0];
35+
constdateParts=date.split("/");
36+
letday=0,month=0,year=0;
37+
if(dateParts.length===3){
38+
year=Number(dateParts[0]);
39+
month=Number(dateParts[1])-1;
40+
day=Number(dateParts[2]);
41+
}
42+
consttime=parts[1];
43+
consttimeParts=time.split("/");
44+
letsecond=0,minute=0,hour=0;
45+
if(timeParts.length===3){
46+
hour=Number(timeParts[0])
47+
minute=Number(timeParts[1])
48+
second=Number(timeParts[2])
49+
constdateObj=newDate(Date.UTC(year,month,day,hour,minute,second));
50+
if(dateObj>dateToCheck){
51+
ids.push(linkId.replace(`${base}/library/`,""))
52+
}
53+
}
54+
}
55+
}
56+
})
57+
returnids;
58+
}
59+
60+
parsePages($:CheerioStatic):string[]{
61+
constpages:string[]=[];
62+
$("div[data-image]").map((index,element)=>{
63+
consturl=element.attribs["data-image"];
64+
if(url){
65+
pages.push(url);
66+
}
67+
})
68+
returnpages;
2769
}
2870

2971
parseChapterList($:CheerioStatic,mangaId:string){

‎src/tests/VoidScans.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,11 @@ describe("VoidScans Tests", function () {
7777
expect(subitem.image,"No Image found for homepage item").to.not.be.empty;
7878
}
7979
})
80+
81+
it("Testing Notifications",async()=>{
82+
letupdates=awaitwrapper.filterUpdatedManga(source,newDate("2021-1-27"),[mangaId])
83+
expect(updates,"No server response").to.exist
84+
expect(updates,"Empty server response").to.not.be.empty
85+
expect(updates[0],"No updates").to.not.be.empty;
86+
})
8087
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp