diff --git a/package.json b/package.json index 0217810..b26ec52 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,7 @@ "@types/socket.io": "^3.0.2", "@types/socket.io-client": "^3.0.0", "@types/through2": "^2.0.36", - "airdcpp-extension": "^1.5.0", - "airdcpp-extension-settings": "^1.2.1", + "airdcpp-apisocket": "^2.4.1", "antd": "^4.16.5", "babel-polyfill": "^6.26.0", "better-docs": "^2.3.2", @@ -56,6 +55,8 @@ "socket.io-client": "^4.1.2", "threetwo-ui-typings": "^1.0.1", "voca": "^1.4.0", + "websocket": "^1.0.34", + "ws": "^7.5.3", "ws-calibre": "bluelovers/ws-calibre", "xregexp": "^5.0.2" }, diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index ac2afcc..d10d4a6 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -10,7 +10,6 @@ import { CV_SEARCH_SUCCESS, CV_CLEANUP, } from "../constants/action-types"; - import { refineQuery } from "../shared/utils/filenameparser.utils"; import { matchScorer } from "../shared/utils/searchmatchscorer.utils"; diff --git a/src/server/index.ts b/src/server/index.ts index 53803ac..336cb3b 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -11,6 +11,11 @@ import { EnumLinkRel } from "opds-extra/lib/const"; import { async as FastGlob } from "@bluelovers/fast-glob/bluebird"; import { Entry, Feed } from "opds-extra/lib/v1"; import { Link } from "opds-extra/lib/v1/core"; +import SocketService from "./utils/airdcpp.socket.service"; + +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} // call express const app: Express = express(); // define our app using express @@ -94,8 +99,43 @@ app.get("/", (req: Request, res: Response) => { console.log("sending index.html"); res.sendFile("/dist/index.html"); }); - +interface SearchInstance { + current_search_id: string; + expires_in: number; + id: number; + owner: string; + query: Record; + queue_time: number; + queued_count: number; + result_count: number; + searches_sent_ago: number; +} app.use(opdsRouter()); +const foo = SocketService.connect("admin", "password"); +foo.then(async (data) => { + const instance: SearchInstance = await SocketService.post("search"); + await sleep(10000); + + const searchInfo = await SocketService.post( + `search/${instance.id}/hub_search`, + { + query: { + pattern: "H.P. Lovecraft", + file_type: "compressed", + extensions: ["cbz", "cbr"], + }, + hub_urls: [ + "nmdcs://piter.feardc.net:411", + "dchub://dc.rutrack.net", + "dchub://dc.elitedc.ru", + ], + priority: 1, + }, + ); + await sleep(10000); + const results = await SocketService.get(`search/${instance.id}/results/0/5`); + console.log(results); +}); // REGISTER ROUTES // all of the routes will be prefixed with /api diff --git a/tsconfig.server.json b/tsconfig.server.json index ab8e057..d941af8 100644 --- a/tsconfig.server.json +++ b/tsconfig.server.json @@ -3,6 +3,7 @@ "$schema": "https://json.schemastore.org/tsconfig", "display": "Node 12", "compilerOptions": { + "lib": ["DOM"], "module": "commonjs", "target": "es2019", "strict": true, @@ -16,10 +17,6 @@ "noImplicitAny": false }, "compileOnSave": true, - "exclude": [ - "./src/client" - ], - "include": [ - "./src/server" - ] -} \ No newline at end of file + "exclude": ["./src/client"], + "include": ["./src/server"] +} diff --git a/yarn-error.log b/yarn-error.log index 7701093..fdec35b 100644 --- a/yarn-error.log +++ b/yarn-error.log @@ -1,5 +1,5 @@ Arguments: - /Users/rishi/.nvm/versions/node/v12.21.0/bin/node /Users/rishi/.yarn/bin/yarn.js add @bluelovers/fast-glob/bluebird + /Users/rishi/.nvm/versions/node/v12.21.0/bin/node /Users/rishi/.yarn/bin/yarn.js add airdcpp-apisocket-js PATH: /Users/rishi/.yarn/bin:/Users/rishi/.config/yarn/global/node_modules/.bin:/Users/rishi/.nvm/versions/node/v12.21.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin @@ -14,8 +14,8 @@ Platform: darwin x64 Trace: - Error: https://registry.yarnpkg.com/@bluelovers%2ffast-glob/bluebird: Request "https://registry.yarnpkg.com/@bluelovers%2ffast-glob/bluebird" returned a 405 - at Request.params.callback [as _callback] (/Users/rishi/.yarn/lib/cli.js:66997:18) + Error: https://registry.yarnpkg.com/airdcpp-apisocket-js: Not found + at Request.params.callback [as _callback] (/Users/rishi/.yarn/lib/cli.js:66988:18) at Request.self.callback (/Users/rishi/.yarn/lib/cli.js:140749:22) at Request.emit (events.js:314:20) at Request. (/Users/rishi/.yarn/lib/cli.js:141721:10) @@ -46,7 +46,9 @@ npm manifest: "license": "MIT", "dependencies": { "@babel/runtime": "^7.13.17", + "@bluelovers/fast-glob": "^3.0.4", "@types/event-stream": "^3.3.34", + "@types/mime-types": "^2.1.0", "@types/react": "^17.0.3", "@types/react-dom": "^17.0.2", "@types/react-redux": "^7.1.16", @@ -66,6 +68,7 @@ npm manifest: "fastest-validator": "^1.11.0", "final-form": "^4.20.2", "fs-extra": "^9.1.0", + "http-response-stream": "^1.0.7", "imghash": "^0.0.8", "jsdoc": "^3.6.7", "opds-extra": "^3.0.9", @@ -1227,6 +1230,14 @@ Lockfile: resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== + "@bluelovers/fast-glob@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@bluelovers/fast-glob/-/fast-glob-3.0.4.tgz#6bb11e3e0274451a2b1362763e85fd50120f7ea3" + integrity sha512-djAOOjDWXolYArm5NXxOIX7Q7OGhAaRtMs5F968OxelWkMUU6PyU6tS66CFykVON4U5y8jXcsnVAFCaeuf1nEA== + dependencies: + bluebird "^3" + fast-glob "^3" + "@canvas/image-data@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@canvas/image-data/-/image-data-1.0.0.tgz#3bd2cd856e13fc9e2c25feff360a4056857b0367" @@ -2005,6 +2016,11 @@ Lockfile: resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.171.tgz#f01b3a5fe3499e34b622c362a46a609fdb23573b" integrity sha512-7eQ2xYLLI/LsicL2nejW9Wyko3lcpN6O/z0ZLHrEQsg280zIdCv1t/0m6UtBjUHokCGBQ3gYTbHzDkZ1xOBwwg== + "@types/mime-types@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@types/mime-types/-/mime-types-2.1.0.tgz#9ca52cda363f699c69466c2a6ccdaad913ea7a73" + integrity sha1-nKUs2jY/aZxpRmwqbM2q2RPqenM= + "@types/mime@^1": version "1.3.2" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a" @@ -3420,7 +3436,7 @@ Lockfile: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== - bluebird@^3.4.7, bluebird@^3.5.1, bluebird@^3.7.2, bluebird@~3.7.2: + bluebird@^3, bluebird@^3.4.7, bluebird@^3.5.1, bluebird@^3.7.2, bluebird@~3.7.2: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== @@ -5902,7 +5918,7 @@ Lockfile: resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== - fast-glob@^3.0.3, fast-glob@^3.1.1: + fast-glob@^3, fast-glob@^3.0.3, fast-glob@^3.1.1: version "3.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q== @@ -6924,6 +6940,13 @@ Lockfile: follow-redirects "^1.0.0" requires-port "^1.0.0" + http-response-stream@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/http-response-stream/-/http-response-stream-1.0.7.tgz#07e6104a8431c0788175578b3aebe3f0c7cf9925" + integrity sha512-d6PRAbo67f60BboWpG+RXS1wjPcWcMY6kq4LsACdUYscoh6Kw9HluRegy1/zweetrnatMxtD/dxtn1mO7XVvlQ== + dependencies: + tslib "^2.3.0" + http-signature@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" diff --git a/yarn.lock b/yarn.lock index b8331cc..d949594 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2371,25 +2371,6 @@ airdcpp-apisocket@^2.4.1: is-in-browser "^1.1.3" promise "^8.1.0" -airdcpp-extension-settings@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/airdcpp-extension-settings/-/airdcpp-extension-settings-1.2.1.tgz#361fd8f4e52b78fb9f586d60d9d3b3d74f30d79e" - integrity sha512-tMAkVOu3qf/w0C/GD0dhCsovDZaZOVu2gomZq8HfWknwshpXK5qEqMEyrlIVauuezaxdZJXqEfG6dZb3Y/+K+g== - dependencies: - "@babel/runtime" "^7.12.5" - invariant "^2.2.4" - -airdcpp-extension@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/airdcpp-extension/-/airdcpp-extension-1.5.0.tgz#f1a2f62113b6682ddbdbbe105d45e5b4051979c6" - integrity sha512-5hxT2xTq3Z15yxLYfBtiFs4H4zZc5uJuBvX52qYzbOHppLsOcViuS9HyLmmf+AV/5AWFAl85iAqDxwai59w71w== - dependencies: - airdcpp-apisocket "^2.4.1" - chalk "^4.1.0" - minimist "^1.2.5" - mkdirp "^1.0.4" - websocket "^1.0.33" - ajv-errors@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d" @@ -14200,7 +14181,7 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== -websocket@^1.0.33: +websocket@^1.0.34: version "1.0.34" resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.34.tgz#2bdc2602c08bf2c82253b730655c0ef7dcab3111" integrity sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ== @@ -14383,7 +14364,7 @@ ws@^6.2.1: dependencies: async-limiter "~1.0.0" -ws@^7.4.5: +ws@^7.4.5, ws@^7.5.3: version "7.5.3" resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.3.tgz#160835b63c7d97bfab418fc1b8a9fced2ac01a74" integrity sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==