@riffyh/adapter-nhentai 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +89 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +28 -0
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import pThrottle from "p-throttle";
|
|
2
|
+
const getGallery = pThrottle({
|
|
3
|
+
limit: 45,
|
|
4
|
+
interval: 60 * 1e3
|
|
5
|
+
})(async ({ id }) => {
|
|
6
|
+
const data = await fetch(`https://nhentai.net/api/v2/galleries/${id.toString()}`).then((o) => {
|
|
7
|
+
if (o.ok) return o.json();
|
|
8
|
+
else throw o;
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
id: data.id.toString(),
|
|
12
|
+
key: "nh",
|
|
13
|
+
title: {
|
|
14
|
+
display: data.title.english ?? data.title.pretty ?? data.title.japanese,
|
|
15
|
+
original: data.title.japanese || null
|
|
16
|
+
},
|
|
17
|
+
cover: {
|
|
18
|
+
src: `https://t4.nhentai.net/${data.cover.path}`,
|
|
19
|
+
width: data.cover.width,
|
|
20
|
+
height: data.cover.height
|
|
21
|
+
},
|
|
22
|
+
pages: data.pages.map((page) => ({
|
|
23
|
+
order: page.number,
|
|
24
|
+
src: `https://i4.nhentai.net/${page.path}`,
|
|
25
|
+
width: page.width,
|
|
26
|
+
height: page.height
|
|
27
|
+
})),
|
|
28
|
+
tags: data.tags.map((tag) => ({
|
|
29
|
+
id: tag.id.toString(),
|
|
30
|
+
key: "nh",
|
|
31
|
+
name: tag.name,
|
|
32
|
+
type: tag.type,
|
|
33
|
+
slug: tag.slug
|
|
34
|
+
}))
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
const getListing = pThrottle({
|
|
38
|
+
limit: 30,
|
|
39
|
+
interval: 60 * 1e3
|
|
40
|
+
})(async ({ searchQuery, page }) => {
|
|
41
|
+
const payload = new URLSearchParams({
|
|
42
|
+
query: searchQuery ?? "-thisisrandomstringtomakesurethatthereisnoanytagbeingexcluded",
|
|
43
|
+
sort: "date",
|
|
44
|
+
page: page.toString()
|
|
45
|
+
});
|
|
46
|
+
const data = await fetch(`https://nhentai.net/api/v2/search?${payload.toString()}`).then((o) => {
|
|
47
|
+
if (o.ok) return o.json();
|
|
48
|
+
else throw o;
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
galleries: data.result.map((result) => ({
|
|
52
|
+
id: result.id.toString(),
|
|
53
|
+
key: "nh",
|
|
54
|
+
title: {
|
|
55
|
+
display: result.english_title ?? result.japanese_title,
|
|
56
|
+
original: null
|
|
57
|
+
},
|
|
58
|
+
cover: {
|
|
59
|
+
src: `https://t4.nhentai.net/${result.thumbnail}`,
|
|
60
|
+
width: result.thumbnail_width,
|
|
61
|
+
height: result.thumbnail_height
|
|
62
|
+
}
|
|
63
|
+
})),
|
|
64
|
+
currentPage: page,
|
|
65
|
+
maximumPages: data.num_pages
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/getImage.ts
|
|
70
|
+
const getImage = ({ url }) => fetch(url).then(async (o) => {
|
|
71
|
+
if (o.ok) return Buffer.from(await o.arrayBuffer());
|
|
72
|
+
else throw o;
|
|
73
|
+
});
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/index.ts
|
|
76
|
+
const nhentai = () => {
|
|
77
|
+
return {
|
|
78
|
+
key: "nh",
|
|
79
|
+
name: "nhentai",
|
|
80
|
+
iconUrl: "https://nhentai.net/favicon.png",
|
|
81
|
+
getGallery,
|
|
82
|
+
getListing,
|
|
83
|
+
getImage
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { nhentai };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["throttle"],"sources":["../src/getGalery.ts","../src/getListing.ts","../src/getImage.ts","../src/index.ts"],"sourcesContent":["import pThrottle from \"p-throttle\";\nimport { key } from \"./key\";\n\nimport type { DataSource, Gallery } from \"@riffyh/commons\";\nimport type { NhentaiGallery } from \"./types/NhentaiGallery\";\n\nconst throttle = pThrottle({\n limit: 45,\n interval: 60 * 1000,\n});\n\nexport const getGallery: DataSource[\"getGallery\"] = throttle(async ({ id }) => {\n const data = await fetch(`https://nhentai.net/api/v2/galleries/${id.toString()}`).then((o) => {\n if (o.ok) return o.json() as Promise<NhentaiGallery>;\n else throw o;\n });\n\n const gallery: Gallery = {\n id: data.id.toString(),\n key,\n title: {\n display: data.title.english ?? data.title.pretty ?? data.title.japanese,\n original: data.title.japanese || null,\n },\n cover: {\n src: `https://t4.nhentai.net/${data.cover.path}`,\n width: data.cover.width,\n height: data.cover.height,\n },\n pages: data.pages.map((page) => ({\n order: page.number,\n src: `https://i4.nhentai.net/${page.path}`,\n width: page.width,\n height: page.height,\n })),\n tags: data.tags.map((tag) => ({\n id: tag.id.toString(),\n key,\n name: tag.name,\n type: tag.type,\n slug: tag.slug,\n })),\n };\n\n return gallery;\n});\n","import pThrottle from \"p-throttle\";\nimport { key } from \"./key\";\n\nimport type { DataSource, ListingResult } from \"@riffyh/commons\";\nimport type { NhentaiSearchResult } from \"./types/NhentaiSearchResult\";\n\nconst throttle = pThrottle({\n limit: 30,\n interval: 60 * 1000,\n});\n\nexport const getListing: DataSource[\"getListing\"] = throttle(async ({ searchQuery, page }) => {\n const payload = new URLSearchParams({\n query: searchQuery ?? \"-thisisrandomstringtomakesurethatthereisnoanytagbeingexcluded\",\n sort: \"date\",\n page: page.toString(),\n });\n\n const data = await fetch(`https://nhentai.net/api/v2/search?${payload.toString()}`).then((o) => {\n if (o.ok) return o.json() as Promise<NhentaiSearchResult>;\n else throw o;\n });\n\n const result: ListingResult = {\n galleries: data.result.map((result) => ({\n id: result.id.toString(),\n key,\n title: {\n display: result.english_title ?? result.japanese_title,\n original: null,\n },\n cover: {\n src: `https://t4.nhentai.net/${result.thumbnail}`,\n width: result.thumbnail_width,\n height: result.thumbnail_height,\n },\n })),\n currentPage: page,\n maximumPages: data.num_pages,\n };\n\n return result;\n});\n","import type { DataSource } from \"@riffyh/commons\";\n\nexport const getImage: DataSource[\"getImage\"] = ({ url }) =>\n fetch(url).then(async (o) => {\n if (o.ok) return Buffer.from(await o.arrayBuffer());\n else throw o;\n });\n","import type { DataSource } from \"@riffyh/commons\";\nimport { getGallery } from \"./getGalery\";\nimport { getListing } from \"./getListing\";\nimport { getImage } from \"./getImage\";\nimport { key } from \"./key\";\n\nexport const nhentai = (): DataSource => {\n return {\n key,\n name: \"nhentai\",\n iconUrl: \"https://nhentai.net/favicon.png\",\n getGallery,\n getListing,\n getImage,\n };\n};\n"],"mappings":";AAWA,MAAa,aALI,UAAU;CACzB,OAAO;CACP,UAAU,KAAK;CAChB,CAAC,CAE2D,OAAO,EAAE,SAAS;CAC7E,MAAM,OAAO,MAAM,MAAM,wCAAwC,GAAG,UAAU,GAAG,CAAC,MAAM,MAAM;AAC5F,MAAI,EAAE,GAAI,QAAO,EAAE,MAAM;MACpB,OAAM;GACX;AA6BF,QA3ByB;EACvB,IAAI,KAAK,GAAG,UAAU;EACtB,KAAA;EACA,OAAO;GACL,SAAS,KAAK,MAAM,WAAW,KAAK,MAAM,UAAU,KAAK,MAAM;GAC/D,UAAU,KAAK,MAAM,YAAY;GAClC;EACD,OAAO;GACL,KAAK,0BAA0B,KAAK,MAAM;GAC1C,OAAO,KAAK,MAAM;GAClB,QAAQ,KAAK,MAAM;GACpB;EACD,OAAO,KAAK,MAAM,KAAK,UAAU;GAC/B,OAAO,KAAK;GACZ,KAAK,0BAA0B,KAAK;GACpC,OAAO,KAAK;GACZ,QAAQ,KAAK;GACd,EAAE;EACH,MAAM,KAAK,KAAK,KAAK,SAAS;GAC5B,IAAI,IAAI,GAAG,UAAU;GACrB,KAAA;GACA,MAAM,IAAI;GACV,MAAM,IAAI;GACV,MAAM,IAAI;GACX,EAAE;EACJ;EAGD;AClCF,MAAa,aALI,UAAU;CACzB,OAAO;CACP,UAAU,KAAK;CAChB,CAAC,CAE2D,OAAO,EAAE,aAAa,WAAW;CAC5F,MAAM,UAAU,IAAI,gBAAgB;EAClC,OAAO,eAAe;EACtB,MAAM;EACN,MAAM,KAAK,UAAU;EACtB,CAAC;CAEF,MAAM,OAAO,MAAM,MAAM,qCAAqC,QAAQ,UAAU,GAAG,CAAC,MAAM,MAAM;AAC9F,MAAI,EAAE,GAAI,QAAO,EAAE,MAAM;MACpB,OAAM;GACX;AAoBF,QAlB8B;EAC5B,WAAW,KAAK,OAAO,KAAK,YAAY;GACtC,IAAI,OAAO,GAAG,UAAU;GACxB,KAAA;GACA,OAAO;IACL,SAAS,OAAO,iBAAiB,OAAO;IACxC,UAAU;IACX;GACD,OAAO;IACL,KAAK,0BAA0B,OAAO;IACtC,OAAO,OAAO;IACd,QAAQ,OAAO;IAChB;GACF,EAAE;EACH,aAAa;EACb,cAAc,KAAK;EACpB;EAGD;;;ACxCF,MAAa,YAAoC,EAAE,UACjD,MAAM,IAAI,CAAC,KAAK,OAAO,MAAM;AAC3B,KAAI,EAAE,GAAI,QAAO,OAAO,KAAK,MAAM,EAAE,aAAa,CAAC;KAC9C,OAAM;EACX;;;ACAJ,MAAa,gBAA4B;AACvC,QAAO;EACL,KAAA;EACA,MAAM;EACN,SAAS;EACT;EACA;EACA;EACD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@riffyh/adapter-nhentai",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/rayriffy/rayriffy-h.git"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.mjs",
|
|
13
|
+
"types": "dist/index.d.mts",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"registry": "https://registry.npmjs.org"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"p-throttle": "8.1.0",
|
|
20
|
+
"@riffyh/commons": "2.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"tsdown": "0.21.7"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsdown"
|
|
27
|
+
}
|
|
28
|
+
}
|