Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into 0.8
  • Loading branch information
TheNetsky committed Jun 16, 2024
2 parents 48e78ad + 7704617 commit e0f20be
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 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
21 changes: 6 additions & 15 deletions src/NHentai/NHentai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
TagSection
} from '@paperback/types'

import { NHSortOrders } from './NHentaiHelper'
import { hasNoResults, NHSortOrders } from './NHentaiHelper'

import {
parseMangaDetails,
Expand All @@ -43,7 +43,7 @@ import { popularTags } from './tags.json'
const NHENTAI_URL = 'https://nhentai.net'

export const NHentaiInfo: SourceInfo = {
version: '4.0.6',
version: '4.0.7',
name: 'nhentai',
icon: 'icon.png',
author: 'NotMarek & Netsky',
Expand Down Expand Up @@ -236,20 +236,7 @@ export class NHentai implements SearchResultsProviding, MangaProviding, ChapterP
containsMoreItems: true,
type: HomeSectionType.singleRowNormal
})
},
{
request: App.createRequest({
url: `${NHENTAI_URL}/api/galleries/search?query=${await this.generateQuery()}&sort=popular`,
method: 'GET'
}),
sectionID: App.createHomeSection({
id: 'popular',
title: 'Popular All-Time',
containsMoreItems: true,
type: HomeSectionType.singleRowNormal
})
}

]

const promises: Promise<void>[] = []
Expand All @@ -261,7 +248,11 @@ export class NHentai implements SearchResultsProviding, MangaProviding, ChapterP
.then(response => {
this.CloudFlareError(response.status)
const jsonData = this.parseJson(response)
if (hasNoResults(jsonData)) {
return
}
section.sectionID.items = parseSearch(jsonData)

sectionCallback(section.sectionID)
})
)
Expand Down
10 changes: 10 additions & 0 deletions src/NHentai/NHentaiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,13 @@ class NHSortOrderClass {
}

export const NHSortOrders = new NHSortOrderClass()

export function hasNoResults(data: any): boolean {
console.log(data)
if (data.error) {
console.error(data.error)
return true
}

return false
}

0 comments on commit e0f20be

Please sign in to comment.