From 72eda2bf5c50c4e7abf49710fd9a0ad3bdf6a9bd Mon Sep 17 00:00:00 2001 From: shafat420 Date: Fri, 25 Apr 2025 12:18:41 +0600 Subject: [PATCH] Initial commit --- README.md | 287 +++++ package-lock.json | 1784 ++++++++++++++++++++++++++++++ package.json | 24 + src/constants/api-constants.js | 25 + src/index.js | 210 ++++ src/mappers/animekai-mapper.js | 144 +++ src/mappers/animepahe-mapper.js | 321 ++++++ src/mappers/hianime-mapper.js | 18 + src/mappers/index.js | 9 + src/providers/anilist.js | 103 ++ src/providers/animekai.js | 61 + src/providers/animepahe.js | 281 +++++ src/providers/hianime-servers.js | 136 +++ src/providers/hianime.js | 381 +++++++ src/providers/index.js | 11 + src/utils/cache.js | 43 + src/utils/client.js | 12 + vercel.json | 15 + 18 files changed, 3865 insertions(+) create mode 100644 README.md create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/constants/api-constants.js create mode 100644 src/index.js create mode 100644 src/mappers/animekai-mapper.js create mode 100644 src/mappers/animepahe-mapper.js create mode 100644 src/mappers/hianime-mapper.js create mode 100644 src/mappers/index.js create mode 100644 src/providers/anilist.js create mode 100644 src/providers/animekai.js create mode 100644 src/providers/animepahe.js create mode 100644 src/providers/hianime-servers.js create mode 100644 src/providers/hianime.js create mode 100644 src/providers/index.js create mode 100644 src/utils/cache.js create mode 100644 src/utils/client.js create mode 100644 vercel.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..d1937d0 --- /dev/null +++ b/README.md @@ -0,0 +1,287 @@ +# Anilist to AnimePahe Mapper API + +A specialized Node.js API that maps anime data between Anilist and streaming platforms (AnimePahe, HiAnime, AnimeKai) using advanced string similarity algorithms. + +## Features + +- Map Anilist anime IDs to AnimePahe, HiAnime, and AnimeKai content +- Advanced string similarity analysis with multiple algorithms +- Season/year matching for multi-season anime series +- Title variation detection across platforms +- Get streaming links with proper headers +- Support for both subbed and dubbed anime (AnimeKai) + +## Installation + +```bash +# Clone the repository +git clone https://github.com/yourusername/anilist-animepahe-mapper.git +cd anilist-animepahe-mapper + +# Install dependencies +npm install + +# Start the server +npm start +``` + +## API Endpoints + +### AnimePahe Endpoints + +#### Map Anilist ID to AnimePahe + +``` +GET /animepahe/map/:anilistId +``` + +Maps an Anilist anime ID to its corresponding AnimePahe content. + +#### Get AnimePahe Streaming Links + +``` +GET /animepahe/sources/:session/:episodeId +``` + +Returns streaming links for a specific AnimePahe episode. + +Alternative format: +``` +GET /animepahe/sources/:id +``` + +### HiAnime Endpoints + +#### Map Anilist ID to HiAnime + +``` +GET /hianime/:anilistId +``` + +Maps an Anilist anime ID to its corresponding HiAnime content. + +#### Get HiAnime Servers + +``` +GET /hianime/servers/:episodeId +``` + +Get available servers for a HiAnime episode. + +Parameters: +- `ep` (optional): Episode number + +Example: +``` +GET /hianime/servers/one-piece-100?ep=2142 +``` + +#### Get HiAnime Streaming Sources + +``` +GET /hianime/sources/:episodeId +``` + +Returns streaming links for a specific HiAnime episode. + +Parameters: +- `ep` (required): Episode number +- `server` (optional): Server name (default: vidstreaming) +- `category` (optional): Content type (sub, dub, raw) (default: sub) + +Example: +``` +GET /hianime/sources/one-piece-100?ep=2142&server=vidstreaming&category=sub +``` + +### AnimeKai Endpoints + +#### Map Anilist ID to AnimeKai + +``` +GET /animekai/map/:anilistId +``` + +Maps an Anilist anime ID to its corresponding AnimeKai content. + +#### Get AnimeKai Streaming Links + +``` +GET /animekai/sources/:episodeId +``` + +Returns streaming links for a specific AnimeKai episode. + +Parameters: +- `server` (optional): Specify a streaming server +- `dub` (optional): Set to `true` or `1` to get dubbed sources instead of subbed + +Example: +``` +GET /animekai/sources/episode-id-here?dub=true +``` + +## Handling 403 Errors + +When accessing the streaming URLs (not the API endpoint), you will encounter 403 Forbidden errors unless you include the proper Referer header. This is a requirement from the underlying streaming provider. + +### Required Headers for Streaming + +``` +Referer: https://kwik.cx/ +``` + +### Example Implementation + +```javascript +// Javascript fetch example +fetch('https://streaming-url-from-response.m3u8', { + headers: { + 'Referer': 'https://kwik.cx/' + } +}) + +// Using axios +axios.get('https://streaming-url-from-response.m3u8', { + headers: { + 'Referer': 'https://kwik.cx/' + } +}) +``` + +### Video Player Examples + +```javascript +// Video.js player +const player = videojs('my-player', { + html5: { + hls: { + overrideNative: true, + xhr: { + beforeRequest: function(options) { + options.headers = { + ...options.headers, + 'Referer': 'https://kwik.cx/' + }; + return options; + } + } + } + } +}); + +// HLS.js player +const hls = new Hls({ + xhrSetup: function(xhr, url) { + xhr.setRequestHeader('Referer', 'https://kwik.cx/'); + } +}); +hls.loadSource('https://streaming-url-from-response.m3u8'); +hls.attachMedia(document.getElementById('video')); +``` + +## Mapping Approach + +The API uses several techniques to find the best match between Anilist and streaming platforms: + +1. Tries multiple possible titles (romaji, english, native, userPreferred, synonyms) +2. Uses multiple string similarity algorithms to find the best match +3. Ranks matches based on similarity score +4. Uses year and season information to match the correct season of a series +5. Extracts season numbers from titles for better matching + +## Response Format Examples + +### AnimePahe Mapping Response + +```json +{ + "id": 131681, + "animepahe": { + "id": "5646-Re:ZERO -Starting Life in Another World- Season 3", + "title": "Re:ZERO -Starting Life in Another World- Season 3", + "type": "TV", + "status": "Finished Airing", + "season": "Fall", + "year": 2024, + "score": 8.5, + "posterImage": "https://i.animepahe.ru/posters/016b3cda2c47fb5167e238a3f4e97f03e0d1bd3d5e8ffb079ad6d8665fb92455.jpg", + "episodes": { + "count": 16, + "data": [...] + } + } +} +``` + +### AnimeKai Mapping Response + +```json +{ + "id": 131681, + "animekai": { + "id": "re-zero-starting-life-in-another-world-season-3", + "title": "Re:ZERO -Starting Life in Another World- Season 3", + "malId": 51194, + "posterImage": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx131681-OFQfZ5v67VYq.jpg", + "episodes": [...] + } +} +``` + +### Episode Sources Response + +```json +{ + "headers": { "Referer": "https://kwik.cx/" }, + "sources": [ + { + "url": "https://na-191.files.nextcdn.org/hls/01/b49063a1225cf4350deb46d79b42a7572e323274d1c9d63f3b067cc4df09986a/uwu.m3u8", + "isM3U8": true, + "quality": "360", + "size": 44617958 + }, + { + "url": "https://na-191.files.nextcdn.org/hls/01/c32da1b1975a5106dcee7e7182219f9b4dbef836fb782d7939003a8cde8f057f/uwu.m3u8", + "isM3U8": true, + "quality": "720", + "size": 78630133 + }, + { + "url": "https://na-191.files.nextcdn.org/hls/01/b85d4450908232aa32b71bc67c80e8aedcc4f32a282e5df9ad82e4662786e9d8/uwu.m3u8", + "isM3U8": true, + "quality": "1080", + "size": 118025148 + } + ] +} +``` + +## Notes + +- This API is for educational purposes only +- Respect the terms of service of all providers (Anilist, AnimePahe, HiAnime, AnimeKai) +- Optimized for simplicity and focused exclusively on mapping functionality + +## Dependencies + +- Express.js - Web framework +- @consumet/extensions - For AnimePahe integration +- AniWatch (HiAnime) - For HiAnime integration +- Node-cache - For response caching + +## Example Usage + +Map by Anilist ID: +``` +GET /animepahe/map/21 +GET /hianime/21 +GET /animekai/map/21 +``` + +Get streaming links for an episode: +``` +GET /animepahe/sources/session-id/episode-id +GET /animekai/sources/episode-id +GET /animekai/sources/episode-id?dub=true +``` \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b8f9376 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1784 @@ +{ + "name": "anilist-animepahe-mapper", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "anilist-animepahe-mapper", + "version": "1.0.0", + "dependencies": { + "@consumet/extensions": "github:consumet/consumet.ts", + "aniwatch": "^2.21.2", + "axios": "^1.8.4", + "cheerio": "^1.0.0", + "express": "^4.21.2", + "node-cache": "^5.1.2", + "node-fetch": "^3.3.2", + "string-similarity-js": "^2.1.4" + }, + "devDependencies": { + "nodemon": "^3.0.1" + } + }, + "node_modules/@consumet/extensions": { + "version": "1.8.1", + "resolved": "git+ssh://git@github.com/consumet/consumet.ts.git#625c04c140fd7a9ac0b48b533745382e4fceef6f", + "license": "MIT", + "dependencies": { + "ascii-url-encoder": "^1.2.0", + "axios": "^1.7.9", + "cheerio": "^1.0.0-rc.12", + "crypto-js": "^4.1.1", + "domhandler": "^5.0.3", + "form-data": "^4.0.0", + "husky": "^9.1.1" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/aniwatch": { + "version": "2.21.2", + "resolved": "https://registry.npmjs.org/aniwatch/-/aniwatch-2.21.2.tgz", + "integrity": "sha512-XwrUxdN3ljWrd26R2ApdOGy2QRMj45lPRXmE97y7Baf9KJiwfAGTGhK5skAYDyUZLnLSpDw7VnnJhmMQCmv6Cg==", + "license": "MIT", + "dependencies": { + "axios": "^1.7.9", + "cheerio": "1.0.0", + "crypto-js": "^4.2.0" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/ascii-url-encoder": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ascii-url-encoder/-/ascii-url-encoder-1.2.0.tgz", + "integrity": "sha512-jRQMrz1ZqL7gnK60Xbu1S8kDi01UN+lHBnhvXZZqjd7nms7t4jOv4o9nE8bbfDh1Ts/KEtW2nXGR5CmydDBmlw==", + "license": "MIT" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.8.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz", + "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/body-parser": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.13.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/body-parser/node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "license": "ISC" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/cheerio": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0.tgz", + "integrity": "sha512-quS9HgjQpdaXOvsZz82Oz7uxtXiy6UIsIQcpBj7HRw2M63Skasm9qlDocAM7jNuaxdhpPU7c4kJN+gA5MCu4ww==", + "license": "MIT", + "dependencies": { + "cheerio-select": "^2.1.0", + "dom-serializer": "^2.0.0", + "domhandler": "^5.0.3", + "domutils": "^3.1.0", + "encoding-sniffer": "^0.2.0", + "htmlparser2": "^9.1.0", + "parse5": "^7.1.2", + "parse5-htmlparser2-tree-adapter": "^7.0.0", + "parse5-parser-stream": "^7.1.2", + "undici": "^6.19.5", + "whatwg-mimetype": "^4.0.0" + }, + "engines": { + "node": ">=18.17" + }, + "funding": { + "url": "https://github.com/cheeriojs/cheerio?sponsor=1" + } + }, + "node_modules/cheerio-select": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", + "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0", + "css-select": "^5.1.0", + "css-what": "^6.1.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "license": "MIT", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "license": "MIT" + }, + "node_modules/crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", + "license": "MIT" + }, + "node_modules/css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/encoding-sniffer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.0.tgz", + "integrity": "sha512-ju7Wq1kg04I3HtiYIOrUrdfdDvkyO9s5XM8QAj/bN61Yo/Vb4vgJxy5vi4Yxk01gWHbrofpPtpxM8bKger9jhg==", + "license": "MIT", + "dependencies": { + "iconv-lite": "^0.6.3", + "whatwg-encoding": "^3.1.1" + }, + "funding": { + "url": "https://github.com/fb55/encoding-sniffer?sponsor=1" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.3", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.7.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.3.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.12", + "proxy-addr": "~2.0.7", + "qs": "6.13.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.19.0", + "serve-static": "1.16.2", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", + "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "license": "MIT", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/htmlparser2": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", + "integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.1.0", + "entities": "^4.5.0" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "license": "MIT", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true, + "license": "ISC" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-cache": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", + "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", + "license": "MIT", + "dependencies": { + "clone": "2.x" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "deprecated": "Use your platform's native DOMException instead", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "license": "MIT", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/nodemon": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz", + "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.1.0.tgz", + "integrity": "sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==", + "license": "MIT", + "dependencies": { + "domhandler": "^5.0.3", + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-parser-stream": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-7.1.2.tgz", + "integrity": "sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==", + "license": "MIT", + "dependencies": { + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5/node_modules/entities": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.0.tgz", + "integrity": "sha512-aKstq2TDOndCn4diEyp9Uq/Flu2i1GlLkc6XIDQSDMuaFE3OPW5OphLCyQ5SpSJZTb4reN+kTcYru5yIfXoRPw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "license": "MIT" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true, + "license": "MIT" + }, + "node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.19.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/string-similarity-js": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/string-similarity-js/-/string-similarity-js-2.1.4.tgz", + "integrity": "sha512-uApODZNjCHGYROzDSAdCmAHf60L/pMDHnP/yk6TAbvGg7JSPZlSto/ceCI7hZEqzc53/juU2aOJFkM2yUVTMTA==", + "license": "MIT" + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "license": "ISC", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true, + "license": "MIT" + }, + "node_modules/undici": { + "version": "6.21.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.2.tgz", + "integrity": "sha512-uROZWze0R0itiAKVPsYhFov9LxrPMHLMEQFszeI2gCN6bnIIZ8twzBCJcN2LJrBBLfrP0t1FW0g+JmKVl8Vk1g==", + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", + "license": "MIT", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "license": "MIT", + "engines": { + "node": ">=18" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..aee781e --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "anilist-animepahe-mapper", + "version": "1.0.0", + "description": "API to map Anilist to AnimePahe", + "main": "src/index.js", + "type": "module", + "scripts": { + "start": "node src/index.js", + "dev": "nodemon src/index.js" + }, + "dependencies": { + "@consumet/extensions": "github:consumet/consumet.ts", + "aniwatch": "^2.21.2", + "axios": "^1.8.4", + "cheerio": "^1.0.0", + "express": "^4.21.2", + "node-cache": "^5.1.2", + "node-fetch": "^3.3.2", + "string-similarity-js": "^2.1.4" + }, + "devDependencies": { + "nodemon": "^3.0.1" + } +} diff --git a/src/constants/api-constants.js b/src/constants/api-constants.js new file mode 100644 index 0000000..41e7856 --- /dev/null +++ b/src/constants/api-constants.js @@ -0,0 +1,25 @@ +export const ANILIST_URL = 'https://graphql.anilist.co'; +export const ANILIST_QUERY = ` + query ($id: Int) { + Media(id: $id, type: ANIME) { + id + title { + romaji + english + native + userPreferred + } + episodes + synonyms + } + } +`; +export const HIANIME_URL = 'https://hianimez.to'; +export const ANIZIP_URL = 'https://api.ani.zip/mappings'; + +export default { + ANILIST_URL, + ANILIST_QUERY, + HIANIME_URL, + ANIZIP_URL +}; \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..e7672d4 --- /dev/null +++ b/src/index.js @@ -0,0 +1,210 @@ +import express from 'express'; +import { ANIME } from '@consumet/extensions'; +import { HiAnime } from 'aniwatch'; +import { mapAnilistToAnimePahe, mapAnilistToHiAnime, mapAnilistToAnimeKai } from './mappers/index.js'; +import { AniList } from './providers/anilist.js'; +import { AnimeKai } from './providers/animekai.js'; +import { getEpisodeServers } from './providers/hianime-servers.js'; +import { cache } from './utils/cache.js'; + +const app = express(); +const PORT = process.env.PORT || 3000; + +app.use(express.json()); + +// Return server information +app.get('/', (req, res) => { + res.json({ + status: 'ok', + message: 'Anilist to AnimePahe Mapper API', + routes: [ + '/animepahe/map/:anilistId', + '/animepahe/sources/:session/:episodeId', + '/animepahe/sources/:id', + '/hianime/:anilistId', + '/hianime/servers/:episodeId - For example: /hianime/servers/one-piece-100?ep=2142', + '/hianime/sources/:episodeId - optional params: ?ep=episodeId&server=serverName&category=sub|dub|raw', + '/animekai/map/:anilistId', + '/animekai/sources/:episodeId - supports ?server and ?dub=true params' + ], + }); +}); + +// Map Anilist ID to AnimePahe +app.get('/animepahe/map/:anilistId', cache('5 minutes'), async (req, res) => { + try { + const { anilistId } = req.params; + + if (!anilistId) { + return res.status(400).json({ error: 'AniList ID is required' }); + } + + const mappingResult = await mapAnilistToAnimePahe(anilistId); + return res.json(mappingResult); + } catch (error) { + console.error('Mapping error:', error.message); + return res.status(500).json({ error: error.message }); + } +}); + +// Map Anilist ID to HiAnime +app.get('/hianime/:anilistId', cache('5 minutes'), async (req, res) => { + try { + const { anilistId } = req.params; + + if (!anilistId) { + return res.status(400).json({ error: 'AniList ID is required' }); + } + + const episodes = await mapAnilistToHiAnime(anilistId); + return res.json(episodes); + } catch (error) { + console.error('HiAnime mapping error:', error.message); + return res.status(500).json({ error: error.message }); + } +}); + +// Get available servers for HiAnime episode +app.get('/hianime/servers/:animeId', cache('15 minutes'), async (req, res) => { + try { + const { animeId } = req.params; + const { ep } = req.query; + + if (!animeId) { + return res.status(400).json({ error: 'Anime ID is required' }); + } + + // Combine animeId and ep to form the expected episodeId format + const episodeId = ep ? `${animeId}?ep=${ep}` : animeId; + + const servers = await getEpisodeServers(episodeId); + return res.json(servers); + } catch (error) { + console.error('HiAnime servers error:', error.message); + return res.status(500).json({ error: error.message }); + } +}); + +// Get streaming sources for HiAnime episode using AniWatch +app.get('/hianime/sources/:animeId', cache('15 minutes'), async (req, res) => { + try { + const { animeId } = req.params; + const { ep, server = 'vidstreaming', category = 'sub' } = req.query; + + if (!animeId || !ep) { + return res.status(400).json({ error: 'Both anime ID and episode number (ep) are required' }); + } + + // Combine animeId and ep to form the expected episodeId format + const episodeId = `${animeId}?ep=${ep}`; + + // Use the AniWatch library directly + const hianime = new HiAnime.Scraper(); + const sources = await hianime.getEpisodeSources(episodeId, server, category); + + return res.json({ + success: true, + data: sources + }); + } catch (error) { + console.error('HiAnime sources error:', error.message); + return res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +// Map Anilist ID to AnimeKai +app.get('/animekai/map/:anilistId', cache('5 minutes'), async (req, res) => { + try { + const { anilistId } = req.params; + + if (!anilistId) { + return res.status(400).json({ error: 'AniList ID is required' }); + } + + const mappingResult = await mapAnilistToAnimeKai(anilistId); + return res.json(mappingResult); + } catch (error) { + console.error('AnimeKai mapping error:', error.message); + return res.status(500).json({ error: error.message }); + } +}); + +// Get episode sources from AnimeKai +app.get('/animekai/sources/:episodeId', cache('15 minutes'), async (req, res) => { + try { + const { episodeId } = req.params; + const { server, dub } = req.query; + + if (!episodeId) { + return res.status(400).json({ error: 'Episode ID is required' }); + } + + const animeKai = new AnimeKai(); + const isDub = dub === 'true' || dub === '1'; + const sources = await animeKai.fetchEpisodeSources(episodeId, server, isDub); + return res.json(sources); + } catch (error) { + console.error('AnimeKai sources error:', error.message); + return res.status(500).json({ error: error.message }); + } +}); + +// Get HLS streaming links for an episode using path parameter that may contain slashes +app.get('/animepahe/sources/:session/:episodeId', cache('15 minutes'), async (req, res) => { + try { + const { session, episodeId } = req.params; + const fullEpisodeId = `${session}/${episodeId}`; + + // Initialize a new AnimePahe instance each time + const consumetAnimePahe = new ANIME.AnimePahe(); + + // Directly fetch and return the sources without modification + const sources = await consumetAnimePahe.fetchEpisodeSources(fullEpisodeId); + + // Simply return the sources directly as provided by Consumet + return res.status(200).json(sources); + } catch (error) { + console.error('Error fetching episode sources:', error.message); + + // Keep error handling simple + return res.status(500).json({ + error: error.message, + message: 'Failed to fetch episode sources. If you receive a 403 error when accessing streaming URLs, add a Referer: "https://kwik.cx/" header to your requests.' + }); + } +}); + +// Backward compatibility for the single parameter version +app.get('/animepahe/sources/:id', cache('15 minutes'), async (req, res) => { + try { + const episodeId = req.params.id; + + if (!episodeId) { + return res.status(400).json({ error: 'Episode ID is required' }); + } + + // Initialize a new AnimePahe instance each time + const consumetAnimePahe = new ANIME.AnimePahe(); + + // Directly fetch and return the sources without modification + const sources = await consumetAnimePahe.fetchEpisodeSources(episodeId); + + // Simply return the sources directly as provided by Consumet + return res.status(200).json(sources); + } catch (error) { + console.error('Error fetching episode sources:', error.message); + + // Keep error handling simple + return res.status(500).json({ + error: error.message, + message: 'Failed to fetch episode sources. If you receive a 403 error when accessing streaming URLs, add a Referer: "https://kwik.cx/" header to your requests.' + }); + } +}); + +app.listen(PORT, () => { + console.log(`Server running on port ${PORT}`); +}); \ No newline at end of file diff --git a/src/mappers/animekai-mapper.js b/src/mappers/animekai-mapper.js new file mode 100644 index 0000000..bea9000 --- /dev/null +++ b/src/mappers/animekai-mapper.js @@ -0,0 +1,144 @@ +import { AniList } from '../providers/anilist.js'; +import { AnimeKai } from '../providers/animekai.js'; + +/** + * Maps an Anilist anime to AnimeKai + * @param {string|number} anilistId - The AniList ID to map + * @returns {Promise} The mapping result with episodes + */ +export async function mapAnilistToAnimeKai(anilistId) { + const mapper = new AnimeKaiMapper(); + return await mapper.mapAnilistToAnimeKai(anilistId); +} + +/** + * Mapper class that provides mapping between Anilist and AnimeKai + */ +export class AnimeKaiMapper { + constructor() { + this.anilist = new AniList(); + this.animeKai = new AnimeKai(); + } + + /** + * Maps an Anilist anime to AnimeKai content + * @param {string|number} anilistId - The AniList ID to map + */ + async mapAnilistToAnimeKai(anilistId) { + try { + // Get anime info from AniList + const animeInfo = await this.anilist.getAnimeInfo(parseInt(anilistId)); + + if (!animeInfo) { + throw new Error(`Anime with id ${anilistId} not found on AniList`); + } + + // Search for the anime on AnimeKai using the title + const searchTitle = animeInfo.title.english || animeInfo.title.romaji || animeInfo.title.userPreferred; + if (!searchTitle) { + throw new Error('No title available for the anime'); + } + + const searchResults = await this.animeKai.search(searchTitle); + if (!searchResults || !searchResults.results || searchResults.results.length === 0) { + return { + id: animeInfo.id, + title: searchTitle, + animekai: null + }; + } + + // Find the best match from search results + const bestMatch = this.findBestMatch(searchTitle, animeInfo, searchResults.results); + if (!bestMatch) { + return { + id: animeInfo.id, + title: searchTitle, + animekai: null + }; + } + + // Get detailed info for the best match + const animeDetails = await this.animeKai.fetchAnimeInfo(bestMatch.id); + + return { + id: animeInfo.id, + title: searchTitle, + animekai: { + id: bestMatch.id, + title: bestMatch.title, + japaneseTitle: bestMatch.japaneseTitle, + url: bestMatch.url, + image: bestMatch.image, + type: bestMatch.type, + episodes: animeDetails.totalEpisodes, + episodesList: animeDetails.episodes, + hasSub: animeDetails.hasSub, + hasDub: animeDetails.hasDub, + subOrDub: animeDetails.subOrDub, + status: animeDetails.status, + season: animeDetails.season, + genres: animeDetails.genres + } + }; + } catch (error) { + console.error('Error mapping AniList to AnimeKai:', error); + throw error; + } + } + + /** + * Find the best match from search results + * @param {string} searchTitle - The search title + * @param {Object} animeInfo - The AniList anime info + * @param {Array} results - The search results + * @returns {Object|null} The best match or null if no good match found + */ + findBestMatch(searchTitle, animeInfo, results) { + if (!results || results.length === 0) return null; + + // Normalize titles for comparison + const normalizeTitle = title => title.toLowerCase().replace(/[^\w\s]/g, '').replace(/\s+/g, ' ').trim(); + const normalizedSearch = normalizeTitle(searchTitle); + + // Extract year from AniList title if present + let year = null; + if (animeInfo.startDate && animeInfo.startDate.year) { + year = animeInfo.startDate.year; + } else if (animeInfo.seasonYear) { + year = animeInfo.seasonYear; + } + + // First try: find exact title match + for (const result of results) { + const resultTitle = normalizeTitle(result.title); + const japaneseTitle = result.japaneseTitle ? normalizeTitle(result.japaneseTitle) : ''; + + if (resultTitle === normalizedSearch || japaneseTitle === normalizedSearch) { + return result; + } + } + + // Second try: find partial match with proper episode count match + const expectedEpisodes = animeInfo.episodes || 0; + for (const result of results) { + const resultTitle = normalizeTitle(result.title); + const japaneseTitle = result.japaneseTitle ? normalizeTitle(result.japaneseTitle) : ''; + + // Check if this is likely the right anime by comparing episode count + if (result.episodes === expectedEpisodes && expectedEpisodes > 0) { + if (resultTitle.includes(normalizedSearch) || + normalizedSearch.includes(resultTitle) || + japaneseTitle.includes(normalizedSearch) || + normalizedSearch.includes(japaneseTitle)) { + return result; + } + } + } + + // Final fallback: just return the first result + return results[0]; + } +} + +export default mapAnilistToAnimeKai; \ No newline at end of file diff --git a/src/mappers/animepahe-mapper.js b/src/mappers/animepahe-mapper.js new file mode 100644 index 0000000..6f307d7 --- /dev/null +++ b/src/mappers/animepahe-mapper.js @@ -0,0 +1,321 @@ +import { AniList } from '../providers/anilist.js'; +import { AnimePahe } from '../providers/animepahe.js'; + +/** + * Maps an Anilist anime to AnimePahe content + */ +export async function mapAnilistToAnimePahe(anilistId) { + const mapper = new AnimepaheMapper(); + return await mapper.mapAnilistToAnimePahe(anilistId); +} + +/** + * Mapper class that provides mapping between Anilist and AnimePahe + */ +export class AnimepaheMapper { + constructor() { + this.anilist = new AniList(); + this.animePahe = new AnimePahe(); + } + + /** + * Maps an Anilist anime to AnimePahe content + */ + async mapAnilistToAnimePahe(anilistId) { + try { + // Get anime info from AniList + const animeInfo = await this.anilist.getAnimeInfo(parseInt(anilistId)); + + if (!animeInfo) { + throw new Error(`Anime with id ${anilistId} not found on AniList`); + } + + // Try to find matching content on AnimePahe + const bestMatch = await this.findAnimePaheMatch(animeInfo); + + if (!bestMatch) { + return { + id: animeInfo.id, + animepahe: null + }; + } + + // Get episode data for the matched anime + const episodeData = await this.getAnimePaheEpisodes(bestMatch); + + // Return the mapped result + return { + id: animeInfo.id, + animepahe: { + id: bestMatch.id, + title: bestMatch.title || bestMatch.name, + episodes: episodeData.episodes, + type: bestMatch.type, + status: bestMatch.status, + season: bestMatch.season, + year: bestMatch.year, + score: bestMatch.score, + posterImage: bestMatch.poster, + session: bestMatch.session + } + }; + } catch (error) { + console.error('Error mapping AniList to AnimePahe:', error.message); + throw new Error('Failed to map AniList to AnimePahe: ' + error.message); + } + } + + /** + * Finds the matching AnimePahe content for an AniList anime + */ + async findAnimePaheMatch(animeInfo) { + // Only use one primary title to reduce API calls + let bestTitle = animeInfo.title.romaji || animeInfo.title.english || animeInfo.title.userPreferred; + const titleType = animeInfo.title.romaji ? 'romaji' : (animeInfo.title.english ? 'english' : 'userPreferred'); + + // First search attempt + const searchResults = await this.animePahe.scrapeSearchResults(bestTitle); + + // Process results if we found any + if (searchResults && searchResults.length > 0) { + // First try direct ID match (fastest path) + const rawId = animeInfo.id.toString(); + for (const result of searchResults) { + const resultId = (result.id || '').split('-')[0]; + if (resultId && resultId === rawId) { + return result; + } + } + + // If no direct ID match, find the best match with our algorithm + return this.findBestMatchFromResults(animeInfo, searchResults); + } + + // If no results found, try a fallback search with a more generic title + const genericTitle = this.getGenericTitle(animeInfo); + + if (genericTitle && genericTitle !== bestTitle) { + const fallbackResults = await this.animePahe.scrapeSearchResults(genericTitle); + + if (fallbackResults && fallbackResults.length > 0) { + return this.findBestMatchFromResults(animeInfo, fallbackResults); + } + } + + return null; + } + + /** + * Find the best match from available search results + */ + findBestMatchFromResults(animeInfo, results) { + if (!results || results.length === 0) return null; + + // Normalize titles just once to avoid repeating work + const normalizeTitle = t => t.toLowerCase().replace(/[^\w\s]/g, '').replace(/\s+/g, ' ').trim(); + const anilistTitles = [ + animeInfo.title.romaji, + animeInfo.title.english, + animeInfo.title.userPreferred + ].filter(Boolean).map(normalizeTitle); + + // Prepare year information + const anilistYear = + (animeInfo.startDate && animeInfo.startDate.year) ? + animeInfo.startDate.year : animeInfo.seasonYear; + + const animeYear = anilistYear || this.extractYearFromTitle(animeInfo); + + // Process matches sequentially with early returns + let bestMatch = null; + + // Try exact title match with year (highest priority) + if (animeYear) { + // Find matches with exact year + const yearMatches = []; + for (const result of results) { + const resultYear = result.year ? parseInt(result.year) : this.extractYearFromTitle(result); + if (resultYear === animeYear) { + yearMatches.push(result); + } + } + + // If we have year matches, try to find the best title match among them + if (yearMatches.length > 0) { + for (const match of yearMatches) { + const resultTitle = normalizeTitle(match.title || match.name); + + // First try: exact title match with year + for (const title of anilistTitles) { + if (!title) continue; + + if (resultTitle === title || + (resultTitle.includes(title) && title.length > 7) || + (title.includes(resultTitle) && resultTitle.length > 7)) { + return match; // Early return for best match + } + } + + // Second try: high similarity title match with year + for (const title of anilistTitles) { + if (!title) continue; + + const similarity = this.calculateTitleSimilarity(title, resultTitle); + if (similarity > 0.5) { + bestMatch = match; + break; + } + } + + if (bestMatch) break; + } + + // If we found a title similarity match with year, return it + if (bestMatch) return bestMatch; + + // Otherwise use the first year match as a fallback + return yearMatches[0]; + } + } + + // Try exact title match + for (const result of results) { + const resultTitle = normalizeTitle(result.title || result.name); + + for (const title of anilistTitles) { + if (!title) continue; + + if (resultTitle === title) { + return result; // Early return for exact title match + } + } + } + + // Try high similarity title match + bestMatch = this.findBestSimilarityMatch(anilistTitles, results); + if (bestMatch) return bestMatch; + + // Just use the first result as a fallback + return results[0]; + } + + /** + * Find the best match based on title similarity + */ + findBestSimilarityMatch(titles, results) { + const normalizeTitle = t => t.toLowerCase().replace(/[^\w\s]/g, '').replace(/\s+/g, ' ').trim(); + let bestMatch = null; + let highestSimilarity = 0; + + for (const result of results) { + const resultTitle = normalizeTitle(result.title || result.name); + + for (const title of titles) { + if (!title) continue; + + const similarity = this.calculateTitleSimilarity(title, resultTitle); + if (similarity > highestSimilarity) { + highestSimilarity = similarity; + bestMatch = result; + } + } + } + + // Only return if we have a reasonably good match + return highestSimilarity > 0.6 ? bestMatch : null; + } + + /** + * Get the AnimePahe episodes for a match + */ + async getAnimePaheEpisodes(match) { + try { + const episodeData = await this.animePahe.scrapeEpisodes(match.id); + return { + totalEpisodes: episodeData.totalEpisodes || 0, + episodes: episodeData.episodes || [] + }; + } catch (error) { + console.error('Error getting AnimePahe episodes:', error.message); + return { totalEpisodes: 0, episodes: [] }; + } + } + + /** + * Calculate similarity between two titles + */ + calculateTitleSimilarity(title1, title2) { + if (!title1 || !title2) return 0; + + // Normalize both titles + const norm1 = title1.toLowerCase().replace(/[^\w\s]/g, '').replace(/\s+/g, ' ').trim(); + const norm2 = title2.toLowerCase().replace(/[^\w\s]/g, '').replace(/\s+/g, ' ').trim(); + + // Exact match is best + if (norm1 === norm2) return 1; + + // Split into words + const words1 = norm1.split(' ').filter(Boolean); + const words2 = norm2.split(' ').filter(Boolean); + + // Count common words + const commonCount = words1.filter(w => words2.includes(w)).length; + + // Weight by percentage of common words + return commonCount * 2 / (words1.length + words2.length); + } + + /** + * Extract year from title (e.g., "JoJo's Bizarre Adventure (2012)" -> 2012) + */ + extractYearFromTitle(item) { + if (!item) return null; + + // Extract the title string based on the input type + let titleStr = ''; + if (typeof item === 'string') { + titleStr = item; + } else if (typeof item === 'object') { + // Handle both anime objects and result objects + if (item.title) { + if (typeof item.title === 'string') { + titleStr = item.title; + } else if (typeof item.title === 'object') { + // AniList title object + titleStr = item.title.userPreferred || item.title.english || item.title.romaji || ''; + } + } else if (item.name) { + titleStr = item.name; + } + } + + if (!titleStr) return null; + + // Look for year pattern in parentheses or brackets + const yearMatches = titleStr.match(/[\(\[](\d{4})[\)\]]/); + + if (yearMatches && yearMatches[1]) { + const year = parseInt(yearMatches[1]); + if (!isNaN(year) && year > 1950 && year <= new Date().getFullYear()) { + return year; + } + } + + return null; + } + + /** + * Get a generic title by removing year information and other specific identifiers + */ + getGenericTitle(animeInfo) { + if (!animeInfo || !animeInfo.title) return null; + + const title = animeInfo.title.english || animeInfo.title.romaji || animeInfo.title.userPreferred; + if (!title) return null; + + // Remove year information and common specifiers + return title.replace(/\([^)]*\d{4}[^)]*\)/g, '').replace(/\[[^\]]*\d{4}[^\]]*\]/g, '').trim(); + } +} + +export default mapAnilistToAnimePahe; \ No newline at end of file diff --git a/src/mappers/hianime-mapper.js b/src/mappers/hianime-mapper.js new file mode 100644 index 0000000..404bd19 --- /dev/null +++ b/src/mappers/hianime-mapper.js @@ -0,0 +1,18 @@ +import { getEpisodesForAnime } from '../providers/hianime.js'; + +/** + * Maps an Anilist anime to HiAnime episodes + * @param {string|number} anilistId - The AniList ID to map + * @returns {Promise} The mapping result with episodes + */ +export async function mapAnilistToHiAnime(anilistId) { + try { + const episodes = await getEpisodesForAnime(anilistId); + return episodes; + } catch (error) { + console.error('Error mapping Anilist to HiAnime:', error); + throw error; + } +} + +export default mapAnilistToHiAnime; \ No newline at end of file diff --git a/src/mappers/index.js b/src/mappers/index.js new file mode 100644 index 0000000..0e73c68 --- /dev/null +++ b/src/mappers/index.js @@ -0,0 +1,9 @@ +import mapAnilistToAnimePahe from './animepahe-mapper.js'; +import mapAnilistToHiAnime from './hianime-mapper.js'; +import mapAnilistToAnimeKai from './animekai-mapper.js'; + +export { + mapAnilistToAnimePahe, + mapAnilistToHiAnime, + mapAnilistToAnimeKai +}; \ No newline at end of file diff --git a/src/providers/anilist.js b/src/providers/anilist.js new file mode 100644 index 0000000..d535b1a --- /dev/null +++ b/src/providers/anilist.js @@ -0,0 +1,103 @@ +import axios from 'axios'; +import { ANILIST_URL } from '../constants/api-constants.js'; + +export class AniList { + constructor() { + this.baseUrl = ANILIST_URL; + } + + async getAnimeInfo(id) { + try { + const query = ` + query ($id: Int) { + Media(id: $id, type: ANIME) { + id + title { + romaji + english + native + userPreferred + } + description + coverImage { + large + medium + } + bannerImage + episodes + status + season + seasonYear + startDate { + year + month + day + } + endDate { + year + month + day + } + genres + source + averageScore + synonyms + isAdult + format + type + } + } + `; + + const response = await axios.post(this.baseUrl, { + query, + variables: { id } + }); + + return response.data.data.Media; + } catch (error) { + console.error('Error fetching anime info from AniList:', error.message); + throw new Error('Failed to fetch anime info from AniList'); + } + } + + async searchAnime(query) { + try { + const gqlQuery = ` + query ($search: String) { + Page(page: 1, perPage: 10) { + media(search: $search, type: ANIME) { + id + title { + romaji + english + native + } + description + coverImage { + large + medium + } + episodes + status + genres + averageScore + } + } + } + `; + + const response = await axios.post(this.baseUrl, { + query: gqlQuery, + variables: { search: query } + }); + + return response.data.data.Page.media; + } catch (error) { + console.error('Error searching anime on AniList:', error.message); + throw new Error('Failed to search anime on AniList'); + } + } +} + +export default AniList; \ No newline at end of file diff --git a/src/providers/animekai.js b/src/providers/animekai.js new file mode 100644 index 0000000..bd8653a --- /dev/null +++ b/src/providers/animekai.js @@ -0,0 +1,61 @@ +import { ANIME } from '@consumet/extensions'; + +/** + * AnimeKai provider class that wraps the Consumet library + */ +export class AnimeKai { + constructor() { + this.client = new ANIME.AnimeKai(); + } + + /** + * Search for anime on AnimeKai + * @param {string} query - The search query + * @returns {Promise} Search results + */ + async search(query) { + try { + const results = await this.client.search(query); + return results; + } catch (error) { + console.error('Error searching AnimeKai:', error); + throw new Error('Failed to search AnimeKai'); + } + } + + /** + * Fetch anime information including episodes + * @param {string} id - The anime ID + * @returns {Promise} Anime info with episodes + */ + async fetchAnimeInfo(id) { + try { + const info = await this.client.fetchAnimeInfo(id); + return info; + } catch (error) { + console.error('Error fetching anime info from AnimeKai:', error); + throw new Error('Failed to fetch anime info from AnimeKai'); + } + } + + /** + * Fetch episode streaming sources + * @param {string} episodeId - The episode ID + * @param {string} server - Optional streaming server + * @param {boolean} dub - Whether to fetch dubbed sources (true) or subbed (false) + * @returns {Promise} Streaming sources + */ + async fetchEpisodeSources(episodeId, server = undefined, dub = false) { + try { + // Use the SubOrSub enum from Consumet if dub is true + const subOrDub = dub ? 'dub' : 'sub'; + const sources = await this.client.fetchEpisodeSources(episodeId, server, subOrDub); + return sources; + } catch (error) { + console.error('Error fetching episode sources from AnimeKai:', error); + throw new Error('Failed to fetch episode sources from AnimeKai'); + } + } +} + +export default AnimeKai; \ No newline at end of file diff --git a/src/providers/animepahe.js b/src/providers/animepahe.js new file mode 100644 index 0000000..b631565 --- /dev/null +++ b/src/providers/animepahe.js @@ -0,0 +1,281 @@ +import axios from 'axios'; +import * as cheerio from 'cheerio'; + +export class AnimePahe { + constructor() { + this.baseUrl = "https://animepahe.ru"; + this.sourceName = 'AnimePahe'; + this.isMulti = false; + } + + async scrapeSearchResults(query) { + try { + const response = await axios.get(`${this.baseUrl}/api?m=search&l=8&q=${query}`, { + headers: { + 'Cookie': "__ddg1_=;__ddg2_=;", + } + }); + + const jsonResult = response.data; + const searchResults = []; + + if (!jsonResult.data || !jsonResult.data.length) { + return searchResults; + } + + for (const item of jsonResult.data) { + searchResults.push({ + id: `${item.id}-${item.title}`, + title: item.title, + name: item.title, + type: item.type || 'TV', + episodes: item.episodes || 0, + status: item.status || 'Unknown', + season: item.season || 'Unknown', + year: item.year || 0, + score: item.score || 0, + poster: item.poster, + session: item.session, + episodes: { + sub: item.episodes || null, + dub: '??' + } + }); + } + + return searchResults; + } catch (error) { + console.error('Error searching AnimePahe:', error.message); + throw new Error('Failed to search AnimePahe'); + } + } + + async scrapeEpisodes(url) { + try { + const title = url.split('-')[1]; + const id = url.split('-')[0]; + + const session = await this._getSession(title, id); + const epUrl = `${this.baseUrl}/api?m=release&id=${session}&sort=episode_desc&page=1`; + + const response = await axios.get(epUrl, { + headers: { + 'Cookie': "__ddg1_=;__ddg2_=;", + } + }); + + return await this._recursiveFetchEpisodes(epUrl, JSON.stringify(response.data), session); + } catch (error) { + console.error('Error fetching episodes:', error.message); + throw new Error('Failed to fetch episodes'); + } + } + + async _recursiveFetchEpisodes(url, responseData, session) { + try { + const jsonResult = JSON.parse(responseData); + const page = jsonResult.current_page; + const hasNextPage = page < jsonResult.last_page; + let animeTitle = 'Could not fetch title'; + let episodes = []; + let animeDetails = { + type: 'TV', + status: 'Unknown', + season: 'Unknown', + year: 0, + score: 0 + }; + + for (const item of jsonResult.data) { + episodes.push({ + title: `Episode ${item.episode}`, + episodeId: `${session}/${item.session}`, + number: item.episode, + image: item.snapshot, + }); + } + + if (hasNextPage) { + const newUrl = `${url.split("&page=")[0]}&page=${page + 1}`; + const newResponse = await axios.get(newUrl, { + headers: { + 'Cookie': "__ddg1_=;__ddg2_=;", + } + }); + + const moreEpisodes = await this._recursiveFetchEpisodes(newUrl, JSON.stringify(newResponse.data), session); + episodes = [...episodes, ...moreEpisodes.episodes]; + animeTitle = moreEpisodes.title; + animeDetails = moreEpisodes.details || animeDetails; + } else { + const detailUrl = `https://animepahe.ru/a/${jsonResult.data[0].anime_id}`; + const newResponse = await axios.get(detailUrl, { + headers: { + 'Cookie': "__ddg1_=;__ddg2_=;", + } + }); + + if (newResponse.status === 200) { + const $ = cheerio.load(newResponse.data); + animeTitle = $('.title-wrapper span').text().trim() || 'Could not fetch title'; + + // Try to extract additional information + try { + // Parse type + const typeText = $('.col-sm-4.anime-info p:contains("Type")').text(); + if (typeText) { + animeDetails.type = typeText.replace('Type:', '').trim(); + } + + // Parse status + const statusText = $('.col-sm-4.anime-info p:contains("Status")').text(); + if (statusText) { + animeDetails.status = statusText.replace('Status:', '').trim(); + } + + // Parse season and year + const seasonText = $('.col-sm-4.anime-info p:contains("Season")').text(); + if (seasonText) { + const seasonMatch = seasonText.match(/Season:\s+(\w+)\s+(\d{4})/); + if (seasonMatch) { + animeDetails.season = seasonMatch[1]; + animeDetails.year = parseInt(seasonMatch[2]); + } + } + + // Parse score + const scoreText = $('.col-sm-4.anime-info p:contains("Score")').text(); + if (scoreText) { + const scoreMatch = scoreText.match(/Score:\s+([\d.]+)/); + if (scoreMatch) { + animeDetails.score = parseFloat(scoreMatch[1]); + } + } + } catch (err) { + console.error('Error parsing anime details:', err.message); + } + } + } + + return { + title: animeTitle, + session: session, + totalEpisodes: jsonResult.total, + details: animeDetails, + episodes: hasNextPage ? episodes : episodes.reverse(), + }; + } catch (error) { + console.error('Error recursively fetching episodes:', error.message); + throw new Error('Failed to fetch episodes recursively'); + } + } + + async scrapeEpisodesSrcs(episodeUrl, { category, lang } = {}) { + try { + const response = await axios.get(`${this.baseUrl}/play/${episodeUrl}`, { + headers: { + 'Cookie': "__ddg1_=;__ddg2_=;", + } + }); + + const $ = cheerio.load(response.data); + const buttons = $('#resolutionMenu > button'); + const videoLinks = []; + + for (let i = 0; i < buttons.length; i++) { + const btn = buttons[i]; + const kwikLink = $(btn).attr('data-src'); + const quality = $(btn).text(); + + // Instead of extracting, just return the link directly + videoLinks.push({ + quality: quality, + url: kwikLink, + referer: "https://kwik.cx", + }); + } + + const result = { + sources: videoLinks.length > 0 ? [{ url: videoLinks[0].url }] : [], + multiSrc: videoLinks, + }; + + return result; + } catch (error) { + console.error('Error fetching episode sources:', error.message); + throw new Error('Failed to fetch episode sources'); + } + } + + async _getSession(title, animeId) { + try { + const response = await axios.get(`${this.baseUrl}/api?m=search&q=${title}`, { + headers: { + 'Cookie': "__ddg1_=;__ddg2_=;", + } + }); + + const resBody = response.data; + if (!resBody.data || resBody.data.length === 0) { + throw new Error(`No results found for title: ${title}`); + } + + // First try: Direct ID match if provided and valid + if (animeId) { + const animeIdMatch = resBody.data.find(anime => String(anime.id) === String(animeId)); + if (animeIdMatch) { + return animeIdMatch.session; + } + } + + // Second try: Normalize titles and find best match + const normalizeTitle = t => t.toLowerCase().replace(/[^\w\s]/g, '').replace(/\s+/g, ' ').trim(); + const normalizedSearchTitle = normalizeTitle(title); + + let bestMatch = null; + let highestSimilarity = 0; + + for (const anime of resBody.data) { + const normalizedAnimeTitle = normalizeTitle(anime.title); + // Calculate simple similarity (more sophisticated than exact match) + let similarity = 0; + + // Exact match + if (normalizedAnimeTitle === normalizedSearchTitle) { + similarity = 1; + } + // Contains match + else if (normalizedAnimeTitle.includes(normalizedSearchTitle) || + normalizedSearchTitle.includes(normalizedAnimeTitle)) { + const lengthRatio = Math.min(normalizedAnimeTitle.length, normalizedSearchTitle.length) / + Math.max(normalizedAnimeTitle.length, normalizedSearchTitle.length); + similarity = 0.8 * lengthRatio; + } + // Word match + else { + const searchWords = normalizedSearchTitle.split(' '); + const animeWords = normalizedAnimeTitle.split(' '); + const commonWords = searchWords.filter(word => animeWords.includes(word)); + similarity = commonWords.length / Math.max(searchWords.length, animeWords.length); + } + + if (similarity > highestSimilarity) { + highestSimilarity = similarity; + bestMatch = anime; + } + } + + if (bestMatch && highestSimilarity > 0.5) { + return bestMatch.session; + } + + // Default to first result if no good match found + return resBody.data[0].session; + } catch (error) { + console.error('Error getting session:', error.message); + throw new Error('Failed to get session'); + } + } +} + +export default AnimePahe; \ No newline at end of file diff --git a/src/providers/hianime-servers.js b/src/providers/hianime-servers.js new file mode 100644 index 0000000..cc6e1be --- /dev/null +++ b/src/providers/hianime-servers.js @@ -0,0 +1,136 @@ +import { load } from 'cheerio'; +import { client } from '../utils/client.js'; +import { HIANIME_URL } from '../constants/api-constants.js'; + +/** + * Get all available servers for a HiAnime episode + * @param {string} episodeId - Episode ID in format "anime-title-123?ep=456" + * @returns {Promise} Object containing sub, dub, and raw server lists + */ +export async function getEpisodeServers(episodeId) { + const result = { + sub: [], + dub: [], + raw: [], + episodeId, + episodeNo: 0, + }; + + try { + if (!episodeId || episodeId.trim() === "" || episodeId.indexOf("?ep=") === -1) { + throw new Error("Invalid anime episode ID"); + } + + const epId = episodeId.split("?ep=")[1]; + const ajaxUrl = `${HIANIME_URL}/ajax/v2/episode/servers?episodeId=${epId}`; + + const { data } = await client.get(ajaxUrl, { + headers: { + "X-Requested-With": "XMLHttpRequest", + "Referer": `${HIANIME_URL}/watch/${episodeId}` + } + }); + + if (!data.html) { + throw new Error("No server data found"); + } + + const $ = load(data.html); + + // Extract episode number + const epNoSelector = ".server-notice strong"; + result.episodeNo = Number($(epNoSelector).text().split(" ").pop()) || 0; + + // Extract SUB servers + $(`.ps_-block.ps_-block-sub.servers-sub .ps__-list .server-item`).each((_, el) => { + result.sub.push({ + serverName: $(el).find("a").text().toLowerCase().trim(), + serverId: Number($(el)?.attr("data-server-id")?.trim()) || null, + }); + }); + + // Extract DUB servers + $(`.ps_-block.ps_-block-sub.servers-dub .ps__-list .server-item`).each((_, el) => { + result.dub.push({ + serverName: $(el).find("a").text().toLowerCase().trim(), + serverId: Number($(el)?.attr("data-server-id")?.trim()) || null, + }); + }); + + // Extract RAW servers + $(`.ps_-block.ps_-block-sub.servers-raw .ps__-list .server-item`).each((_, el) => { + result.raw.push({ + serverName: $(el).find("a").text().toLowerCase().trim(), + serverId: Number($(el)?.attr("data-server-id")?.trim()) || null, + }); + }); + + return result; + } catch (error) { + console.error('Error fetching episode servers:', error.message); + throw error; + } +} + +/** + * Get streaming sources for a HiAnime episode + * @param {string} episodeId - Episode ID in format "anime-title-123?ep=456" + * @param {string} serverName - Name of the server to get sources from + * @param {string} category - Type of episode: 'sub', 'dub', or 'raw' + * @returns {Promise} Object containing sources and related metadata + */ +export async function getEpisodeSources(episodeId, serverName = 'vidstreaming', category = 'sub') { + try { + if (!episodeId || episodeId.trim() === "" || episodeId.indexOf("?ep=") === -1) { + throw new Error("Invalid anime episode ID"); + } + + // First get available servers + const servers = await getEpisodeServers(episodeId); + + // Find the requested server + const serverList = servers[category] || []; + const server = serverList.find(s => s.serverName.toLowerCase() === serverName.toLowerCase()); + + if (!server) { + throw new Error(`Server '${serverName}' not found for category '${category}'`); + } + + const epId = episodeId.split("?ep=")[1]; + const serverId = server.serverId; + + // Fetch the source URL + const { data } = await client.get( + `${HIANIME_URL}/ajax/v2/episode/sources?id=${epId}&server=${serverId}`, + { + headers: { + "X-Requested-With": "XMLHttpRequest", + "Referer": `${HIANIME_URL}/watch/${episodeId}` + } + } + ); + + // Return sources format similar to the AniWatch package + return { + headers: { + Referer: data.link, + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36" + }, + sources: [ + { + url: data.link, + isM3U8: data.link.includes('.m3u8'), + } + ], + subtitles: [], + }; + } catch (error) { + console.error('Error fetching episode sources:', error.message); + throw error; + } +} + +export default { + getEpisodeServers, + getEpisodeSources +}; \ No newline at end of file diff --git a/src/providers/hianime.js b/src/providers/hianime.js new file mode 100644 index 0000000..9e1561a --- /dev/null +++ b/src/providers/hianime.js @@ -0,0 +1,381 @@ +import { load } from 'cheerio'; +import * as stringSimilarity from 'string-similarity-js'; +import { client } from '../utils/client.js'; +import { ANILIST_URL, ANILIST_QUERY, HIANIME_URL, ANIZIP_URL } from '../constants/api-constants.js'; + +// Common word replacements in anime titles - moved outside to avoid recreation +const TITLE_REPLACEMENTS = { + 'season': ['s', 'sz'], + 's': ['season', 'sz'], + 'sz': ['season', 's'], + 'two': ['2', 'ii'], + 'three': ['3', 'iii'], + 'four': ['4', 'iv'], + 'part': ['pt', 'p'], + 'episode': ['ep'], + 'chapters': ['ch'], + 'chapter': ['ch'], + 'first': ['1', 'i'], + 'second': ['2', 'ii'], + 'third': ['3', 'iii'], + 'fourth': ['4', 'iv'] +}; + +// Cache for word variations to avoid recalculating +const wordVariationsCache = new Map(); + +// Helper function to normalize text for comparison +const normalizeText = (text) => { + return text.toLowerCase() + .replace(/[^\w\s]/g, '') + .replace(/\s+/g, ' ') + .trim(); +}; + +// Get word variations with caching +const getWordVariations = (word) => { + const cacheKey = word.toLowerCase(); + if (wordVariationsCache.has(cacheKey)) { + return wordVariationsCache.get(cacheKey); + } + + const variations = new Set([word]); + const normalized = normalizeText(word); + variations.add(normalized); + + const withoutNumbers = word.replace(/\d+/g, '').trim(); + if (withoutNumbers !== word) variations.add(withoutNumbers); + + for (const [key, values] of Object.entries(TITLE_REPLACEMENTS)) { + if (normalized === key) { + values.forEach(v => variations.add(v)); + } else if (values.includes(normalized)) { + variations.add(key); + values.forEach(v => variations.add(v)); + } + } + + const result = [...variations]; + wordVariationsCache.set(cacheKey, result); + return result; +}; + +// Fetch anime info from Anilist +async function getAnimeInfo(anilistId) { + try { + const response = await client.post(ANILIST_URL, { + query: ANILIST_QUERY, + variables: { id: anilistId } + }); + + const animeData = response.data.data.Media; + if (!animeData) return null; + + // Get all possible titles and synonyms at once + const allTitles = new Set([ + ...(animeData.synonyms || []), + animeData.title.english, + animeData.title.romaji + ].filter(Boolean) // Remove nulls/undefined + .filter(t => !(/[\u4E00-\u9FFF]/.test(t)))); // Remove Chinese titles + + return { + id: animeData.id, + title: animeData.title, + episodes: animeData.episodes, + synonyms: [...allTitles] + }; + } catch (error) { + console.error('Error fetching anime info:', error); + return null; + } +} + +// Calculate similarity score between two titles +const calculateTitleScore = (searchTitle, hianimeTitle) => { + const normalizedSearch = normalizeText(searchTitle); + const normalizedTitle = normalizeText(hianimeTitle); + + // Quick exact match check + if (normalizedSearch === normalizedTitle) { + return 1; + } + + const searchWords = normalizedSearch.split(' '); + const titleWords = normalizedTitle.split(' '); + + // Pre-calculate word variations for both titles + const searchVariations = searchWords.map(w => getWordVariations(w)); + const titleVariations = titleWords.map(w => getWordVariations(w)); + + let matches = 0; + let partialMatches = 0; + + for (let i = 0; i < searchVariations.length; i++) { + let bestWordMatch = 0; + + for (let j = 0; j < titleVariations.length; j++) { + for (const searchVar of searchVariations[i]) { + for (const titleVar of titleVariations[j]) { + if (searchVar === titleVar) { + bestWordMatch = 1; + break; + } + + if (searchVar.includes(titleVar) || titleVar.includes(searchVar)) { + const matchLength = Math.min(searchVar.length, titleVar.length); + const maxLength = Math.max(searchVar.length, titleVar.length); + bestWordMatch = Math.max(bestWordMatch, matchLength / maxLength); + } + } + if (bestWordMatch === 1) break; + } + if (bestWordMatch === 1) break; + } + + if (bestWordMatch === 1) { + matches++; + } else if (bestWordMatch > 0) { + partialMatches += bestWordMatch; + } + } + + const wordMatchScore = (matches + (partialMatches * 0.5)) / searchWords.length; + const similarity = stringSimilarity.stringSimilarity(normalizedSearch, normalizedTitle); + + return (wordMatchScore * 0.7) + (similarity * 0.3); +}; + +// Search anime on Hianime and get the most similar match +async function searchAnime(title, animeInfo) { + try { + let bestMatch = { score: 0, id: null }; + let seriesMatches = []; + let year = null; + + // Extract year from title if present (e.g., 2011 from "Hunter x Hunter (2011)") + const yearMatch = title.match(/\((\d{4})\)/); + if (yearMatch && yearMatch[1]) { + year = yearMatch[1]; + } + + // Try each title in order of priority + const titlesToTry = [ + animeInfo.title.english, + animeInfo.title.romaji, + ...animeInfo.synonyms + ].filter(Boolean) + .filter((t, i, arr) => arr.indexOf(t) === i); + + for (const searchTitle of titlesToTry) { + const searchUrl = `${HIANIME_URL}/search?keyword=${encodeURIComponent(searchTitle)}`; + + const response = await client.get(searchUrl); + const $ = load(response.data); + + $('.film_list-wrap > .flw-item').each((_, item) => { + const el = $(item).find('.film-detail .film-name a'); + const hianimeTitle = el.text().trim(); + const hianimeId = el.attr('href')?.split('/').pop()?.split('?')[0]; + + // Check the data-jname attribute which may contain year information + const jname = el.attr('data-jname')?.trim(); + + // Check if this is a TV series + const isTV = $(item).find('.fd-infor .fdi-item').first().text().trim() === 'TV'; + + // Check episodes count to match with expected count from Anilist + const episodesText = $(item).find('.tick-item.tick-eps').text().trim(); + const episodesCount = episodesText ? parseInt(episodesText, 10) : 0; + + if (hianimeId) { + // Calculate base similarity score + let score = calculateTitleScore(searchTitle, hianimeTitle); + + // Boost score for TV series when searching for TV series + if (isTV && animeInfo.episodes > 12) { + score += 0.1; + } + + // Boost score if episodes count matches Anilist data + if (animeInfo.episodes && episodesCount === animeInfo.episodes) { + score += 0.2; + } + + // Special handling for year matching + if (year) { + // Check if jname contains the year + if (jname && jname.includes(year)) { + score += 0.3; + } + } + + // Penalize movies when looking for series with episodes + const isMovie = $(item).find('.fd-infor .fdi-item').first().text().trim() === 'Movie'; + if (isMovie && animeInfo.episodes > 1) { + score -= 0.3; + } + + if (score > 0.5) { + seriesMatches.push({ + title: hianimeTitle, + id: hianimeId, + score, + isMovie, + isTV, + episodes: episodesCount, + jname + }); + } + + if (score > bestMatch.score) { + bestMatch = { score, id: hianimeId }; + } + } + }); + + // Stop if we found a very good match + if (bestMatch.score > 0.85) { + return bestMatch.id; + } + } + + // Special handling for Hunter x Hunter 2011 version + const hxh2011Matches = seriesMatches.filter(match => + match.isTV && + match.episodes >= 100 && + (match.jname?.includes('2011') || match.title.toLowerCase().includes('hunter x hunter')) + ); + + if (hxh2011Matches.length > 0 && year === '2011') { + const bestHxH = hxh2011Matches.sort((a, b) => b.score - a.score)[0]; + return bestHxH.id; + } + + // If we have multiple matches, prioritize non-movies and TV series + if (seriesMatches.length > 0) { + // First prioritize by TV series with matching episode count + const exactEpisodeMatches = seriesMatches.filter(m => + m.isTV && animeInfo.episodes && m.episodes === animeInfo.episodes + ); + + if (exactEpisodeMatches.length > 0) { + const bestExactMatch = exactEpisodeMatches.sort((a, b) => b.score - a.score)[0]; + return bestExactMatch.id; + } + + // Sort by score descending + seriesMatches.sort((a, b) => b.score - a.score); + + // Prioritize TV series over others if scores are close + const bestTV = seriesMatches.filter(m => m.isTV)[0]; + const bestOverall = seriesMatches[0]; + + if (bestTV && bestOverall.score - bestTV.score < 0.2) { + return bestTV.id; + } + + // Otherwise return best match + return bestOverall.id; + } + + return bestMatch.score > 0.4 ? bestMatch.id : null; + } catch (error) { + console.error('Error searching Hianime:', error); + return null; + } +} + +// Get episode IDs for an anime +async function getEpisodeIds(animeId, anilistId) { + try { + const episodeUrl = `${HIANIME_URL}/ajax/v2/episode/list/${animeId.split('-').pop()}`; + + // Fetch additional metadata from ani.zip + const anizipUrl = `${ANIZIP_URL}?anilist_id=${anilistId}`; + const [episodeResponse, anizipResponse] = await Promise.all([ + client.get(episodeUrl, { + headers: { + 'Referer': `${HIANIME_URL}/watch/${animeId}`, + 'X-Requested-With': 'XMLHttpRequest' + } + }), + client.get(anizipUrl) + ]); + + if (!episodeResponse.data.html) { + return { totalEpisodes: 0, episodes: [] }; + } + + const $ = load(episodeResponse.data.html); + const episodes = []; + const anizipData = anizipResponse.data; + + $('#detail-ss-list div.ss-list a').each((i, el) => { + const $el = $(el); + const href = $el.attr('href'); + if (!href) return; + + const fullPath = href.split('/').pop(); + const episodeNumber = i + 1; + const anizipEpisode = anizipData?.episodes?.[episodeNumber]; + + if (fullPath) { + episodes.push({ + episodeId: `${animeId}?ep=${fullPath.split('?ep=')[1]}`, + title: anizipEpisode?.title?.en || $el.attr('title') || '', + number: episodeNumber, + image: anizipEpisode?.image || null, + overview: anizipEpisode?.overview || null, + airDate: anizipEpisode?.airDate || null, + runtime: anizipEpisode?.runtime || null + }); + } + }); + + return { + totalEpisodes: episodes.length, + episodes, + titles: anizipData?.titles || null, + images: anizipData?.images || null, + mappings: anizipData?.mappings || null + }; + } catch (error) { + console.error('Error fetching episodes:', error); + return { totalEpisodes: 0, episodes: [] }; + } +} + +// Main function to get episodes for an Anilist ID +export async function getEpisodesForAnime(anilistId) { + try { + const animeInfo = await getAnimeInfo(anilistId); + if (!animeInfo) { + throw new Error('Could not fetch anime info from Anilist'); + } + + const title = animeInfo.title.english || animeInfo.title.romaji; + if (!title) { + throw new Error('No English or romaji title found'); + } + + const hianimeId = await searchAnime(title, animeInfo); + if (!hianimeId) { + throw new Error('Could not find anime on Hianime'); + } + + const episodes = await getEpisodeIds(hianimeId, anilistId); + if (!episodes || episodes.totalEpisodes === 0) { + throw new Error('Could not fetch episodes'); + } + + return { anilistId, hianimeId, title, ...episodes }; + } catch (error) { + console.error('Error in getEpisodesForAnime:', error); + throw error; + } +} + +export default { + getEpisodesForAnime +}; \ No newline at end of file diff --git a/src/providers/index.js b/src/providers/index.js new file mode 100644 index 0000000..73afef6 --- /dev/null +++ b/src/providers/index.js @@ -0,0 +1,11 @@ +import AniList from './anilist.js'; +import AnimePahe from './animepahe.js'; +import HiAnime from './hianime.js'; +import AnimeKai from './animekai.js'; + +export { + AniList, + AnimePahe, + HiAnime, + AnimeKai +}; \ No newline at end of file diff --git a/src/utils/cache.js b/src/utils/cache.js new file mode 100644 index 0000000..896f3a3 --- /dev/null +++ b/src/utils/cache.js @@ -0,0 +1,43 @@ +import NodeCache from 'node-cache'; + +// Create a new cache instance +const apiCache = new NodeCache({ stdTTL: 300 }); // Default TTL 5 minutes + +/** + * Middleware for caching API responses + * @param {string} duration Cache duration in format: '5 minutes', '1 hour', etc. + */ +export function cache(duration) { + return (req, res, next) => { + // Skip caching for non-GET requests + if (req.method !== 'GET') { + return next(); + } + + // Create a unique cache key from the request URL + const key = req.originalUrl || req.url; + + // Check if we have a cached response for this request + const cachedResponse = apiCache.get(key); + + if (cachedResponse) { + console.log(`Cache hit for: ${key}`); + return res.json(cachedResponse); + } + + // Store the original json method + const originalJson = res.json; + + // Override the json method to cache the response + res.json = function(data) { + // Cache the data + console.log(`Caching response for: ${key}`); + apiCache.set(key, data); + + // Call the original json method + return originalJson.call(this, data); + }; + + next(); + }; +} \ No newline at end of file diff --git a/src/utils/client.js b/src/utils/client.js new file mode 100644 index 0000000..76c4b44 --- /dev/null +++ b/src/utils/client.js @@ -0,0 +1,12 @@ +import axios from 'axios'; + +export const client = axios.create({ + headers: { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'en-US,en;q=0.9' + }, + timeout: 10000 +}); + +export default client; \ No newline at end of file diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..8040a64 --- /dev/null +++ b/vercel.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "builds": [ + { + "src": "src/index.js", + "use": "@vercel/node" + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "src/index.js" + } + ] +} \ No newline at end of file