Big updates
This commit is contained in:
parent
ea0e18f9d7
commit
8223487c0b
8 changed files with 70 additions and 77 deletions
|
@ -1,9 +1,9 @@
|
||||||
name: Update Minor Dependencies and Build Container
|
name: Bump deps (only minor versions)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *' # Runs every night at midnight (UTC)
|
- cron: '0 0 * * *' # Runs every night at midnight (UTC)
|
||||||
workflow_dispatch: # Allows manual triggering
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-dependencies:
|
update-dependencies:
|
||||||
|
@ -13,24 +13,17 @@ jobs:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.FORGEJO_TOKEN }} # Make sure to add this token in your repo secrets
|
token: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '20' # Adjust as needed
|
node-version: '20'
|
||||||
|
|
||||||
- name: Configure npm version
|
- name: Update deps, install them (to change package-lock.json) and commit
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Check and Update Minor Dependencies
|
|
||||||
run: npx npm-check-updates --target minor -u
|
|
||||||
|
|
||||||
- name: Install Updated Dependencies
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Commit and Push Changes
|
|
||||||
run: |
|
run: |
|
||||||
|
npx npm-check-updates --target minor -u
|
||||||
|
npm install
|
||||||
git config --global user.name "forgejo-bot"
|
git config --global user.name "forgejo-bot"
|
||||||
git config --global user.email "bot@pweapon.org"
|
git config --global user.email "bot@pweapon.org"
|
||||||
git add package.json || exit 0
|
git add package.json || exit 0
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<script lang='ts'>
|
<script lang="ts">
|
||||||
let props = $props();
|
let props = $props();
|
||||||
</script>
|
</script>
|
|
@ -7,9 +7,10 @@
|
||||||
{@render children()}
|
{@render children()}
|
||||||
|
|
||||||
<footer
|
<footer
|
||||||
class="absolute bottom-0 w-[100dvw] mt-10 bg-black text-green-500 text-center py-4 border-t-4 border-green-500"
|
class="absolute bottom-0 mt-10 w-[100dvw] border-t-4 border-green-500 bg-black py-4 text-center text-green-500"
|
||||||
>
|
>
|
||||||
<a class='underline' href='https://git.pweapon.org/odo/dl.emersa.it'>source code</a> - Made with ❤️ by Emersa <span>©</span>
|
<a class="underline" href="https://git.pweapon.org/odo/dl.emersa.it">source code</a> - Made with
|
||||||
|
❤️ by Emersa <span>©</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<h1 id='title' class="mb-6 text-center text-xl">🐙 Scaricatore 🐙</h1>
|
<h1 id="title" class="mb-6 text-center text-xl">🐙 Scaricatore 🐙</h1>
|
||||||
<form class="space-y-6" onsubmit={handleSubmit}>
|
<form class="space-y-6" onsubmit={handleSubmit}>
|
||||||
<!-- Source Selection -->
|
<!-- Source Selection -->
|
||||||
<fieldset class="space-y-4">
|
<fieldset class="space-y-4">
|
||||||
|
|
|
@ -6,17 +6,16 @@ import { json, error } from '@sveltejs/kit';
|
||||||
import type { RequestHandler } from './$types';
|
import type { RequestHandler } from './$types';
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch YouTube metadata (title, uploader/artist)
|
* Fetch YouTube metadata (title, uploader/artist)
|
||||||
*/
|
*/
|
||||||
async function getYouTubeMetadata(link: string) {
|
async function getYouTubeMetadata(link: string) {
|
||||||
return await ytdl(link, {
|
return await ytdl(link, {
|
||||||
dumpSingleJson: true,
|
dumpSingleJson: true,
|
||||||
noCheckCertificates: true,
|
noCheckCertificates: true,
|
||||||
noWarnings: true,
|
noWarnings: true,
|
||||||
preferFreeFormats: true
|
preferFreeFormats: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,41 +50,41 @@ function streamYouTube(link: string, format: string): ReadableStream<Uint8Array>
|
||||||
* Sanitize filename by removing unsafe characters
|
* Sanitize filename by removing unsafe characters
|
||||||
*/
|
*/
|
||||||
function sanitizeFilename(name: string): string {
|
function sanitizeFilename(name: string): string {
|
||||||
return name.replace(/[\/:*?"<>|]/g, '').trim();
|
return name.replace(/[\/:*?"<>|]/g, '').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GET: RequestHandler = async ({ url }) => {
|
export const GET: RequestHandler = async ({ url }) => {
|
||||||
// Get query params
|
// Get query params
|
||||||
const link = url.searchParams.get('link');
|
const link = url.searchParams.get('link');
|
||||||
const format = url.searchParams.get('format'); // mp3, mp4
|
const format = url.searchParams.get('format'); // mp3, mp4
|
||||||
const source = url.searchParams.get('source'); // youtube or spotify
|
const source = url.searchParams.get('source'); // youtube or spotify
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!link || !format || !source) {
|
if (!link || !format || !source) {
|
||||||
throw error(400, 'Missing required query parameters: link, format, or source');
|
throw error(400, 'Missing required query parameters: link, format, or source');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source !== 'youtube') {
|
if (source !== 'youtube') {
|
||||||
throw error(400, 'Currently, only YouTube is supported');
|
throw error(400, 'Currently, only YouTube is supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch metadata for filename
|
// Fetch metadata for filename
|
||||||
const metadata = await getYouTubeMetadata(link);
|
const metadata = await getYouTubeMetadata(link);
|
||||||
const { title, uploader } = metadata;
|
const { title, uploader } = metadata;
|
||||||
const safeTitle = sanitizeFilename(`${uploader} - ${title}`);
|
const safeTitle = sanitizeFilename(`${uploader} - ${title}`);
|
||||||
const filename = `${safeTitle}.${format}`;
|
const filename = `${safeTitle}.${format}`;
|
||||||
|
|
||||||
console.log(filename)
|
console.log(filename);
|
||||||
// Stream video/audio
|
// Stream video/audio
|
||||||
return new Response(streamYouTube(link, format), {
|
return new Response(streamYouTube(link, format), {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': format === 'mp3' ? 'audio/mpeg' : 'video/mp4',
|
'Content-Type': format === 'mp3' ? 'audio/mpeg' : 'video/mp4',
|
||||||
'Content-Disposition': `attachment; filename="${filename}"`
|
'Content-Disposition': `attachment; filename="${filename}"`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching metadata:', err);
|
console.error('Error fetching metadata:', err);
|
||||||
throw error(500, 'Failed to fetch video metadata');
|
throw error(500, 'Failed to fetch video metadata');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ const CACHE = `cache-${version}`;
|
||||||
|
|
||||||
const ASSETS = [
|
const ASSETS = [
|
||||||
...build, // the app itself
|
...build, // the app itself
|
||||||
...files // everything in `static`
|
...files // everything in `static`
|
||||||
];
|
];
|
||||||
|
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event) => {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "EmersaDownloader",
|
"name": "EmersaDownloader",
|
||||||
"start_url": "https://dl.emersa.it",
|
"start_url": "https://dl.emersa.it",
|
||||||
"theme_color": "rgb(34,197,94)",
|
"theme_color": "rgb(34,197,94)",
|
||||||
"background": "black",
|
"background": "black",
|
||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"display": "fullscreen",
|
"display": "fullscreen",
|
||||||
"short_name": "e-downloader",
|
"short_name": "e-downloader",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "favicon.png",
|
"src": "favicon.png",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"sizes": "128x128"
|
"sizes": "128x128"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue