Skip to content

Commit

Permalink
Fix mangaplus new version (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
YvesPa authored May 27, 2024
1 parent 47575b2 commit 7704617
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/MangaPlus/MangaPlus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const API_URL = 'https://jumpg-webapi.tokyo-cdn.com/api'
const langCode = Language.ENGLISH

export const MangaPlusInfo: SourceInfo = {
version: '2.0.1',
version: '2.0.2',
name: 'MangaPlus',
icon: 'icon.png',
author: 'Rinto-kun',
Expand Down Expand Up @@ -110,7 +110,7 @@ export class MangaPlus implements SearchResultsProviding, MangaProviding, Chapte

async getMangaDetails(mangaId: string): Promise<SourceManga> {
const request = App.createRequest({
url: `${API_URL}/title_detail?title_id=${mangaId}&format=json`,
url: `${API_URL}/title_detailV3?title_id=${mangaId}&format=json`,
method: 'GET'
})

Expand All @@ -122,7 +122,7 @@ export class MangaPlus implements SearchResultsProviding, MangaProviding, Chapte

async getChapters(mangaId: string): Promise<Chapter[]> {
const request = App.createRequest({
url: `${API_URL}/title_detail?title_id=${mangaId}&format=json`,
url: `${API_URL}/title_detailV3?title_id=${mangaId}&format=json`,
method: 'GET'
})

Expand Down Expand Up @@ -242,7 +242,7 @@ export class MangaPlus implements SearchResultsProviding, MangaProviding, Chapte

function latestUpdatesRequest() {
return App.createRequest({
url: `${API_URL}/web/web_homeV3?lang=eng&format=json`,
url: `${API_URL}/web/web_homeV4?lang=eng&format=json`,
method: 'GET'
})
}
Expand All @@ -258,7 +258,7 @@ export class MangaPlus implements SearchResultsProviding, MangaProviding, Chapte

const languages = await getLanguages(this.stateManager)

const results = result.success.webHomeViewV3?.groups
const results = result.success.webHomeViewV4?.groups
.flatMap(ex => ex.titleGroups)
.flatMap(ex => ex.titles)
.map(title => title.title)
Expand Down
12 changes: 8 additions & 4 deletions src/MangaPlus/MangaPlusHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface SuccessResult {
titleDetailView?: TitleDetailView;
mangaViewer?: MangaViewer;
allTitlesViewV2?: AllTitlesViewV2;
webHomeViewV3?: WebHomeViewV3;
webHomeViewV4?: WebHomeViewV4;
featuredTitlesView?: {
contents: [
{
Expand All @@ -38,7 +38,7 @@ interface AllTitlesGroup {
titles: Title[];
}

interface WebHomeViewV3 {
interface WebHomeViewV4 {
groups: UpdatedTitleV2Group[];
}

Expand Down Expand Up @@ -115,6 +115,10 @@ export class TitleDetailView {
nextTimeStamp = 0;
viewingPeriodDescription = '';
nonAppearanceInfo = '';
chapterListGroup: {
firstChapterList: Chapter[] | undefined;
lastChapterList: Chapter[] | undefined;
}[] = [];
firstChapterList: Chapter[] = [];
lastChapterList: Chapter[] = [];
isSimulReleased = false;
Expand Down Expand Up @@ -179,8 +183,8 @@ export class TitleDetailView {
obj.nextTimeStamp = json.nextTimeStamp
obj.viewingPeriodDescription = json.viewingPeriodDescription
obj.nonAppearanceInfo = json.nonAppearanceInfo
obj.firstChapterList = json.firstChapterList?.map(chapter => Object.assign(new Chapter(1, 1, '', 1, 1), chapter))
obj.lastChapterList = json.lastChapterList?.map(chapter => Object.assign(new Chapter(1, 1, '', 1, 1), chapter))
obj.firstChapterList = json.chapterListGroup?.flatMap(a => a.firstChapterList ?? []).map(chapter => Object.assign(new Chapter(1, 1, '', 1, 1), chapter))
obj.lastChapterList = json.chapterListGroup?.flatMap(a => a.lastChapterList ?? []).map(chapter => Object.assign(new Chapter(1, 1, '', 1, 1), chapter))

return obj
}
Expand Down

0 comments on commit 7704617

Please sign in to comment.