Skip to content

Commit

Permalink
Update MangaPlus connector
Browse files Browse the repository at this point in the history
  • Loading branch information
viliml committed Jun 8, 2024
1 parent 2d4a872 commit 85b13b6
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/web/mjs/connectors/ShueishaMangaPlus.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class ShueishaMangaPlus extends Publus {

async _getMangaFromURI(uri) {
let id = uri.pathname.match(/\/(\d+)$/)[1];
uri = new URL('/api/title_detail', this.apiURL);
uri = new URL('/api/title_detailV3', this.apiURL);
uri.searchParams.set('title_id', id);
let request = new Request(uri, this.requestOptions);
let data = await this.fetchPROTO(request, this.protoTypes, this.rootType);
Expand All @@ -33,31 +33,32 @@ export default class ShueishaMangaPlus extends Publus {
}

async _getMangas() {
let request = new Request(new URL('/api/title_list/all', this.apiURL), this.requestOptions);
let request = new Request(new URL('/api/title_list/allV2', this.apiURL), this.requestOptions);
let data = await this.fetchPROTO(request, this.protoTypes, this.rootType);
return data.success.allTitlesView.titles.map(manga => {
return data.success.allTitlesViewV2.allTitlesGroup.flatMap(mangaGroup => mangaGroup.titles.map(manga => {
return {
id: manga.titleId,
title: `${manga.name} ${this._getLanguage(manga.language)}`
};
});
}));
}

async _getChapters(manga) {
let uri = new URL('/api/title_detail', this.apiURL);
let uri = new URL('/api/title_detailV3', this.apiURL);
uri.searchParams.set('title_id', manga.id);
let request = new Request(uri, this.requestOptions);
let data = await this.fetchPROTO(request, this.protoTypes, this.rootType);
return [
...data.success.titleDetailView.firstChapterList || [],
...data.success.titleDetailView.lastChapterList || []
return data.success.titleDetailView.chapterListGroup.flatMap(chapterGroup => [
...chapterGroup.firstChapterList || [],
...chapterGroup.midChapterList || [],
...chapterGroup.lastChapterList || []
].map(chapter => {
return {
id: chapter.chapterId,
title: chapter.subTitle || chapter.name,
language: ''
};
}).reverse();
})).reverse();
}

async _getPages(chapter) {
Expand Down
59 changes: 58 additions & 1 deletion src/web/mjs/connectors/ShueishaMangaPlus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Based on: https://mangaplus.shueisha.co.jp/js/app.a3091b24.js

package MangaPlus;
syntax = "proto3";
//syntax = "proto3";

message AdNetworkList {
repeated AdNetwork adNetworks = 1;
Expand Down Expand Up @@ -193,6 +193,28 @@ message AllTitlesView {
repeated Title titles = 1;
}

message Tag {
optional string tag = 1;
optional string slug = 2;
}

message Label {
optional int32 label = 1;
optional string description = 2;
}

message AllTitlesGroup {
optional string theTitle = 1;
repeated Title titles = 2;
repeated Tag tags = 3;
repeated Label labels = 4;
optional uint32 nextChapterStartTimestamp = 5;
}

message AllTitlesViewV2 {
repeated AllTitlesGroup allTitlesGroup = 1;
}

message CommentListView {
repeated Comment comments = 1;
optional bool ifSetUserName = 2;
Expand Down Expand Up @@ -274,6 +296,22 @@ message SubscribedTitlesView {
}

message TitleDetailView {
// message PublisherItem {
// TODO
// }
message ChapterGroup {
optional string chapterNumbers = 1;
repeated Chapter firstChapterList = 2;
repeated Chapter midChapterList = 3;
repeated Chapter lastChapterList = 4;
}
// message TitleLanguages {
// TODO
// }
// message TitleLabels {
// TODO
// }

optional Title title = 1;
optional string titleImageUrl = 2;
optional string overview = 3;
Expand All @@ -292,6 +330,24 @@ message TitleDetailView {
optional int32 rating = 16;
optional bool chaptersDescending = 17;
optional uint32 numberOfViews = 18;
// repeated PublisherItem publisherItems = 19;
repeated Banner titleBanners = 20;
// optional UserTickets userTickets = 21;
repeated Chapter ticketChapterList = 22;
repeated Title ticketTitleList = 23;
optional bool hasChaptersBetween = 24;
optional Banner publisherBanner = 25;
optional AdNetworkList advertisement = 26;
// repeated TitleLanguages titleLanguages = 27;
repeated ChapterGroup chapterListGroup = 28;
// optional FreeViewDialogue freeViewDialogue = 29;
optional string regionCode = 30;
repeated Tag tags = 31;
// optional TitleLabels titleLabels = 32;
// optional Subscription subscription = 33;
optional Label label = 34;
optional bool isFirstTimeFree = 35;
// optional MetaInfo metaInfo = 36;
}

message TitleRankingView {
Expand Down Expand Up @@ -332,6 +388,7 @@ message SuccessResult {
optional ServiceAnnouncementsView serviceAnnouncementsView = 15;
optional InitialView initialView = 16;
optional FeedbackView feedbackView = 17;
optional AllTitlesViewV2 allTitlesViewV2 = 25;
}

message WebHomeView {
Expand Down

0 comments on commit 85b13b6

Please sign in to comment.