diff --git a/src/NHentai/NHentaiHelper.ts b/src/NHentai/NHentaiHelper.ts index 4d3d1d5..aa52681 100644 --- a/src/NHentai/NHentaiHelper.ts +++ b/src/NHentai/NHentaiHelper.ts @@ -87,6 +87,12 @@ class NHSortOrderClass { name: 'Most Recent', NHCode: 'date', shortcuts: ['s:r', 's:recent', 'sort:r', 'sort:recent'] + }, + { + // Sort by popular this month + name: 'Popular This Month', + NHCode: 'popular-month', + shortcuts: ['s:pm', 's:m', 's:popular-month', 'sort:pm', 'sort:m', 'sort:popular-month'] } ] diff --git a/src/NHentai/NHentaiParser.ts b/src/NHentai/NHentaiParser.ts index cf7fb05..6b636e9 100644 --- a/src/NHentai/NHentaiParser.ts +++ b/src/NHentai/NHentaiParser.ts @@ -3,7 +3,8 @@ import { ChapterDetails, PartialSourceManga, Tag, - Chapter + Chapter, + SourceStateManager } from '@paperback/types' import { NHLanguages } from './NHentaiHelper' @@ -60,18 +61,17 @@ export const parseChapterDetails = (data: Gallery, mangaId: string): ChapterDeta }) } -export const parseSearch = (data: QueryResponse): PartialSourceManga[] => { +export const parseSearch = (data: QueryResponse, readMangaIds: string[]): PartialSourceManga[] => { const tiles: PartialSourceManga[] = [] const collectedIds: string[] = [] if (!data?.result) { console.log(JSON.stringify(data)) - throw new Error('JSON NO RESULT ERROR!\n\nYou\'ve like set too many additional arguments in this source\'s settings, remove some to see results!\nSo search with tags you need to use arguments like shown in the sourc\'s settings!') + throw new Error('JSON NO RESULT ERROR!\n\nYou\'ve like set too many additional arguments in this source\'s settings, remove some to see results!\nSo search with tags you need to use arguments like shown in the source\'s settings!') } for (const gallery of data.result) { - - if (collectedIds.includes(gallery.id.toString())) continue + if (collectedIds.includes(gallery.id.toString()) || readMangaIds.includes(gallery.id.toString())) continue tiles.push(App.createPartialSourceManga({ image: `https://t3.nhentai.net/galleries/${gallery.media_id}/cover.${typeOfImage(gallery.images.cover)}`, title: gallery.title.pretty, @@ -83,11 +83,17 @@ export const parseSearch = (data: QueryResponse): PartialSourceManga[] => { return tiles } +export const addToReadMangaIds = async (stateManager: SourceStateManager, mangaId: string): Promise => { + const readMangaIds = await stateManager.retrieve('read_manga_ids') ?? {} + readMangaIds[mangaId] = true + await stateManager.store('read_manga_ids', readMangaIds) +} + // Utility function capitalizeTags(str: string) { return str.split(' ').map(word => { return word.charAt(0).toUpperCase() + word.slice(1) - }).join(' ') + }).join(' ') } const typeMap: { [key: string]: string; } = { 'j': 'jpg', 'p': 'png', 'g': 'gif', 'w': 'webp'} @@ -96,6 +102,7 @@ const typeOfImage = (image: ImagePageObject): string => { return typeMap[image.t] ?? '' } + const getArtist = (gallery: Gallery): string => { const tags: TagObject[] = gallery.tags for (const tag of tags) {