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

Commite9e27c2

Browse files
committed
Add VoidScans
1 parent5ac71e8 commite9e27c2

File tree

4 files changed

+258
-1
lines changed

4 files changed

+258
-1
lines changed

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Sources for small scanlation sites.
33

44
#Websites
55
*https://glitchycomics.com/
6-
*https://rainofsnow.com/
6+
*https://rainofsnow.com/
7+
*https://voidscans.net/

‎src/VoidScans/VoidScans.ts‎

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import{
2+
Chapter,
3+
ChapterDetails,
4+
HomeSection,
5+
Manga,MangaTile,
6+
PagedResults,
7+
Request,
8+
SearchRequest,
9+
Source,
10+
SourceInfo,
11+
}from"paperback-extensions-common"
12+
import{VoidScansParser}from"./VoidScansParser";
13+
14+
constBASE="https://voidscans.net"
15+
16+
exportconstVoidScansInfo:SourceInfo={
17+
icon:"icon.png",
18+
version:"1.1.0",
19+
name:"VoidScans",
20+
author:"PythonCoderAS",
21+
authorWebsite:"https://github.com/PythonCoderAS",
22+
description:"Extension that pulls manga from VoidScans",
23+
language:"en",
24+
hentaiSource:false,
25+
websiteBaseURL:BASE
26+
}
27+
28+
exportclassVoidScansextendsSource{
29+
30+
privatereadonlyparser:VoidScansParser=newVoidScansParser();
31+
32+
getMangaShareUrl(mangaId:string):string|null{
33+
return`${BASE}/library/${mangaId}`;
34+
}
35+
36+
asyncgetHomePageSections(sectionCallback:(section:HomeSection)=>void):Promise<void>{
37+
sectionCallback(createHomeSection({
38+
id:"1",
39+
items:(awaitthis.getWebsiteMangaDirectory(null)).results,
40+
title:"All Manga"
41+
}));
42+
}
43+
44+
asyncgetWebsiteMangaDirectory(metadata:any):Promise<PagedResults>{
45+
constoptions:Request=createRequestObject({
46+
url:`${BASE}/library`,
47+
method:'GET'
48+
});
49+
letresponse=awaitthis.requestManager.schedule(options,1);
50+
let$=this.cheerio.load(response.data);
51+
returncreatePagedResults({
52+
results:this.parser.parseMangaList($,BASE)
53+
});
54+
}
55+
56+
asyncgetChapterPage(mangaId:string,chapterId:string,page:number=1):Promise<string|null>{
57+
constoptions:Request=createRequestObject({
58+
url:`${BASE}/read/${mangaId}/${chapterId}/${page}`,
59+
method:'GET'
60+
});
61+
letresponse=awaitthis.requestManager.schedule(options,1);
62+
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){
71+
pages.push(page)
72+
page=awaitthis.getChapterPage(mangaId,chapterId,num);
73+
num++;
74+
}
75+
returncreateChapterDetails({
76+
id:chapterId,
77+
longStrip:true,
78+
mangaId:mangaId,
79+
pages:pages
80+
})
81+
}
82+
83+
asyncgetChapters(mangaId:string):Promise<Chapter[]>{
84+
constoptions:Request=createRequestObject({
85+
url:`${BASE}/library/${mangaId}`,
86+
method:'GET'
87+
});
88+
letresponse=awaitthis.requestManager.schedule(options,1);
89+
let$=this.cheerio.load(response.data);
90+
returnthis.parser.parseChapterList($,mangaId);
91+
}
92+
93+
asyncgetMangaDetails(mangaId:string):Promise<Manga>{
94+
constoptions:Request=createRequestObject({
95+
url:`${BASE}/library/${mangaId}`,
96+
method:'GET'
97+
});
98+
letresponse=awaitthis.requestManager.schedule(options,1);
99+
let$=this.cheerio.load(response.data);
100+
returnthis.parser.parseManga($,mangaId);
101+
}
102+
103+
asyncsearchRequest(query:SearchRequest,metadata:any):Promise<PagedResults>{
104+
// TODO: Wait for search to be implemented on the website.
105+
constresults=(awaitthis.getWebsiteMangaDirectory(null)).results;
106+
constdata:MangaTile[]=[];
107+
for(leti=0;i<results.length;i++){
108+
constkey=results[i];
109+
if(query.title){
110+
if((key.primaryText?.text||"").toLowerCase().includes((query.title.toLowerCase()))){
111+
data.push(key);
112+
}
113+
}
114+
}
115+
returncreatePagedResults({
116+
results:data
117+
});
118+
}
119+
}

