Skip to content

Commit

Permalink
Fix ComicZerosum : no more Speedbind (#6230)
Browse files Browse the repository at this point in the history
* Fix ComicZerosum : from Speedbind to protobuf

Fixes #6222

* Update ComicZerosum.proto

* Update ComicZerosum.mjs
  • Loading branch information
MikeZeDev authored and Sheepux committed Jan 2, 2024
1 parent 598c071 commit 56b6b95
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 17 deletions.
60 changes: 43 additions & 17 deletions src/web/mjs/connectors/ComicZerosum.mjs
Original file line number Diff line number Diff line change
@@ -1,37 +1,63 @@
import SpeedBinb from './templates/SpeedBinb.mjs';
import Connector from '../engine/Connector.mjs';
import Manga from '../engine/Manga.mjs';

export default class ComicZerosum extends SpeedBinb {
export default class ComicZerosum extends Connector {

constructor() {
super();
super.id = 'comiczerosum';
super.label = 'Comic ゼロサム (Comic ZEROSUM)';
this.tags = ['manga', 'japanese'];
this.url = 'https://online.ichijinsha.co.jp/zerosum';
this.data_url = 'https://online.ichijinsha.co.jp/json/zerosum';
this.url = 'https://zerosumonline.com';
this.api_url = 'https://api.zerosumonline.com/api/v1/';
this.protoTypes = '/mjs/connectors/ComicZerosum.proto';

}

async _getMangas() {
const request = new Request(`${this.data_url}/list/name.json`, this.requestOptions);
const data = await this.fetchJSON(request);
async _getMangaFromURI(uri) {
//'https://api.zerosumonline.com/api/v1/title?tag=
const mangaid = uri.href.match(/\/detail\/([\w]+)/)[1];
const requri = new URL(`title?tag=${mangaid}`, this.api_url);
const responseType = 'ComicZerosum.TitleView';
const request = new Request(requri, this.requestOptions);
const data = await this.fetchPROTO(request, this.protoTypes, responseType);
return new Manga(this, data.title.tag, data.title.name);
}

return data.Stories.map(story => {
async _getMangas() {
const uri = new URL('list?category=series&sort=date', this.api_url);
const responseType = 'ComicZerosum.Listview';
const request = new Request (uri, this.requestOptions);
const data = await this.fetchPROTO(request, this.protoTypes, responseType);
return data.titles.map(element => {
return {
id: story.Work.Tag,
title: story.Work.Name
id: element.tag,
title : element.name.trim()
};
});
}

async _getChapters(manga) {
const request = new Request(`${this.data_url}/works/${manga.id}.json`, this.requestOptions);
const data = await this.fetchJSON(request);

return data.Work.Stories.map(story => {
const uri = new URL(`title?tag=${manga.id}`, this.api_url);
const responseType = 'ComicZerosum.TitleView';
const request = new Request(uri, this.requestOptions);
const data = await this.fetchPROTO(request, this.protoTypes, responseType);
return data.chapters.map(chapter => {
return {
id: story.Url,
title: story.Name
id: chapter.id,
title: chapter.name.trim()
};
});
}
}

async _getPages(chapter) {
const uri = new URL(`viewer?chapter_id=${chapter.id}`, this.api_url);
const responseType = 'ComicZerosum.MangaViewerView';
const request = new Request(uri, {
method: 'POST',
});
const data = await this.fetchPROTO(request, this.protoTypes, responseType);
return data.pages.filter(page=> page.imageUrl).map(page => page.imageUrl);
}

}
117 changes: 117 additions & 0 deletions src/web/mjs/connectors/ComicZerosum.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package ComicZerosum;
syntax = "proto3";

//Common
message Header {
optional uint32 lastUpdateTime = 1;
optional uint32 nextUpdateTime = 2;
}

//Mangas
message Listview {
optional Header header = 1;
repeated Title titles = 3;
}

message Title {
optional uint32 id = 1;
optional string tag = 2;
optional string name = 3;
optional string nameKana = 4;
optional string author = 5;
optional string authorKana = 6;
optional string description = 7;
optional string imgUrl = 8;
optional uint32 startTime = 9;
optional uint32 endTime = 10;
optional bool fanLetterEnable = 11;
optional bool r18Flag = 12;
optional Genres genres = 13;
optional uint32 lastUpdateTime = 14;
optional uint32 latestChapterId = 15;
}

message Genres {
repeated Genre genre = 1;
}

message Genre {
optional uint32 id = 1;
optional string name = 2;
}

message IndependentBook {
optional uint32 id = 1;
optional uint32 titleId = 2;
optional string name = 3;
optional string imageUrl = 4;
optional uint32 releaseTime = 5;
optional uint32 startTime = 6;
optional uint32 endTime = 7;
optional StoreUrls storeUrls = 8;
}

message StoreUrls {
repeated StoreUrl storeUrl = 1;
}

message StoreUrl {
optional int32 store = 1;
optional string url = 2;
}

//Chapter
message TitleView {
optional Header header = 1;
optional Title title = 2;
repeated Chapter chapters = 3;
repeated IndependentBook independentBooks = 4;
repeated TitleRelatedBanner titleRelatedBanners = 5;
optional Sns sns = 6;
}



message Chapter {
optional uint32 id = 1;
optional string name = 2;
optional string imageUrl = 3;
optional uint32 startTime = 4;
optional uint32 endTime = 5;
optional string nextUpdateTime = 6;
optional bool fanLetterEnabled = 7;
}


message TitleRelatedBanners {
repeated TitleRelatedBanner titleRelatedBanners = 1;
}

message TitleRelatedBanner {
optional string imageUrl = 1;
optional string url = 2;
}

message Sns {
optional string facebook = 1;
optional string twitter = 2;
}

//Pages

message MangaViewerView {
optional int32 status = 1;
optional uint32 titleId = 2;
optional string titleTag = 3;
optional string viewerTitle = 4;
repeated MangaPage pages = 5;
}

message MangaPage {
optional string imageUrl = 1;
optional LastPage lastPage = 2;
}

message LastPage {
optional uint32 t = 1;
}

0 comments on commit 56b6b95

Please sign in to comment.