diff --git a/dist/providers/manga/mangadex.d.ts b/dist/providers/manga/mangadex.d.ts index 9dd0b5fe7..34b92a277 100644 --- a/dist/providers/manga/mangadex.d.ts +++ b/dist/providers/manga/mangadex.d.ts @@ -16,6 +16,10 @@ declare class MangaDex extends MangaParser { * @param limit limit of results to return (default: 20) (max: 100) (min: 1) */ search: (query: string, page?: number, limit?: number) => Promise>; + fetchRandom: () => Promise>; + fetchRecentlyAdded: (page?: number, limit?: number) => Promise>; + fetchLatestUpdates: (page?: number, limit?: number) => Promise>; + fetchPopular: (page?: number, limit?: number) => Promise>; private fetchAllChapters; private fetchCoverImage; } diff --git a/dist/providers/manga/mangadex.js b/dist/providers/manga/mangadex.js index 207381dde..daa3fc49f 100644 --- a/dist/providers/manga/mangadex.js +++ b/dist/providers/manga/mangadex.js @@ -115,6 +115,146 @@ class MangaDex extends models_1.MangaParser { throw new Error(err.message); } }; + this.fetchRandom = async () => { + try { + const res = await this.client.get(`${this.apiUrl}/manga/random`); + if (res.data.result == 'ok') { + const results = { + currentPage: 1, + results: [], + }; + results.results.push({ + id: res.data.data.id, + title: Object.values(res.data.data.attributes.title)[0], + altTitles: res.data.data.attributes.altTitles, + description: Object.values(res.data.data.attributes.description)[0], + status: res.data.data.attributes.status, + releaseDate: res.data.data.attributes.year, + contentRating: res.data.data.attributes.contentRating, + lastVolume: res.data.data.attributes.lastVolume, + lastChapter: res.data.data.attributes.lastChapter, + }); + return results; + } + else { + throw new Error(res.data.message); + } + } + catch (err) { + throw new Error(err.message); + } + }; + this.fetchRecentlyAdded = async (page = 1, limit = 20) => { + if (page <= 0) + throw new Error('Page number must be greater than 0'); + if (limit > 100) + throw new Error('Limit must be less than or equal to 100'); + if (limit * (page - 1) >= 10000) + throw new Error('not enough results'); + try { + const res = await this.client.get(`${this.apiUrl}/manga?includes[]=cover_art&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&order[createdAt]=desc&hasAvailableChapters=true&limit=${limit}&offset=${limit * (page - 1)}`); + if (res.data.result == 'ok') { + const results = { + currentPage: page, + results: [], + }; + for (const manga of res.data.data) { + results.results.push({ + id: manga.id, + title: Object.values(manga.attributes.title)[0], + altTitles: manga.attributes.altTitles, + description: Object.values(manga.attributes.description)[0], + status: manga.attributes.status, + releaseDate: manga.attributes.year, + contentRating: manga.attributes.contentRating, + lastVolume: manga.attributes.lastVolume, + lastChapter: manga.attributes.lastChapter, + }); + } + return results; + } + else { + throw new Error(res.data.message); + } + } + catch (err) { + throw new Error(err.message); + } + }; + this.fetchLatestUpdates = async (page = 1, limit = 20) => { + if (page <= 0) + throw new Error('Page number must be greater than 0'); + if (limit > 100) + throw new Error('Limit must be less than or equal to 100'); + if (limit * (page - 1) >= 10000) + throw new Error('not enough results'); + try { + const res = await this.client.get(`${this.apiUrl}/manga?order[latestUploadedChapter]=desc&limit=${limit}&offset=${limit * (page - 1)}`); + if (res.data.result == 'ok') { + const results = { + currentPage: page, + results: [], + }; + for (const manga of res.data.data) { + results.results.push({ + id: manga.id, + title: Object.values(manga.attributes.title)[0], + altTitles: manga.attributes.altTitles, + description: Object.values(manga.attributes.description)[0], + status: manga.attributes.status, + releaseDate: manga.attributes.year, + contentRating: manga.attributes.contentRating, + lastVolume: manga.attributes.lastVolume, + lastChapter: manga.attributes.lastChapter, + }); + } + return results; + } + else { + throw new Error(res.data.message); + } + } + catch (err) { + throw new Error(err.message); + } + }; + this.fetchPopular = async (page = 1, limit = 20) => { + if (page <= 0) + throw new Error('Page number must be greater than 0'); + if (limit > 100) + throw new Error('Limit must be less than or equal to 100'); + if (limit * (page - 1) >= 10000) + throw new Error('not enough results'); + try { + const res = await this.client.get(`${this.apiUrl}/manga?includes[]=cover_art&includes[]=artist&includes[]=author&order[followedCount]=desc&contentRating[]=safe&contentRating[]=suggestive&hasAvailableChapters=true&limit=${limit}&offset=${limit * (page - 1)}`); + if (res.data.result == 'ok') { + const results = { + currentPage: page, + results: [], + }; + for (const manga of res.data.data) { + results.results.push({ + id: manga.id, + title: Object.values(manga.attributes.title)[0], + altTitles: manga.attributes.altTitles, + description: Object.values(manga.attributes.description)[0], + status: manga.attributes.status, + releaseDate: manga.attributes.year, + contentRating: manga.attributes.contentRating, + lastVolume: manga.attributes.lastVolume, + lastChapter: manga.attributes.lastChapter, + }); + } + return results; + } + else { + throw new Error(res.data.message); + } + } + catch (err) { + throw new Error(err.message); + } + }; this.fetchAllChapters = async (mangaId, offset, res) => { var _a, _b; if (((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.offset) + 96 >= ((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.total)) { diff --git a/dist/providers/manga/mangadex.js.map b/dist/providers/manga/mangadex.js.map index 9bebb012f..a6de8b073 100644 --- a/dist/providers/manga/mangadex.js.map +++ b/dist/providers/manga/mangadex.js.map @@ -1 +1 @@ -{"version":3,"file":"mangadex.js","sourceRoot":"","sources":["../../../src/providers/manga/mangadex.ts"],"names":[],"mappings":";;AAAA,yDAA2C;AAG3C,yCAA8G;AAC9G,uCAAqE;AAErE,MAAM,QAAS,SAAQ,oBAAW;IAAlC;;QACoB,SAAI,GAAG,UAAU,CAAC;QACjB,YAAO,GAAG,sBAAsB,CAAC;QACjC,SAAI,GAAG,+EAA+E,CAAC;QACvF,cAAS,GAAG,gBAAgB,CAAC;QAE/B,WAAM,GAAG,0BAA0B,CAAC;QAE5C,mBAAc,GAAG,KAAK,EAAE,OAAe,EAAuB,EAAE;;YACvE,IAAI,CAAC;gBACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,UAAU,OAAO,EAAE,CAAC,CAAC;gBAC1E,MAAM,SAAS,GAAe;oBAC5B,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;oBAChB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;oBACpC,SAAS,EAAE,IA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E,+BAA+B;AAC/B,QAAQ;AAER,kBAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/docs/providers/mangadex.md b/docs/providers/mangadex.md index d5e298511..0ef211f32 100644 --- a/docs/providers/mangadex.md +++ b/docs/providers/mangadex.md @@ -9,6 +9,10 @@ const mangadex = new MANGA.MangaDex(); - [search](#search) - [fetchMangaInfo](#fetchmangainfo) - [fetchChapterPages](#fetchchapterpages) +- [fetchPopular](#fetchpopular) +- [fetchRecentlyAdded](#fetchRecentlyAdded) +- [fetchLatestUpdates](#fetchLatestUpdates) +- [fetchRandom](#fetchrandom) ### search > Note: This method is a subclass of the [`BaseParser`](https://github.com/consumet/extensions/blob/master/src/models/base-parser.ts) class. meaning it is available across most categories. @@ -81,7 +85,7 @@ output: ], description: { en: "Katagiri Yuichi believes that friends are more important than money, but he also knows the hardships ...', - pl: 'Dziękujemy za wpłatę dwudziestu milionów jenów! W ten sposób dołączyliście do jedynej w swoim rodzaju gry przyjaciół! Witajcie...", + pl: 'Dziękujemy za wpłatę dwudziestu milionów jenów! W ten sposób dołączyliście do jedynej w swoim rodzaju gry przyjaciół! Witajcie...', ... }, genres: [ 'Psychological', 'Drama', '...' ], @@ -135,4 +139,165 @@ output: ] ``` +### fetchPopular + +

Parameters

+ +| Parameter | Type | Description | +| ---------------- | -------- | ---------------------------------------------------------------------------- | +| page (optional) | `number` | page number (default: 1) | +| limit (optional) | `number` | limit of results (default: 20) | + +```ts +mangadex.fetchPopular().then(data => { + console.log(data); +}) +``` +returns a promise which resolves into an array of manga. (*[`Promise>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L97-L106)*)\ +output: +```js +{ + currentPage: 1, + results: [ + { + id: '32d76d19-8a05-4db0-9fc2-e0b0648fe9d0', + title: 'Solo Leveling', + altTitles: [ + { ko: '나 혼자만 레벨업' }, + { en: 'Only I Level up' }, + {...}, + ... + ], + description: 'Als sich vor zehn Jahren das „Gate“ öffnete und unsere Welt sich mit der von Monstern verband, erhielten einige normale Menschen die Macht...', + status: 'completed', + releaseDate: 2018, + contentRating: 'safe', + lastVolume: '3', + lastChapter: '200' + }, + {...} + ... + ] +} +``` + +### fetchRecentlyAdded + +

Parameters

+ +| Parameter | Type | Description | +| ---------------- | -------- | ---------------------------------------------------------------------------- | +| page (optional) | `number` | page number (default: 1) | +| limit (optional) | `number` | limit of results (default: 20) | + +```ts +mangadex.fetchRecentlyAdded().then(data => { + console.log(data); +}) +``` +returns a promise which resolves into an array of manga. (*[`Promise>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L97-L106)*)\ +output: +```js +{ + currentPage: 1, + results: [ + { + id: '39480d0b-339d-4669-be8e-01ca0041fca4', + title: 'Mamono no kuchibiru', + altTitles: [ { en: "Devil's Lips" }, { ja: '魔物のくちびる' } ], + description: 'At first, it was a small "favour".Kibakura had instantly fallen in love with, Aikyou, his junior one grade below him.They had first met at last year...', + status: 'completed', + releaseDate: 2021, + contentRating: 'erotica', + lastVolume: '', + lastChapter: '1' +}, + {...} + ... + ] +} +``` + +### fetchLatestUpdates + +

Parameters

+ +| Parameter | Type | Description | +| ---------------- | -------- | ---------------------------------------------------------------------------- | +| page (optional) | `number` | page number (default: 1) | +| limit (optional) | `number` | limit of results (default: 20) | + +```ts +mangadex.fetchLatestUpdates().then(data => { + console.log(data); +}) +``` +returns a promise which resolves into an array of manga. (*[`Promise>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L97-L106)*)\ +output: +```js +{ + currentPage: 1, + results: [ + { + id: 'e93849b2-939f-40f3-91b4-79b96133052e', + title: 'Medusa Dorei o Katta', + altTitles: [ + { ja: 'メドゥーサ奴隷を買った' }, + { en: 'I Bought a Medusa Slave' }, + {...}, + ... + ], + description: undefined, + status: 'ongoing', + releaseDate: 2023, + contentRating: 'suggestive', + lastVolume: '', + lastChapter: '' + }, + {...} + ... + ] +} +``` + +### fetchRandom + +

Parameters

+ +| Parameter | Type | Description | +| ---------------- | -------- | ---------------------------------------------------------------------------- | + + +```ts +mangadex.fetchRandom().then(data => { + console.log(data); +}) +``` +returns a promise which resolves into an array of manga. (*[`Promise>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L97-L106)*)\ +output: +```js +{ + results: [ + { + id: '151bca3e-db98-4ad2-8d8d-239943b91437', + title: 'You Shou Yan', + altTitles: [ + { zh: '有兽焉' }, + { en: 'Fabulous Beasts' }, + {...}, + ... + ], + description: 'In this realm mythological creatures roam, descendant of the nine heavens they call home. Sibuxiang, a mythical deer-man couch potato, is kicked out of heaven and assigned to...', + status: 'ongoing', + releaseDate: 2017, + contentRating: 'safe', + lastVolume: null, + lastChapter: null + }, + {...} + ... + ] +} +``` +

(back to manga providers list)

diff --git a/src/providers/manga/mangadex.ts b/src/providers/manga/mangadex.ts index 163aba462..b9bdeb91a 100644 --- a/src/providers/manga/mangadex.ts +++ b/src/providers/manga/mangadex.ts @@ -128,7 +128,170 @@ class MangaDex extends MangaParser { throw new Error((err as Error).message); } }; + fetchRandom = async ( + ): Promise> => { + try { + const res = await this.client.get( + `${this.apiUrl}/manga/random` + ); + + if (res.data.result == 'ok') { + const results: ISearch = { + currentPage: 1, + results: [], + }; + + results.results.push({ + id: res.data.data.id, + title: Object.values(res.data.data.attributes.title)[0] as string, + altTitles: res.data.data.attributes.altTitles, + description: Object.values(res.data.data.attributes.description)[0] as string, + status: res.data.data.attributes.status, + releaseDate: res.data.data.attributes.year, + contentRating: res.data.data.attributes.contentRating, + lastVolume: res.data.data.attributes.lastVolume, + lastChapter: res.data.data.attributes.lastChapter, + }); + + + return results; + } else { + throw new Error(res.data.message); + } + } catch (err) { + throw new Error((err as Error).message); + } + }; + fetchRecentlyAdded = async ( + page: number = 1, + limit: number = 20 + ): Promise> => { + if (page <= 0) throw new Error('Page number must be greater than 0'); + if (limit > 100) throw new Error('Limit must be less than or equal to 100'); + if (limit * (page - 1) >= 10000) throw new Error('not enough results'); + try { + const res = await this.client.get( + `${this.apiUrl}/manga?includes[]=cover_art&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&order[createdAt]=desc&hasAvailableChapters=true&limit=${limit}&offset=${ + limit * (page - 1) + }` + ); + + if (res.data.result == 'ok') { + const results: ISearch = { + currentPage: page, + results: [], + }; + + for (const manga of res.data.data) { + results.results.push({ + id: manga.id, + title: Object.values(manga.attributes.title)[0] as string, + altTitles: manga.attributes.altTitles, + description: Object.values(manga.attributes.description)[0] as string, + status: manga.attributes.status, + releaseDate: manga.attributes.year, + contentRating: manga.attributes.contentRating, + lastVolume: manga.attributes.lastVolume, + lastChapter: manga.attributes.lastChapter, + }); + } + + return results; + } else { + throw new Error(res.data.message); + } + } catch (err) { + + throw new Error((err as Error).message); + } + }; + fetchLatestUpdates = async ( + page: number = 1, + limit: number = 20 + ): Promise> => { + if (page <= 0) throw new Error('Page number must be greater than 0'); + if (limit > 100) throw new Error('Limit must be less than or equal to 100'); + if (limit * (page - 1) >= 10000) throw new Error('not enough results'); + + try { + const res = await this.client.get( + `${this.apiUrl}/manga?order[latestUploadedChapter]=desc&limit=${limit}&offset=${ + limit * (page - 1) + }` + ); + + if (res.data.result == 'ok') { + const results: ISearch = { + currentPage: page, + results: [], + }; + + for (const manga of res.data.data) { + results.results.push({ + id: manga.id, + title: Object.values(manga.attributes.title)[0] as string, + altTitles: manga.attributes.altTitles, + description: Object.values(manga.attributes.description)[0] as string, + status: manga.attributes.status, + releaseDate: manga.attributes.year, + contentRating: manga.attributes.contentRating, + lastVolume: manga.attributes.lastVolume, + lastChapter: manga.attributes.lastChapter, + }); + } + + return results; + } else { + throw new Error(res.data.message); + } + } catch (err) { + throw new Error((err as Error).message); + } + }; + fetchPopular = async ( + page: number = 1, + limit: number = 20 + ): Promise> => { + if (page <= 0) throw new Error('Page number must be greater than 0'); + if (limit > 100) throw new Error('Limit must be less than or equal to 100'); + if (limit * (page - 1) >= 10000) throw new Error('not enough results'); + + try { + const res = await this.client.get( + `${this.apiUrl}/manga?includes[]=cover_art&includes[]=artist&includes[]=author&order[followedCount]=desc&contentRating[]=safe&contentRating[]=suggestive&hasAvailableChapters=true&limit=${limit}&offset=${ + limit * (page - 1) + }` + ); + + if (res.data.result == 'ok') { + const results: ISearch = { + currentPage: page, + results: [], + }; + + for (const manga of res.data.data) { + results.results.push({ + id: manga.id, + title: Object.values(manga.attributes.title)[0] as string, + altTitles: manga.attributes.altTitles, + description: Object.values(manga.attributes.description)[0] as string, + status: manga.attributes.status, + releaseDate: manga.attributes.year, + contentRating: manga.attributes.contentRating, + lastVolume: manga.attributes.lastVolume, + lastChapter: manga.attributes.lastChapter, + }); + } + + return results; + } else { + throw new Error(res.data.message); + } + } catch (err) { + throw new Error((err as Error).message); + } + }; private fetchAllChapters = async ( mangaId: string, offset: number,