‎src/VoidScans/VoidScansParser.ts‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import{Chapter,LanguageCode,Manga,MangaStatus,MangaTile}from"paperback-extensions-common";
2+
3+
exportclassVoidScansParser{
4+
parseMangaList($:CheerioStatic,base:string){
5+
constmangaTiles:MangaTile[]=[];
6+
$("div.col").map((index,element)=>{
7+
constlink=$("a.btn",element);
8+
constlinkId=link.attr("href");
9+
if(linkId){
10+
mangaTiles.push(createMangaTile({
11+
id:linkId.replace(`${base}/library/`,""),
12+
title:createIconText({
13+
text:""
14+
}),
15+
image:$("img",element).attr("src")||"",
16+
primaryText:createIconText({
17+
text:$("p.card-text",element).text()
18+
})
19+
}))
20+
}
21+
})
22+
returnmangaTiles;
23+
}
24+
25+
parsePage($:CheerioStatic):string|null{
26+
return$("img").attr("src")||null;
27+
}
28+
29+
parseChapterList($:CheerioStatic,mangaId:string){
30+
constchapters:Chapter[]=[];
31+
$("ul.list-group").first().children().map((index,element)=>{
32+
constlink=$(element).first();
33+
constchapNum=Number(link.text().replace("Chapter ",""));
34+
constdata:Chapter={
35+
chapNum:chapNum,
36+
id:String(chapNum),
37+
langCode:LanguageCode.ENGLISH,
38+
mangaId:mangaId,
39+
}
40+
chapters.push(createChapter(data))
41+
})
42+
returnchapters
43+
}
44+
45+
parseManga($:CheerioStatic,mangaId:string){
46+
constmangaObj:Manga={
47+
desc:$("p").first().text().trim(),
48+
id:mangaId,
49+
image:$("img#manga-img").attr("src")||"",
50+
rating:0,
51+
status:MangaStatus.ONGOING,
52+
titles:[$("h1").first().text()],
53+
}
54+
returncreateManga(mangaObj)
55+
}
56+
57+
}

‎src/tests/VoidScans.test.ts‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
importcheeriofrom"cheerio";
2+
import{VoidScans}from"../VoidScans/VoidScans";
3+
import{APIWrapper,Source}from"paperback-extensions-common";
4+
5+
describe("VoidScans Tests",function(){
6+
letwrapper:APIWrapper=newAPIWrapper();
7+
letsource:Source=newVoidScans(cheerio);
8+
letchai=require("chai"),
9+
expect=chai.expect;
10+
letchaiAsPromised=require("chai-as-promised");
11+
chai.use(chaiAsPromised);
12+
13+
letmangaId="2";
14+
15+
it("Retrieve Manga Details",async()=>{
16+
letdetails=awaitwrapper.getMangaDetails(source,mangaId);
17+
expect(
18+
details,
19+
"No results found with test-defined ID ["+mangaId+"]"
20+
).to.exist;
21+
22+
// Validate that the fields are filled
23+
letdata=details;
24+
expect(data.id,"Missing ID").to.be.not.empty;
25+
expect(data.image,"Missing Image").to.exist;
26+
expect(data.status,"Missing Status").to.exist;
27+
expect(data.titles,"Missing Titles").to.be.not.empty;
28+
expect(data.rating,"Missing Rating").to.exist;
29+
expect(data.desc,"Missing Description").to.be.not.empty;
30+
});
31+
32+
it("Get Chapters",async()=>{
33+
letdata=awaitwrapper.getChapters(source,mangaId);
34+
35+
expect(data,"No chapters present for: ["+mangaId+"]").to.not.be.empty;
36+
37+
letentry=data[0];
38+
expect(entry.id,"No ID present").to.not.be.empty;
39+
expect(entry.chapNum,"No chapter number present").to.exist;
40+
});
41+
42+
it("Get Chapter Details",async()=>{
43+
letchapters=awaitwrapper.getChapters(source,mangaId);
44+
letdata=awaitwrapper.getChapterDetails(source,mangaId,chapters[0].id);
45+
46+
expect(data,"Empty server response").to.not.be.empty;
47+
48+
expect(data.id,"Missing ID").to.be.not.empty;
49+
expect(data.mangaId,"Missing MangaID").to.be.not.empty;
50+
expect(data.pages,"No pages present").to.be.not.empty;
51+
});
52+
53+
it("Testing search",async()=>{
54+
lettestSearch=createSearchRequest({
55+
title:"Son",
56+
});
57+
58+
letsearch=awaitwrapper.searchRequest(source,testSearch);
59+
letresult=search.results[0];
60+
61+
expect(result,"No response from server").to.exist;
62+
63+
expect(result.id,"No ID found for search query").to.be.not.empty;
64+
expect(result.title,"No title").to.be.not.empty;
65+
});
66+
67+
it("Testing Home Page",async()=>{
68+
letresult=awaitwrapper.getHomePageSections(source);
69+
expect(result,"No response from server").to.exist;
70+
letitem=result[0];
71+
expect(item,"Empty response from server").to.exist;
72+
if(item.items){
73+
letsubitem=item.items[0];
74+
75+
expect(subitem.id,"No ID found for homepage item").to.not.be.empty;
76+
expect(subitem.title,"No Title found for homepage item").to.not.be.empty;
77+
expect(subitem.image,"No Image found for homepage item").to.not.be.empty;
78+
}
79+
})
80+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp