Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
15 changed files with 286 additions and 260 deletions
|
@ -2,4 +2,4 @@ HOST=0.0.0.0
|
|||
ORIGIN=https://dl.emersa.it
|
||||
YTDLP_PATH=./yt-dlp
|
||||
PUBLIC_VERSION=0.6.3
|
||||
HTTPS_PROXY=
|
||||
HTTPS_PROXY=
|
|
@ -1,4 +1,4 @@
|
|||
name: Just some continuos integration
|
||||
name: Bump deps (only minor versions)
|
||||
|
||||
on: [push]
|
||||
|
||||
|
@ -15,16 +15,7 @@ jobs:
|
|||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Format things if needed
|
||||
- name: Prepare, Check, Lint and Format
|
||||
run: |
|
||||
npm install
|
||||
npm i
|
||||
npm run prepare
|
||||
npm run lint
|
||||
npm run format
|
||||
git config --global user.name "forgejo-bot"
|
||||
git config --global user.email "bot@pweapon.org"
|
||||
git add --all || exit 0
|
||||
git commit -m "chore: lint and format" || exit 0
|
||||
git push origin HEAD:${GITHUB_REF#refs/heads/}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||
|
|
|
@ -29,15 +29,13 @@ jobs:
|
|||
- name: Create Release
|
||||
run: |
|
||||
npm ci
|
||||
touch .env.production
|
||||
echo "HOST=0.0.0.0" >> .env.production
|
||||
echo "PORT=3000" >> .env.production
|
||||
echo "ORIGIN=https://dl.emersa.it" >> .env.production
|
||||
echo "PUBLIC_VERSION=$(cat package.json | jq .version)" >> .env.production
|
||||
echo "NODE_ENV=production" >> .env.production
|
||||
touch .env
|
||||
echo "HOST=0.0.0.0" >> .env
|
||||
echo "ORIGIN=https://dl.emersa.it" >> .env
|
||||
echo "PUBLIC_VERSION=$(cat package.json | jq .version)" >> .env
|
||||
npm run build
|
||||
cp package* build/
|
||||
cp .env.production build/
|
||||
cp .env build/
|
||||
mkdir releases
|
||||
cd build/
|
||||
tar czvf ../releases/build.tar.gz .
|
||||
|
|
234
package-lock.json
generated
234
package-lock.json
generated
|
@ -1,42 +1,42 @@
|
|||
{
|
||||
"name": "dl.emersa.it",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dl.emersa.it",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@tailwindcss/forms": "^0.5.10",
|
||||
"@tailwindcss/postcss": "^4.1.4",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@types/node": "^22.15.2",
|
||||
"@types/node": "^22.14.1",
|
||||
"winston": "^3.17.0",
|
||||
"youtube-dl-exec": "^3.0.20"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.8",
|
||||
"@eslint/js": "^9.25.1",
|
||||
"@eslint/js": "^9.25.0",
|
||||
"@sveltejs/adapter-node": "^5.2.12",
|
||||
"@sveltejs/kit": "^2.20.7",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||
"@tailwindcss/vite": "^4.1.4",
|
||||
"eslint": "^9.25.1",
|
||||
"eslint": "^9.25.0",
|
||||
"eslint-config-prettier": "^10.1.2",
|
||||
"eslint-plugin-svelte": "^3.5.1",
|
||||
"globals": "^16.0.0",
|
||||
"mdsvex": "^0.12.5",
|
||||
"mdsvex": "^0.12.3",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-svelte": "^3.3.3",
|
||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||
"svelte": "^5.28.2",
|
||||
"svelte": "^5.28.1",
|
||||
"svelte-check": "^4.1.6",
|
||||
"sveltekit-sse": "^0.13.19",
|
||||
"sveltekit-sse": "^0.13.18",
|
||||
"tailwindcss": "^4.1.4",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.31.0",
|
||||
"vite": "^6.3.3"
|
||||
"typescript-eslint": "^8.30.1",
|
||||
"vite": "^6.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@alloc/quick-lru": {
|
||||
|
@ -639,9 +639,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@eslint/js": {
|
||||
"version": "9.25.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.25.1.tgz",
|
||||
"integrity": "sha512-dEIwmjntEx8u3Uvv+kr3PDeeArL8Hw07H9kyYxCjnM9pBjfEhk6uLXSchxxzgiwtRhhzVzqmUSDFBOi1TuZ7qg==",
|
||||
"version": "9.25.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.25.0.tgz",
|
||||
"integrity": "sha512-iWhsUS8Wgxz9AXNfvfOPFSW4VfMXdVhp1hjkZVhXCrpgh/aLcc45rX6MPu+tIVUWDw0HfNwth7O28M1xDxNf9w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
@ -1628,20 +1628,10 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/mdast": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",
|
||||
"integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/unist": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.15.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.2.tgz",
|
||||
"integrity": "sha512-uKXqKN9beGoMdBfcaTY1ecwz6ctxuJAcUlwE55938g0ZJ8lRxwAZqRz2AJ4pzpt5dHdTPMB863UZ0ESiFUcP7A==",
|
||||
"version": "22.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.1.tgz",
|
||||
"integrity": "sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
|
@ -1665,17 +1655,17 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.31.0.tgz",
|
||||
"integrity": "sha512-evaQJZ/J/S4wisevDvC1KFZkPzRetH8kYZbkgcTRyql3mcKsf+ZFDV1BVWUGTCAW5pQHoqn5gK5b8kn7ou9aFQ==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.30.1.tgz",
|
||||
"integrity": "sha512-v+VWphxMjn+1t48/jO4t950D6KR8JaJuNXzi33Ve6P8sEmPr5k6CEXjdGwT6+LodVnEa91EQCtwjWNUCPweo+Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.10.0",
|
||||
"@typescript-eslint/scope-manager": "8.31.0",
|
||||
"@typescript-eslint/type-utils": "8.31.0",
|
||||
"@typescript-eslint/utils": "8.31.0",
|
||||
"@typescript-eslint/visitor-keys": "8.31.0",
|
||||
"@typescript-eslint/scope-manager": "8.30.1",
|
||||
"@typescript-eslint/type-utils": "8.30.1",
|
||||
"@typescript-eslint/utils": "8.30.1",
|
||||
"@typescript-eslint/visitor-keys": "8.30.1",
|
||||
"graphemer": "^1.4.0",
|
||||
"ignore": "^5.3.1",
|
||||
"natural-compare": "^1.4.0",
|
||||
|
@ -1695,16 +1685,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.31.0.tgz",
|
||||
"integrity": "sha512-67kYYShjBR0jNI5vsf/c3WG4u+zDnCTHTPqVMQguffaWWFs7artgwKmfwdifl+r6XyM5LYLas/dInj2T0SgJyw==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.30.1.tgz",
|
||||
"integrity": "sha512-H+vqmWwT5xoNrXqWs/fesmssOW70gxFlgcMlYcBaWNPIEWDgLa4W9nkSPmhuOgLnXq9QYgkZ31fhDyLhleCsAg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.31.0",
|
||||
"@typescript-eslint/types": "8.31.0",
|
||||
"@typescript-eslint/typescript-estree": "8.31.0",
|
||||
"@typescript-eslint/visitor-keys": "8.31.0",
|
||||
"@typescript-eslint/scope-manager": "8.30.1",
|
||||
"@typescript-eslint/types": "8.30.1",
|
||||
"@typescript-eslint/typescript-estree": "8.30.1",
|
||||
"@typescript-eslint/visitor-keys": "8.30.1",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -1720,14 +1710,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.31.0.tgz",
|
||||
"integrity": "sha512-knO8UyF78Nt8O/B64i7TlGXod69ko7z6vJD9uhSlm0qkAbGeRUSudcm0+K/4CrRjrpiHfBCjMWlc08Vav1xwcw==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.30.1.tgz",
|
||||
"integrity": "sha512-+C0B6ChFXZkuaNDl73FJxRYT0G7ufVPOSQkqkpM/U198wUwUFOtgo1k/QzFh1KjpBitaK7R1tgjVz6o9HmsRPg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.31.0",
|
||||
"@typescript-eslint/visitor-keys": "8.31.0"
|
||||
"@typescript-eslint/types": "8.30.1",
|
||||
"@typescript-eslint/visitor-keys": "8.30.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
@ -1738,14 +1728,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.31.0.tgz",
|
||||
"integrity": "sha512-DJ1N1GdjI7IS7uRlzJuEDCgDQix3ZVYVtgeWEyhyn4iaoitpMBX6Ndd488mXSx0xah/cONAkEaYyylDyAeHMHg==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.30.1.tgz",
|
||||
"integrity": "sha512-64uBF76bfQiJyHgZISC7vcNz3adqQKIccVoKubyQcOnNcdJBvYOILV1v22Qhsw3tw3VQu5ll8ND6hycgAR5fEA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/typescript-estree": "8.31.0",
|
||||
"@typescript-eslint/utils": "8.31.0",
|
||||
"@typescript-eslint/typescript-estree": "8.30.1",
|
||||
"@typescript-eslint/utils": "8.30.1",
|
||||
"debug": "^4.3.4",
|
||||
"ts-api-utils": "^2.0.1"
|
||||
},
|
||||
|
@ -1762,9 +1752,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.31.0.tgz",
|
||||
"integrity": "sha512-Ch8oSjVyYyJxPQk8pMiP2FFGYatqXQfQIaMp+TpuuLlDachRWpUAeEu1u9B/v/8LToehUIWyiKcA/w5hUFRKuQ==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.30.1.tgz",
|
||||
"integrity": "sha512-81KawPfkuulyWo5QdyG/LOKbspyyiW+p4vpn4bYO7DM/hZImlVnFwrpCTnmNMOt8CvLRr5ojI9nU1Ekpw4RcEw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
@ -1776,14 +1766,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.31.0.tgz",
|
||||
"integrity": "sha512-xLmgn4Yl46xi6aDSZ9KkyfhhtnYI15/CvHbpOy/eR5NWhK/BK8wc709KKwhAR0m4ZKRP7h07bm4BWUYOCuRpQQ==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.30.1.tgz",
|
||||
"integrity": "sha512-kQQnxymiUy9tTb1F2uep9W6aBiYODgq5EMSk6Nxh4Z+BDUoYUSa029ISs5zTzKBFnexQEh71KqwjKnRz58lusQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.31.0",
|
||||
"@typescript-eslint/visitor-keys": "8.31.0",
|
||||
"@typescript-eslint/types": "8.30.1",
|
||||
"@typescript-eslint/visitor-keys": "8.30.1",
|
||||
"debug": "^4.3.4",
|
||||
"fast-glob": "^3.3.2",
|
||||
"is-glob": "^4.0.3",
|
||||
|
@ -1829,16 +1819,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.31.0.tgz",
|
||||
"integrity": "sha512-qi6uPLt9cjTFxAb1zGNgTob4x9ur7xC6mHQJ8GwEzGMGE9tYniublmJaowOJ9V2jUzxrltTPfdG2nKlWsq0+Ww==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.30.1.tgz",
|
||||
"integrity": "sha512-T/8q4R9En2tcEsWPQgB5BQ0XJVOtfARcUvOa8yJP3fh9M/mXraLxZrkCfGb6ChrO/V3W+Xbd04RacUEqk1CFEQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "8.31.0",
|
||||
"@typescript-eslint/types": "8.31.0",
|
||||
"@typescript-eslint/typescript-estree": "8.31.0"
|
||||
"@typescript-eslint/scope-manager": "8.30.1",
|
||||
"@typescript-eslint/types": "8.30.1",
|
||||
"@typescript-eslint/typescript-estree": "8.30.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
@ -1853,13 +1843,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.31.0.tgz",
|
||||
"integrity": "sha512-QcGHmlRHWOl93o64ZUMNewCdwKGU6WItOU52H0djgNmn1EOrhVudrDzXz4OycCRSCPwFCDrE2iIt5vmuUdHxuQ==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.30.1.tgz",
|
||||
"integrity": "sha512-aEhgas7aJ6vZnNFC7K4/vMGDGyOiqWcYZPpIWrTKuTAlsvDNKy2GFDqh9smL+iq069ZvR0YzEeq0B8NJlLzjFA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.31.0",
|
||||
"@typescript-eslint/types": "8.30.1",
|
||||
"eslint-visitor-keys": "^4.2.0"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -2388,9 +2378,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/eslint": {
|
||||
"version": "9.25.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.25.1.tgz",
|
||||
"integrity": "sha512-E6Mtz9oGQWDCpV12319d59n4tx9zOTXSTmc8BLVxBx+G/0RdM5MvEEJLU9c0+aleoePYYgVTOsRblx433qmhWQ==",
|
||||
"version": "9.25.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.25.0.tgz",
|
||||
"integrity": "sha512-MsBdObhM4cEwkzCiraDv7A6txFXEqtNXOb877TsSp2FCkBNl8JfVQrmiuDqC1IkejT6JLPzYBXx/xAiYhyzgGA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
@ -2400,7 +2390,7 @@
|
|||
"@eslint/config-helpers": "^0.2.1",
|
||||
"@eslint/core": "^0.13.0",
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@eslint/js": "9.25.1",
|
||||
"@eslint/js": "9.25.0",
|
||||
"@eslint/plugin-kit": "^0.2.8",
|
||||
"@humanfs/node": "^0.16.6",
|
||||
"@humanwhocodes/module-importer": "^1.0.1",
|
||||
|
@ -2718,11 +2708,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/fdir": {
|
||||
"version": "6.4.4",
|
||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.4.tgz",
|
||||
"integrity": "sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==",
|
||||
"version": "6.4.3",
|
||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.3.tgz",
|
||||
"integrity": "sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"picomatch": "^3 || ^4"
|
||||
},
|
||||
|
@ -3462,17 +3451,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/mdsvex": {
|
||||
"version": "0.12.5",
|
||||
"resolved": "https://registry.npmjs.org/mdsvex/-/mdsvex-0.12.5.tgz",
|
||||
"integrity": "sha512-JQy8CBbGF1IvpxZTmGJigRiD1s2BKfLKS9xCLPKngjHToY8WMYLZ8WFGRpuR6x4C4bxipSuLm2LctwL2fVXaEQ==",
|
||||
"version": "0.12.3",
|
||||
"resolved": "https://registry.npmjs.org/mdsvex/-/mdsvex-0.12.3.tgz",
|
||||
"integrity": "sha512-C/uIJamjNo5PHHnR3JHqsBPoLcfUBpzRmAEB6FLMXI/s7XHOceswjDMKqSPEW2WHmYpKm0taZ3U20GSyhMridA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/mdast": "^4.0.4",
|
||||
"@types/unist": "^2.0.3",
|
||||
"prism-svelte": "^0.4.7",
|
||||
"prismjs": "^1.17.1",
|
||||
"unist-util-visit": "^2.0.1",
|
||||
"vfile-message": "^2.0.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
@ -4432,9 +4418,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/svelte": {
|
||||
"version": "5.28.2",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.28.2.tgz",
|
||||
"integrity": "sha512-FbWBxgWOpQfhKvoGJv/TFwzqb4EhJbwCD17dB0tEpQiw1XyUEKZJtgm4nA4xq3LLsMo7hu5UY/BOFmroAxKTMg==",
|
||||
"version": "5.28.1",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.28.1.tgz",
|
||||
"integrity": "sha512-iOa9WmfNG95lSOSJdMhdjJ4Afok7IRAQYXpbnxhd5EINnXseG0GVa9j6WPght4eX78XfFez45Fi+uRglGKPV/Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
@ -4534,9 +4520,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/sveltekit-sse": {
|
||||
"version": "0.13.19",
|
||||
"resolved": "https://registry.npmjs.org/sveltekit-sse/-/sveltekit-sse-0.13.19.tgz",
|
||||
"integrity": "sha512-0uOiMqRdpjoM2dM/2fyLPUfGdhhOeW9KX4LR03b4K/cYFoZt4RYyOQJrX5RPijPf9sGX2mXkc0GEA2d0l3zifg==",
|
||||
"version": "0.13.18",
|
||||
"resolved": "https://registry.npmjs.org/sveltekit-sse/-/sveltekit-sse-0.13.18.tgz",
|
||||
"integrity": "sha512-DEK2pcnHZsQTezM6Eq4qBUewkp3v1SBpBXX4eNiFZs4cwfGw++lEVAoPoR4I1CmLjfz+RznblvvX/Q0qomj1VA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
|
@ -4592,13 +4578,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/tinyglobby": {
|
||||
"version": "0.2.13",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.13.tgz",
|
||||
"integrity": "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==",
|
||||
"version": "0.2.12",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.12.tgz",
|
||||
"integrity": "sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fdir": "^6.4.4",
|
||||
"fdir": "^6.4.3",
|
||||
"picomatch": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -4692,15 +4678,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/typescript-eslint": {
|
||||
"version": "8.31.0",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.31.0.tgz",
|
||||
"integrity": "sha512-u+93F0sB0An8WEAPtwxVhFby573E8ckdjwUUQUj9QA4v8JAvgtoDdIyYR3XFwFHq2W1KJ1AurwJCO+w+Y1ixyQ==",
|
||||
"version": "8.30.1",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.30.1.tgz",
|
||||
"integrity": "sha512-D7lC0kcehVH7Mb26MRQi64LMyRJsj3dToJxM1+JVTl53DQSV5/7oUGWQLcKl1C1KnoVHxMMU2FNQMffr7F3Row==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "8.31.0",
|
||||
"@typescript-eslint/parser": "8.31.0",
|
||||
"@typescript-eslint/utils": "8.31.0"
|
||||
"@typescript-eslint/eslint-plugin": "8.30.1",
|
||||
"@typescript-eslint/parser": "8.30.1",
|
||||
"@typescript-eslint/utils": "8.30.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
@ -4720,17 +4706,6 @@
|
|||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/unist-util-is": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.1.0.tgz",
|
||||
"integrity": "sha512-ZOQSsnce92GrxSqlnEEseX0gi7GH9zTJZ0p9dtu87WRb/37mMPO2Ilx1s/t9vBHrFhbgweUwb+t7cIn5dxPhZg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/unist-util-stringify-position": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz",
|
||||
|
@ -4744,37 +4719,6 @@
|
|||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/unist-util-visit": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz",
|
||||
"integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/unist": "^2.0.0",
|
||||
"unist-util-is": "^4.0.0",
|
||||
"unist-util-visit-parents": "^3.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/unist-util-visit-parents": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz",
|
||||
"integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/unist": "^2.0.0",
|
||||
"unist-util-is": "^4.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
@ -4805,18 +4749,18 @@
|
|||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "6.3.3",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.3.tgz",
|
||||
"integrity": "sha512-5nXH+QsELbFKhsEfWLkHrvgRpTdGJzqOZ+utSdmPTvwHmvU6ITTm3xx+mRusihkcI8GeC7lCDyn3kDtiki9scw==",
|
||||
"version": "6.3.2",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.2.tgz",
|
||||
"integrity": "sha512-ZSvGOXKGceizRQIZSz7TGJ0pS3QLlVY/9hwxVh17W3re67je1RKYzFHivZ/t0tubU78Vkyb9WnHPENSBCzbckg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"fdir": "^6.4.4",
|
||||
"fdir": "^6.4.3",
|
||||
"picomatch": "^4.0.2",
|
||||
"postcss": "^8.5.3",
|
||||
"rollup": "^4.34.9",
|
||||
"tinyglobby": "^0.2.13"
|
||||
"tinyglobby": "^0.2.12"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
|
|
18
package.json
18
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "dl.emersa.it",
|
||||
"private": true,
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
@ -16,32 +16,32 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.8",
|
||||
"@eslint/js": "^9.25.1",
|
||||
"@eslint/js": "^9.25.0",
|
||||
"@sveltejs/adapter-node": "^5.2.12",
|
||||
"@sveltejs/kit": "^2.20.7",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||
"@tailwindcss/vite": "^4.1.4",
|
||||
"eslint": "^9.25.1",
|
||||
"eslint": "^9.25.0",
|
||||
"eslint-config-prettier": "^10.1.2",
|
||||
"eslint-plugin-svelte": "^3.5.1",
|
||||
"globals": "^16.0.0",
|
||||
"mdsvex": "^0.12.5",
|
||||
"mdsvex": "^0.12.3",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-svelte": "^3.3.3",
|
||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||
"svelte": "^5.28.2",
|
||||
"svelte": "^5.28.1",
|
||||
"svelte-check": "^4.1.6",
|
||||
"sveltekit-sse": "^0.13.19",
|
||||
"sveltekit-sse": "^0.13.18",
|
||||
"tailwindcss": "^4.1.4",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.31.0",
|
||||
"vite": "^6.3.3"
|
||||
"typescript-eslint": "^8.30.1",
|
||||
"vite": "^6.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/forms": "^0.5.10",
|
||||
"@tailwindcss/postcss": "^4.1.4",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@types/node": "^22.15.2",
|
||||
"@types/node": "^22.14.1",
|
||||
"winston": "^3.17.0",
|
||||
"youtube-dl-exec": "^3.0.20"
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@ tar -xvf build.tar.gz -C .
|
|||
rm build.tar.gz
|
||||
npm ci
|
||||
npm run download-yt-dlp
|
||||
echo "YTDLP_PATH=$(readlink -f yt-dlp)" >> .env.production
|
||||
echo "HTTPS_PROXY=${PROXY}" >> .env.production
|
||||
echo "YTDLP_PATH=$(readlink -f yt-dlp)" >>.env
|
||||
echo "HTTPS_PROXY=${PROXY}" >>.env
|
||||
|
|
|
@ -14,5 +14,4 @@ __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||
version="${1:?Error: No argument provided. Usage: $0 <version>}"
|
||||
|
||||
npm version "v${version}"
|
||||
git push --tags
|
||||
git push
|
||||
git push --tags
|
21
src/lib/client/downloader.ts
Normal file
21
src/lib/client/downloader.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
const createAnchorElement = (url: string, filename: string): HTMLAnchorElement => {
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = url;
|
||||
anchor.download = filename;
|
||||
return anchor;
|
||||
};
|
||||
export const download = async (url: string, filename: string) => {
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const objectURL = window.URL.createObjectURL(blob);
|
||||
const anchor = createAnchorElement(url, filename);
|
||||
document.body.appendChild(anchor);
|
||||
anchor.click();
|
||||
anchor.remove();
|
||||
window.URL.revokeObjectURL(objectURL);
|
||||
};
|
73
src/lib/components/DownloadManager.svelte
Normal file
73
src/lib/components/DownloadManager.svelte
Normal file
|
@ -0,0 +1,73 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
let { url, dismiss } = $props();
|
||||
|
||||
let visible = $state(false);
|
||||
let progress = $state(0);
|
||||
let filename = $state('');
|
||||
onMount(async () => {
|
||||
if (!url) return;
|
||||
|
||||
try {
|
||||
visible = true;
|
||||
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error('Download failed');
|
||||
|
||||
const contentDisposition: string = response?.headers?.get('content-disposition');
|
||||
filename = contentDisposition.split('filename=')[1];
|
||||
const contentLength: number = Number(response?.headers?.get('content-length'));
|
||||
const reader = response?.body?.getReader();
|
||||
const chunks: Uint8Array[] = [];
|
||||
let receivedLength = 0;
|
||||
|
||||
while (true) {
|
||||
const { done, value }: ReadableStreamReadResult<Uint8Array> = await reader.read();
|
||||
if (done) break;
|
||||
if (value) {
|
||||
chunks.push(value);
|
||||
receivedLength += value.length;
|
||||
progress = Math.round((receivedLength / contentLength) * 100);
|
||||
}
|
||||
}
|
||||
|
||||
const blob = new Blob(chunks);
|
||||
const downloadUrl = URL.createObjectURL(blob);
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = downloadUrl;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
|
||||
URL.revokeObjectURL(downloadUrl);
|
||||
|
||||
setTimeout(() => {
|
||||
visible = false;
|
||||
}, 1500); // auto-dismiss
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
visible = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/80 font-mono backdrop-blur-sm"
|
||||
>
|
||||
<div
|
||||
class="w-[90%] max-w-sm rounded-2xl border border-green-400 bg-[#000f00] p-6 text-sm text-green-300 shadow-2xl"
|
||||
>
|
||||
<p class="mb-2 text-center text-cyan-300">
|
||||
Downloading <span class="font-semibold text-green-400">{filename}</span>
|
||||
</p>
|
||||
<div class="h-4 w-full overflow-hidden rounded-md border border-green-500 bg-black">
|
||||
<div
|
||||
class="h-full bg-gradient-to-r from-green-400 to-green-600 transition-all duration-300"
|
||||
style="width: {progress}%"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-2 text-center text-pink-400">{progress}%</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
28
src/lib/components/Loader.svelte
Normal file
28
src/lib/components/Loader.svelte
Normal file
|
@ -0,0 +1,28 @@
|
|||
<div class="w-[150px]">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"
|
||||
><linearGradient id="a3"
|
||||
><stop offset="0" stop-color="#FF156D" stop-opacity="0"></stop><stop
|
||||
offset="1"
|
||||
stop-color="#FF156D"
|
||||
></stop></linearGradient
|
||||
><circle
|
||||
fill="none"
|
||||
stroke="url(#a3)"
|
||||
stroke-width="15"
|
||||
stroke-linecap="round"
|
||||
stroke-dasharray="0 44 0 44 0 44 0 44 0 360"
|
||||
cx="100"
|
||||
cy="100"
|
||||
r="70"
|
||||
transform-origin="center"
|
||||
><animateTransform
|
||||
type="rotate"
|
||||
attributeName="transform"
|
||||
calcMode="discrete"
|
||||
dur="2"
|
||||
values="360;324;288;252;216;180;144;108;72;36"
|
||||
repeatCount="indefinite"
|
||||
></animateTransform></circle
|
||||
></svg
|
||||
>
|
||||
</div>
|
|
@ -1,22 +0,0 @@
|
|||
<script lang="ts">
|
||||
let { progress, filename } = $props();
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/80 font-mono backdrop-blur-sm"
|
||||
>
|
||||
<div
|
||||
class="w-[90%] max-w-sm rounded-2xl border border-green-400 bg-[#000f00] p-6 text-sm text-green-300 shadow-2xl"
|
||||
>
|
||||
<p class="mb-2 text-center text-cyan-300">
|
||||
Downloading <span class="font-semibold text-green-400">{filename}</span>
|
||||
</p>
|
||||
<div class="h-4 w-full overflow-hidden rounded-md border border-green-500 bg-black">
|
||||
<div
|
||||
class="h-full bg-gradient-to-r from-green-400 to-green-600 transition-all duration-300"
|
||||
style="width: {progress}%"
|
||||
></div>
|
||||
</div>
|
||||
<p class="mt-2 text-center text-pink-400">{progress}%</p>
|
||||
</div>
|
||||
</div>
|
|
@ -1,8 +1,9 @@
|
|||
import formats from '$lib/common/supportedFormats.json';
|
||||
import winston from 'winston';
|
||||
import { dev } from '$app/environment';
|
||||
|
||||
export const logger = winston.createLogger({
|
||||
level: 'debug',
|
||||
level: dev ? 'debug' : 'error',
|
||||
format: winston.format.json(),
|
||||
transports: [new winston.transports.Console()]
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { create, type Flags } from 'youtube-dl-exec';
|
||||
import { create } from 'youtube-dl-exec';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import { spawn } from 'node:child_process';
|
||||
import supportedFormats from '$lib/common/supportedFormats.json';
|
||||
import { logger, mimeTypeMap } from '$lib/server/helpers';
|
||||
|
||||
const YTDLP_PATH: string = env.YTDLP_PATH as string;
|
||||
|
@ -12,7 +13,7 @@ export const ytdl = create(YTDLP_PATH);
|
|||
* Fetch YouTube metadata (title, uploader/artist)
|
||||
*/
|
||||
export async function getYouTubeMetadata(link: string) {
|
||||
const options: Flags = {
|
||||
const options = {
|
||||
dumpSingleJson: true,
|
||||
noCheckCertificates: true,
|
||||
noWarnings: true,
|
||||
|
@ -65,11 +66,10 @@ export function streamYouTube(link: string, format: string): ReadableStream<Uint
|
|||
process.stdout.on('data', (chunk) => {
|
||||
try {
|
||||
controller.enqueue(chunk);
|
||||
} catch {
|
||||
} catch (ex) {
|
||||
process.kill();
|
||||
}
|
||||
});
|
||||
|
||||
process.stderr.on('data', (chunk) => logger.debug(chunk.toString()));
|
||||
process.stdout.on('end', () => {
|
||||
try {
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
<script lang="ts">
|
||||
import { PUBLIC_VERSION } from '$env/static/public';
|
||||
import supportedFormats from '$lib/common/supportedFormats.json';
|
||||
import DownloadManager from '$lib/components/ProgressBar.svelte';
|
||||
import Loader from '$lib/components/Loader.svelte';
|
||||
import { download } from '$lib/client/downloader';
|
||||
import DownloadManager from '$lib/components/DownloadManager.svelte';
|
||||
import { mount, unmount } from 'svelte';
|
||||
|
||||
let source = $state('youtube');
|
||||
let link = $state('');
|
||||
let downloading = $state(false);
|
||||
let format = $state('mp3');
|
||||
let showModal = $state(false);
|
||||
let href = $state('');
|
||||
let disabled = $state(true);
|
||||
let progress = $state(0);
|
||||
let filename = $state('');
|
||||
let metadata = $state(false);
|
||||
let logs = $state('');
|
||||
let downloadManager: DownloadManager | null = null;
|
||||
|
||||
const formats = Object.keys(supportedFormats).map((f) => {
|
||||
return { value: f, label: f.toUpperCase() };
|
||||
|
@ -25,50 +28,17 @@
|
|||
showModal = !showModal;
|
||||
};
|
||||
|
||||
const download = async (url: string) => {
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
|
||||
const contentDisposition: string | null = response?.headers?.get('content-disposition');
|
||||
filename = contentDisposition?.split('filename=')[1] || 'noname';
|
||||
// const contentLength: number = Number(response?.headers?.get('content-length'));
|
||||
const reader = response?.body?.getReader();
|
||||
const chunks: Uint8Array[] = [];
|
||||
let receivedLength = 0;
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader!.read();
|
||||
if (done) break;
|
||||
if (value) {
|
||||
chunks.push(value);
|
||||
receivedLength += value.length;
|
||||
progress = Math.round((receivedLength / 50000) * 100);
|
||||
}
|
||||
}
|
||||
|
||||
const blob = new Blob(chunks);
|
||||
const downloadUrl = URL.createObjectURL(blob);
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = downloadUrl;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(downloadUrl);
|
||||
const dismiss = () => {
|
||||
unmount(downloadManager);
|
||||
};
|
||||
|
||||
const onClick = async (evt) => {
|
||||
evt.preventDefault();
|
||||
|
||||
downloading = true;
|
||||
await download(href);
|
||||
downloading = false;
|
||||
const props = $state({ url: href });
|
||||
downloadManager = mount(DownloadManager, { target: document.body, props, events: { dismiss } });
|
||||
|
||||
link = '';
|
||||
progress = 0;
|
||||
filename = '';
|
||||
};
|
||||
|
||||
const createAnchor = () => {
|
||||
|
@ -80,9 +50,8 @@
|
|||
try {
|
||||
new URL(link);
|
||||
disabled = false;
|
||||
} catch {
|
||||
} catch (err) {
|
||||
/*
|
||||
|
||||
if (err.code === 'ERR_INVALID_URL') {
|
||||
|
||||
}
|
||||
|
@ -96,6 +65,8 @@
|
|||
searchParams.append('link', link);
|
||||
searchParams.append('format', format);
|
||||
|
||||
if (metadata) searchParams.append('metadata', '1');
|
||||
|
||||
href = `/download?${searchParams.toString()}`;
|
||||
};
|
||||
|
||||
|
@ -114,6 +85,15 @@
|
|||
id="wrapper"
|
||||
class="relative mx-auto max-w-full rounded-2xl bg-black p-4 text-green-400 shadow-xl sm:max-w-sm md:max-w-md lg:max-w-lg"
|
||||
>
|
||||
<!-- Loader Overlay -->
|
||||
<div
|
||||
id="loader"
|
||||
class="absolute inset-0 z-10 hidden items-center justify-center bg-black/80 backdrop-blur-sm"
|
||||
>
|
||||
<Loader />
|
||||
{@html logs}
|
||||
</div>
|
||||
|
||||
<!-- Info Button -->
|
||||
<button
|
||||
onclick={toggleModal}
|
||||
|
@ -144,7 +124,7 @@
|
|||
bind:value={source}
|
||||
class="w-full rounded-md border border-green-400 bg-[#000f00] px-3 py-2 text-green-300 focus:border-pink-400 focus:outline-none"
|
||||
>
|
||||
{#each sources as source (source.label)}
|
||||
{#each sources as source}
|
||||
<option value={source.value}>{source.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
@ -158,7 +138,7 @@
|
|||
bind:value={format}
|
||||
class="w-full rounded-md border border-green-400 bg-[#000f00] px-3 py-2 text-green-300 focus:border-pink-400 focus:outline-none"
|
||||
>
|
||||
{#each formats as format (format.label)}
|
||||
{#each formats as format}
|
||||
<option value={format.value}>{format.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
@ -179,6 +159,20 @@
|
|||
/>
|
||||
</div>
|
||||
|
||||
<!-- Metadata Checkbox -->
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="metadata"
|
||||
name="metadata"
|
||||
bind:checked={metadata}
|
||||
class="h-4 w-4 border border-green-400 bg-[#000f00] text-green-500 focus:ring-pink-400"
|
||||
/>
|
||||
<label for="metadata" class="text-cyan-300"
|
||||
>Set filename (<span class="text-red-500">slow</span>)</label
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- Download Button -->
|
||||
<a
|
||||
id="btn-download"
|
||||
|
@ -193,10 +187,6 @@
|
|||
</form>
|
||||
</div>
|
||||
|
||||
{#if downloading}
|
||||
<DownloadManager {filename} {progress}></DownloadManager>
|
||||
{/if}
|
||||
|
||||
<!-- Modal -->
|
||||
{#if showModal}
|
||||
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/90 text-green-300">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getYouTubeMetadata, streamYouTube } from '$lib/server/ytdlp';
|
||||
import { getYouTubeMetadata, streamYouTube, ytdl } from '$lib/server/ytdlp';
|
||||
import { isURLValid, logger, mimeTypeMap } from '$lib/server/helpers';
|
||||
|
||||
const validateRequest = (url: URL) => {
|
||||
|
@ -8,6 +8,7 @@ const validateRequest = (url: URL) => {
|
|||
const link = url.searchParams.get('link');
|
||||
const format = url.searchParams.get('format'); // mp3, mp4
|
||||
const source = url.searchParams.get('source'); // youtube or spotify
|
||||
const metadata = url.searchParams.has('metadata');
|
||||
|
||||
// Validate input
|
||||
if (!link || !format || !source) {
|
||||
|
@ -31,20 +32,21 @@ const validateRequest = (url: URL) => {
|
|||
return {
|
||||
link,
|
||||
format,
|
||||
source
|
||||
source,
|
||||
metadata
|
||||
};
|
||||
};
|
||||
export const GET: RequestHandler = async ({ url }) => {
|
||||
const { format, link } = validateRequest(url);
|
||||
const { format, source, metadata, link } = validateRequest(url);
|
||||
let filename = '';
|
||||
|
||||
logger.debug(`Requested: ${link}`);
|
||||
let contentLength = 0;
|
||||
|
||||
try {
|
||||
logger.debug(`Fetching video data to set filename`);
|
||||
// Fetch metadata for filename
|
||||
const ytMetadata = await getYouTubeMetadata(link);
|
||||
const { title, uploader } = ytMetadata;
|
||||
const { title, uploader, filesize_approx } = ytMetadata;
|
||||
contentLength = filesize_approx;
|
||||
const safeTitle = `${uploader} - ${title}`;
|
||||
filename = `${safeTitle}.${format}`;
|
||||
} catch (err) {
|
||||
|
@ -58,6 +60,7 @@ export const GET: RequestHandler = async ({ url }) => {
|
|||
return new Response(streamYouTube(link, format), {
|
||||
headers: {
|
||||
'Content-Type': `${mimeTypeMap.get(format)}`,
|
||||
'Content-Length': contentLength,
|
||||
'Content-Disposition': `attachment; filename="${filename}"`
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue