From 91242164f546da56fcae7918069dc201e2a320a3 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 9 Jan 2026 03:22:31 +0100 Subject: [PATCH] Initial commit --- .editorconfig | 10 + .gitignore | 14 + config.toml | 6 + demon.rb | 62 ++ package-lock.json | 986 +++++++++++++++++++++++++++ package.json | 23 + run.sh | 13 + src/dlmanager.ts | 183 +++++ src/download.ts | 134 ++++ src/index.ts | 110 +++ src/movies.ts | 38 ++ src/movies/kinogo.biz.ts | 65 ++ tsconfig.json | 42 ++ util/__pycache__/dlp.cpython-313.pyc | Bin 0 -> 2394 bytes util/dlp.py | 75 ++ 15 files changed, 1761 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 config.toml create mode 100755 demon.rb create mode 100644 package-lock.json create mode 100644 package.json create mode 100755 run.sh create mode 100644 src/dlmanager.ts create mode 100644 src/download.ts create mode 100644 src/index.ts create mode 100644 src/movies.ts create mode 100644 src/movies/kinogo.biz.ts create mode 100644 tsconfig.json create mode 100644 util/__pycache__/dlp.cpython-313.pyc create mode 100644 util/dlp.py diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..af92807 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# Top-most EditorConfig file +root = true + +# Use same style for all files +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf6607f --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# NodeJS & JavaScript +node_modules/ +dist/ +tsconfig.tsbuildinfo + +# Python +env/ + +# Output +dist/ +download/ + +# Debug +test diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..b6d5dc9 --- /dev/null +++ b/config.toml @@ -0,0 +1,6 @@ +[server] +port = 8080 + +[download] +path = "./download/" +parallel = 1 diff --git a/demon.rb b/demon.rb new file mode 100755 index 0000000..eb6c420 --- /dev/null +++ b/demon.rb @@ -0,0 +1,62 @@ +#!/bin/env ruby + +require 'colorize' +require 'net/http' +require 'uri' +require 'json' + +current = `git rev-parse HEAD`.strip +latest = current +api_url = URI.parse 'https://lesbian.ddns.net/api/v1/repos/tomas/freestuff/commits?limit=1' + +puts '[Daemon] '.red + 'Running WebDL daemon' +while true do + print '[Daemon] '.red + 'Starting server...' + out_thread = nil + IO.popen('npm start', 'w+') do |io| + puts ' Ok!'.green + + out_thread = Thread.new do + begin + for line in io.each_line do + puts '[WebDL] '.blue + line + end + rescue + # Pipe closed + end + end + + while true do + sleep 10 + + print '[Daemon] '.red + 'Checking for updates...' + res = Net::HTTP.get_response api_url + data = JSON.parse res.body + latest = data[0]['sha'] + + if current == latest then + puts ' Already latest' + else + puts ' Update available!'.cyan + puts '[Daemon] '.red + 'Signaled server to shutdown' + puts 'Signal' + io.puts 'shutdown' + io.flush + break + end + end + end + + puts '[Daemon] '.red + 'Server closed' + out_thread.join + + if not current == latest then + puts '[Daemon] '.red + 'Updating...' + ok = system 'git pull' + if ok then + current = `git rev-parse HEAD`.strip + else + puts '[Daemon] '.red + 'Update failed!'.yellow + end + end +end diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..9a73bd7 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,986 @@ +{ + "name": "webdl", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "webdl", + "license": "MIT", + "dependencies": { + "@types/uuid": "^10.0.0", + "express": "^5.2.1", + "mime-detect": "^1.3.0", + "toml": "^3.0.0", + "typescript": "^5.9.3", + "uuid": "^13.0.0" + }, + "devDependencies": { + "@types/express": "^5.0.6", + "@types/node": "^25.0.3" + } + }, + "node_modules/@types/body-parser": { + "version": "1.19.6", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz", + "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/express": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz", + "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^5.0.0", + "@types/serve-static": "^2" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.1.0.tgz", + "integrity": "sha512-jnHMsrd0Mwa9Cf4IdOzbz543y4XJepXrbia2T4b6+spXC2We3t1y6K44D3mR8XMFSXMCf3/l7rCgddfx7UNVBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "node_modules/@types/http-errors": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", + "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "25.0.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.3.tgz", + "integrity": "sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, + "node_modules/@types/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", + "integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/http-errors": "*", + "@types/node": "*" + } + }, + "node_modules/@types/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==", + "license": "MIT" + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/body-parser": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", + "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.1", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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/content-disposition": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", + "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "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/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/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/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": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "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/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-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/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/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.1.tgz", + "integrity": "sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "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": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-detect": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mime-detect/-/mime-detect-1.3.0.tgz", + "integrity": "sha512-SFFkIWONYQdDoiA3iq2abd68kCy+ifzsgWyytMDa/v8Jiu5UhVhgb4upoKDVKTlCz663jqM9PksyM99m+MnSaQ==", + "license": "BSD-2-Clause", + "dependencies": { + "mime-db": "^1.52.0" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "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/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "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": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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/qs": { + "version": "6.14.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", + "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "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": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "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/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "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/toml": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", + "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==", + "license": "MIT" + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" + }, + "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/uuid": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz", + "integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist-node/bin/uuid" + } + }, + "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/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..5c195d4 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "webdl", + "license": "MIT", + "author": "Tomas", + "type": "module", + "main": "dist/index.js", + "scripts": { + "start": "npm run build && node dist/index.js", + "build": "npx tsc" + }, + "dependencies": { + "@types/uuid": "^10.0.0", + "express": "^5.2.1", + "mime-detect": "^1.3.0", + "toml": "^3.0.0", + "typescript": "^5.9.3", + "uuid": "^13.0.0" + }, + "devDependencies": { + "@types/express": "^5.0.6", + "@types/node": "^25.0.3" + } +} diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..e74e874 --- /dev/null +++ b/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +source env/bin/activate + +npm run build + +line="" +for n in `seq $(tput cols)`; do + line="$line=" +done +echo $line + +node dist/index.js diff --git a/src/dlmanager.ts b/src/dlmanager.ts new file mode 100644 index 0000000..1f09ee3 --- /dev/null +++ b/src/dlmanager.ts @@ -0,0 +1,183 @@ +import type { IDownload } from "./download.ts"; +import { Download } from "./download.js"; +import { Readable } from "node:stream"; +import { v4 as v4uuid } from "uuid"; + + +function uuid(): string +{ + return v4uuid().replaceAll("-", ""); +} + + +interface DownloadOrder +{ + id: string; + url: string; + outfile?: string; + en: Promise; + __en: (en: DownloadEntity)=>void; + __download: ()=>IDownload; +} + +interface DownloadEntity +{ + dl: IDownload; + fin: boolean; +} + +interface DownloadStatus +{ + url: string; + filename?: string; + finished: boolean; + total: number; + received: number; + speed: number; +} + + +export class DownloadManager +{ + constructor(parallel_downloads: number) + { + this.__max_downloads = parallel_downloads; + } + + download(url: string, outfile?: string): string + { + return this.enqueue(() => new Download(url, outfile), url, outfile); + } + + enqueue(download: ()=>IDownload, url: string, outfile?: string): string + { + let id = uuid(); + + // Ensure we don't collide, just in that 0.0000000001% case :) + while (id in this.__downloads && this.__orders.some(o => o.id == id)) + id = uuid(); + + let resolve: (en: DownloadEntity) => void; + const promise: Promise = new Promise((res)=>{resolve = res;}) + + const order: DownloadOrder = { + id, + url, + en: promise, + __en: resolve!, // Usure about it + __download: download, + }; + + if (outfile) + order.outfile = outfile; + + this.__orders.push(order); + this.__update(); + + return id; + } + + getDownload(id: string): DownloadStatus + { + const en = this.__downloads[id]; + if (!en) + throw "Download does not exist"; + const out: DownloadStatus = { + url: en.dl.getUrl(), + finished: en.fin, + total: en.dl.getTotal(), + received: en.dl.getReceived(), + speed: en.fin ? 0 : en.dl.getSpeed(), + }; + const filename = en.dl.getFilename(); + if (filename) + out.filename = filename; + return out; + } + + getDownloads(): Record + { + const out: Record = {}; + for (const id of Object.keys(this.__downloads)) + out[id] = this.getDownload(id); + return out; + } + + getQueue(): Record + { + const out: Record = {}; + for (const or of this.__orders) + { + out[or.id] = { + url: or.url, + finished: false, + total: 0, + received: 0, + speed: 0, + }; + if (or.outfile) + out[or.id]!.filename = or.outfile; + } + return out; + } + + inQueue(id: string): boolean + { + return this.__orders.some(item=>item.id==id); + } + + existsDownload(id: string): boolean + { + return id in this.__downloads; + } + + async getData(id: string): Promise + { + let en: DownloadEntity | undefined = this.__downloads[id]; + if (!en) for (const or of this.__orders) + { + if (or.id != id) + continue; + en = await or.en; + break; + } + if (!en) + throw "Download does not exist"; + return await en.dl.getData(); + } + + __update(): void + { + let active = 0; + for (const dl of Object.values(this.__downloads)) + if (!dl.fin) + active += 1; + + for (let n = 0; n < this.__max_downloads - active; n++) + { + const or = this.__orders.shift() + if (!or) + break; + + const dl = or.__download(); + + const en: DownloadEntity = { + dl, + fin: false, + } + + dl.onFinish(()=>{ + en.fin = true; + setTimeout(()=>{ delete this.__downloads[or.id]; }, 3600 * 1000); + this.__update(); + }); + + or.__en(en); + this.__downloads[or.id] = en; + } + } + + __max_downloads: number; + __downloads: Record = {}; + __orders: DownloadOrder[] = []; +} diff --git a/src/download.ts b/src/download.ts new file mode 100644 index 0000000..d5e333d --- /dev/null +++ b/src/download.ts @@ -0,0 +1,134 @@ +import child_process from "node:child_process"; +import { EventEmitter } from "node:events"; +import fs from "node:fs"; +import { Readable } from "node:stream"; + + +interface DLStatus +{ + status: "success" | "failure" | "progress"; + message?: string; + total?: number; + received?: number; + speed?: number; +} + + +export interface IDownload +{ + getFilename: ()=>string|undefined; + getError: ()=>string|undefined; + getTotal: ()=>number; + getReceived: ()=>number; + getSpeed: ()=>number; + getUrl: ()=>string; + getData: ()=>Promise; + + onFinish: (callback: ()=>any)=>void; +} + + +export class Download extends EventEmitter implements IDownload +{ + constructor(url: string, outfile?: string) + { + super(); + + this.url = url; + if (outfile) + this.filename = outfile + + let dlp = this; + function main(resolve: (a?: undefined)=>void, fail: (reason: string)=>void) + { + let proc; + if (!outfile) + proc = child_process.spawn("python", ["-m", "util.dlp", url, "-"]); + else + proc = child_process.spawn("python", ["-m", "util.dlp", url, outfile]); + + let stdout: Buffer[] = []; + let stderr = ""; + + let stdout_fin = false; + let stderr_fin = false; + + proc.stderr.on("data", (chunk=>{ + stderr += chunk; + if (stderr.includes("\n")) + { + let lines = stderr.split("\n"); + stderr = lines.pop()!; + + for (const line of lines) + { + let msg = JSON.parse(line) as DLStatus; + switch (msg.status) + { + case "success": + stderr_fin = true; + if (stdout_fin) + resolve() + break; + case "failure": + dlp.error = msg.message!; + fail(msg.message!); + break; + case "progress": + dlp.total = msg.total!; + dlp.received = msg.received!; + dlp.speed = msg.speed!; + break; + } + } + } + })); + + proc.stdout.on("data", (chunk=>{stdout.push(chunk)})); + proc.stdout.on("end", ()=>{ + if (!outfile) + dlp.__buffer = Buffer.concat(stdout); + stdout_fin = true; + if (stderr_fin) + resolve() + }) + } + + this.__trigger = new Promise(main); + this.__trigger.then(()=>{ + dlp.emit("end"); + }); + } + + __trigger: Promise; + __buffer?: Buffer; + filename?: string; + error?: string = undefined; + total: number = 0; + received: number = 0; + speed: number = 0; + url: string; + + getFilename() { return this.filename; } + getError() { return this.error; } + getTotal() { return this.total; } + getReceived() { return this.received; } + getSpeed() { return this.speed; } + getUrl() { return this.url; } + + onFinish(callback: ()=>any) + { + this.on("end", callback); + } + + async getData(): Promise + { + await this.__trigger; + if (this.__buffer) + return Readable.from(this.__buffer); + else if (this.filename) + return fs.createReadStream(this.filename); + else + throw "No buffer or file was created"; // Should not happen! + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..6c926ac --- /dev/null +++ b/src/index.ts @@ -0,0 +1,110 @@ +import { DownloadManager } from "./dlmanager.js"; +import express from "express"; +import { detectBufferMime } from "mime-detect"; +import { downloadMovie } from "./movies.js"; +import fs from "node:fs"; +import path from "node:path"; +import readline from "node:readline"; +import { Readable } from "node:stream"; +import toml from "toml"; + + +const config = toml.parse(fs.readFileSync("config.toml").toString()); + +if (!fs.existsSync(config.download.path)) + fs.mkdirSync(config.download.path, {recursive: true}); + +const dlmgr = new DownloadManager(config.download.parallel); +const app = express(); +// const mov_url = "https://kinogo.biz/122738-zveropolis-2.html"; +// dlmgr.enqueue(await downloadMovie(mov_url), mov_url); + + +interface API_PostDownload +{ + url: string, + filename: string, +} + +app.get("/download/:filename", (req,res)=>{ + if (req.params.filename.includes("/")) + return res.status(400).send({error:"filename can not contain directories"}); + + const filename = path.join(config.download.path, req.params.filename); + + const parts = req.url.split("?"); + if (parts.length == 1) + return res.status(400).send("Missing download query"); + parts.shift(); + const url = parts.join("?"); + + const id = dlmgr.download(url, filename); + + return res.status(303).header("Location", "/#"+id).send(id); +}); + +app.use("/api/", express.json()); + +app.post("/api/download", (req,res)=>{ + const params: API_PostDownload = req.body; + if (params.filename.includes("/")) + return res.status(400).send({error:"filename can not contain directories"}); + + const filename = path.join(config.download.path, params.filename); + + const id = dlmgr.download(params.url, filename); + + res.send({id}); +}); + +app.get("/api/download/:id", (req, res)=>{ + if (!dlmgr.existsDownload(req.params.id)) + return res.status(404).send({error:"Download does not exist"}); + res.send(dlmgr.getDownload(req.params.id)); +}); + +app.get("/api/data/:id", async (req, res)=>{ + if (dlmgr.inQueue(req.params.id)) + return res.status(400).send("Download has not yet started"); + if (!dlmgr.existsDownload(req.params.id)) + return res.status(404).send("Download does not exist"); + const dl = dlmgr.getDownload(req.params.id) + if (!dl.finished) + return res.status(400).send("Download has not finished"); + + const data = await dlmgr.getData(req.params.id); + const head = data.read(2048); + const mime = await detectBufferMime(head); + + res.contentType(mime); + res.write(head); + data.pipe(res); +}); + +app.listen(config.server.port); +console.log("Server running on :"+config.server.port); + + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, +}); + +const cli: Recordany> = { + help: () => console.log(Object.keys(cli).join("\n")), + shutdown: () => { + rl.close(); + setInterval(()=>{ + if (!Object.values(dlmgr.getDownloads()).some(d=>!d.finished)) + process.exit(0); + }, + 100); + }, +}; + +rl.on("line", (line)=>{ + if (line in cli) + cli[line]!(); + else + console.log("Unknown command"); +}); diff --git a/src/movies.ts b/src/movies.ts new file mode 100644 index 0000000..3895205 --- /dev/null +++ b/src/movies.ts @@ -0,0 +1,38 @@ +import type { IDownload } from "./download.ts"; +import type { Request, Response } from "express"; +import fs from "node:fs"; +import { URL } from "node:url"; +import path from "node:path"; + +export type Driver = (url: string) => ()=>IDownload; + +const __promises: Promise[] = []; +const __drivers: Record = {}; + +for (const ent of fs.readdirSync(path.join(import.meta.dirname, "movies"))) +{ + if (!ent.endsWith(".js")) + continue; + __promises.push(import("./movies/"+ent)); +} + +export async function downloadMovie(url: string): Promise<()=>IDownload> +{ + await Promise.all(__promises); + + const u = URL.parse(url); + if (!u) + throw new Error("Invalid URL : "+url); + const driver = u.hostname; + + console.log(__drivers); + if (driver in __drivers) + return __drivers[driver]!(url); + else + throw driver+" has no registered driver"; +} + +export function registerMovieDriver(name: string, driver: Driver): void +{ + __drivers[name] = driver; +} diff --git a/src/movies/kinogo.biz.ts b/src/movies/kinogo.biz.ts new file mode 100644 index 0000000..448a29d --- /dev/null +++ b/src/movies/kinogo.biz.ts @@ -0,0 +1,65 @@ +import type { IDownload } from "../download.ts"; +import { DownloadManager } from "../dlmanager.js"; +import { Download } from "../download.js"; +import { registerMovieDriver } from "../movies.js"; +import { Readable } from "node:stream"; +import { URL } from "node:url"; + + +class KinogoDownload implements IDownload +{ + constructor(url: string | URL) + { + url = URL.parse(url)! + console.log(url); + // if (!url.pathname.startsWith("/play/")) + } + + getFilename(): string | undefined + { + return undefined; + } + + getError(): string | undefined + { + return undefined; + } + + getTotal(): number + { + return 0; + } + + getReceived(): number + { + return 0; + } + + getSpeed(): number + { + return 0; + } + + getUrl(): string + { + return ""; + } + + async getData(): Promise + { + return Readable.from(Buffer.alloc(0)); + } + + onFinish(callback: ()=>any) + { + } +} + + +function driver(url: string): ()=>IDownload +{ + return () => new KinogoDownload(url); +} + + +registerMovieDriver("kinogo.biz", driver); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..482c7b9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,42 @@ +{ + // Visit https://aka.ms/tsconfig to read more about this file + "compilerOptions": { + // File Layout + "rootDir": "./src", + "outDir": "./dist", + + // Environment Settings + // See also https://aka.ms/tsconfig/module + "module": "nodenext", + "target": "esnext", + "lib": ["esnext"], + "types": ["node"], + // and npm install -D @types/node + + // Other Outputs + "sourceMap": true, + "declaration": true, + "declarationMap": true, + + // Stricter Typechecking Options + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, + + // Style Options + // "noImplicitReturns": true, + // "noImplicitOverride": true, + // "noUnusedLocals": true, + // "noUnusedParameters": true, + // "noFallthroughCasesInSwitch": true, + // "noPropertyAccessFromIndexSignature": true, + + // Recommended Options + "strict": true, + "jsx": "react-jsx", + "verbatimModuleSyntax": true, + "isolatedModules": true, + "noUncheckedSideEffectImports": true, + "moduleDetection": "force", + "skipLibCheck": true, + } +} diff --git a/util/__pycache__/dlp.cpython-313.pyc b/util/__pycache__/dlp.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8743499b730d14ac8503d6a1c4805d48b48f3748 GIT binary patch literal 2394 zcmah~&2JM&6rc6(X4j6t65An8fNV@$VITwu;UguW3PFGtTD(-Euqs--6UWr{TC?jU z1XZM>Qe&xA(o%%0UZNhV_CMgnDC&Tu!u`Zp{>caV%^=2b)*k|B(}b`h5?S;ES$9z?jU zNa15haV5QunU)-38dzpWrx8*^2q|0)$(+o~ZM$90se}{(c7^BG8(NbE9?TJOV_&jp zpSl&447V6KD27IwkhCl9$*8m6l8Pw1WzS(3@hQIK=GMN0xCMkK7T$sNw^mV7P?U5Z-{ zj9!GQY=Vef$=xk22POA7s3l4Cb+^(3Jl%58@lK+^`d~}PK}yKs6+)-Rp>ms*X!2#} zv?Z0zjvjPE*zTrhJA*#B7q+{mL+O0+^#7t%x(1=!2iqa@ox8b~m$Ro4YDeHLnjCBK zaFEj}_W3bqwzu`S61>G4*A1)9Ff~kw z#ZQxri7oD$q311LE9MGDg0VPFHC2OBm#mkDCiNU1GWDEl481}0YdB>ZL(}-GmK`dZ zne333E$l8_rxsPSXb}1-f}$gXzNI61%KTs0D3(khW1 zkGP%dpoLawRxDvc&18!N&q}BBQ))J&Nhv*-Q}ddn7tD;FH>3j5r!pGW5-!_~CFHPS zsA;@Hsjko@UI6yMgkUwd@*S*ayJSqJFp&s0izJV=Q7NuTabwn>((@+Hn}b=LPn(k& z6a)s$pyisrYKh<{O~7=5Yxv);7zV%IZbUND;LFxu+E*w8$1`W^zq!7U)=uq-1K2b+DM6zEiNaQUqZ(IIx`wSbxI^p9X7Z*bOkx#E zZ&)5Xs4GTh7F(XHSv~bm1N)pP8%r-FgYv&ZNkZVJN=&dQX@L2H74=)@l9lG^ynW+lV$D+U9 z)mPtic#UU+o?j8`ZeJ6T+c$syLt)wDTi9OOzPPuvbMAOO(77;Enkh4-8*`_Y{XI2* z;-NoL_3xY;uLrsoZj^46hnLLx8xI1z;9LmQgx-qKTQ;gf%<(Z)4|dmr1C`(afV+W@ z1FJkc>|aA{w||Xqqu$%VyT9rEX-9bRVl5J{MB=qbq7q3w*fDzVm1^W@wd2^_nR-VA zrf_8LY~35IdAB_DZmD|v=1zd;#o=2wDcjl7Y%L&F0#b>48VD_(Dr?oiws~%ul89G= z@uh1&1ozH!b{y5TI4&Q!jX`mJx zei$3B#zyY(mDpG%a&*nj2R*+b9;gebW8Z2RAbrg5zgFkO23Qt47SG?hSswjrOSSia zla2%bO8G~^Q_;UDmJ<&G1CPY`AIm~;9dS@J&QtH~eH`jqB)1R3EpOZJh~)*y954K} l%7Vt92K}YqIl1}d82Wafht6Yd<6GJLY{z(%y&vTP{|yW-1=Iil literal 0 HcmV?d00001 diff --git a/util/dlp.py b/util/dlp.py new file mode 100644 index 0000000..c2b50e5 --- /dev/null +++ b/util/dlp.py @@ -0,0 +1,75 @@ +import cloudscraper +import json +import sys +import time + + +# Usage: dlp.py +# If output file is "-", then file is saved to stdout + + +def status(data): + sys.stderr.write(json.dumps(data)+"\n") + + +try: + if len(sys.argv) != 3: + status({ + "status": "failure", + "message": "Invalid command options provided", + }) + exit(1) + + url = sys.argv[1] + filepath = sys.argv[2] + + scraper = cloudscraper.create_scraper() + response = scraper.get(url, stream=True) + + if response.status_code != 200: + status({ + "status": "failure", + "message": "Server returned: %d %s" % ( + response.status_code, + response.reason, + ) + }) + exit(2) + + total_size = int(response.headers.get("content-length", 0)) + block_size = 4096 + received_size = 0 + start = time.process_time() + + if filepath == "-": + file = sys.stdout.buffer + else: + file = open(filepath, "wb") + + for data in response.iter_content(block_size): + file.write(data) + received_size += len(data) + status({ + "status": "progress", + "total": total_size, + "received": received_size, + "speed": len(data) / (time.process_time() - start), + }) + + file.flush() + file.close() + + if total_size != 0 and total_size != received_size: + status({ + "status": "failure", + "message": "Could not download whole file", + }) + exit(2) + else: + status({"status": "success"}) + +except Exception as ex: + status({ + "status": "failure", + "message": str(ex), + })