From 11042d46ea791490a6e33560ec83ac4c05b76503 Mon Sep 17 00:00:00 2001 From: pisshammy <165633434+hammyo-o@users.noreply.github.com> Date: Wed, 11 Dec 2024 08:40:50 -0600 Subject: [PATCH] NHentai | Fixed IMG urls (#63) * NHentai | Fixed IMG urls and added homepage popular monthly and all time sections * version update * Actually bruh moment --------- Co-authored-by: TheNetsky <56271887+TheNetsky@users.noreply.github.com> --- src/NHentai/NHentai.ts | 26 +++++++++++++++++++++++++- src/NHentai/NHentaiInterfaces.ts | 4 ++-- src/NHentai/NHentaiParser.ts | 10 +++++----- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/NHentai/NHentai.ts b/src/NHentai/NHentai.ts index cba262a..c06749c 100644 --- a/src/NHentai/NHentai.ts +++ b/src/NHentai/NHentai.ts @@ -43,7 +43,7 @@ import { popularTags } from './tags.json' const NHENTAI_URL = 'https://nhentai.net' export const NHentaiInfo: SourceInfo = { - version: '4.0.8', + version: '4.0.9', name: 'nhentai', icon: 'icon.png', author: 'NotMarek & Netsky', @@ -236,6 +236,30 @@ 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-month`, + method: 'GET' + }), + sectionID: App.createHomeSection({ + id: 'popular-month', + title: 'Popular Monthly', + 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 + }) } ] diff --git a/src/NHentai/NHentaiInterfaces.ts b/src/NHentai/NHentaiInterfaces.ts index 5a53201..7ee3e97 100644 --- a/src/NHentai/NHentaiInterfaces.ts +++ b/src/NHentai/NHentaiInterfaces.ts @@ -1,6 +1,6 @@ export interface ImagePageObject { - t: 'j' | 'p' | 'g';// JPG (≧◡≦) + t: 'j' | 'p' | 'g' | 'w';// JPG (≧◡≦) w: number; h: number; } @@ -107,5 +107,5 @@ export interface QueryResponse { export interface RequestMetadata { nextPage?: number; maxPages?: number; - sort: 'popular-today' | 'popular-week' | 'popular' | ''; + sort: 'popular-today' | 'popular-week' | 'popular-month' | 'popular' | ''; } \ No newline at end of file diff --git a/src/NHentai/NHentaiParser.ts b/src/NHentai/NHentaiParser.ts index 84ef906..cf7fb05 100644 --- a/src/NHentai/NHentaiParser.ts +++ b/src/NHentai/NHentaiParser.ts @@ -31,10 +31,10 @@ export const parseMangaDetails = (data: Gallery): SourceManga => { titles: Object.values(data.title).filter(title => title !== null), artist: artist, author: artist, - image: `https://t.nhentai.net/galleries/${data.media_id}/cover.${typeOfImage(data.images.cover)}`, + image: `https://t3.nhentai.net/galleries/${data.media_id}/cover.${typeOfImage(data.images.cover)}`, status: 'Completed', tags: [App.createTagSection({ id: 'tags', label: 'Tags', tags: tags })], - desc: `Pages: ${data.num_pages}` + desc: `Pages: ${data.num_pages} | Favorites: ${data.num_favorites}` }) }) } @@ -55,7 +55,7 @@ export const parseChapterDetails = (data: Gallery, mangaId: string): ChapterDeta mangaId: mangaId, pages: data.images.pages.map((image, i) => { const type = typeOfImage(image) - return `https://i.nhentai.net/galleries/${data.media_id}/${i + 1}.${type}` + return `https://i4.nhentai.net/galleries/${data.media_id}/${i + 1}.${type}` }) }) } @@ -73,10 +73,10 @@ export const parseSearch = (data: QueryResponse): PartialSourceManga[] => { if (collectedIds.includes(gallery.id.toString())) continue tiles.push(App.createPartialSourceManga({ - image: `https://t.nhentai.net/galleries/${gallery.media_id}/cover.${typeOfImage(gallery.images.cover)}`, + image: `https://t3.nhentai.net/galleries/${gallery.media_id}/cover.${typeOfImage(gallery.images.cover)}`, title: gallery.title.pretty, mangaId: gallery.id.toString(), - subtitle: NHLanguages.getName(getLanguage(gallery)) + subtitle: NHLanguages.getName(getLanguage(gallery)).substring(0, 3) + ' | Pgs: ' + gallery.num_pages })) collectedIds.push(gallery.id.toString()) }