@roflsec/splitit
Advanced tools
+1
-1
| { | ||
| "name": "@roflsec/splitit", | ||
| "version": "1.0.23", | ||
| "version": "1.0.24", | ||
| "description": "CLI pour télécharger et séparer les pistes audio de vidéos YouTube (plug-n-play, multi-OS, Termux supporté)", | ||
@@ -5,0 +5,0 @@ "main": "scripts/cli.js", |
+9
-6
@@ -8,4 +8,4 @@ #!/usr/bin/env node | ||
| import process from 'process'; | ||
| import { fileURLToPath } from 'url'; | ||
| const __filename = fileURLToPath(import.meta.url); | ||
@@ -19,10 +19,10 @@ const __dirname = path.dirname(__filename); | ||
| } | ||
| const url = args[0]; | ||
| const BIN_DIR = path.join(__dirname, '..', 'bin'); | ||
| let FFMPEG_PATH = path.join(BIN_DIR, os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'); | ||
| const YTDLP_PATH = path.join(BIN_DIR, os.platform() === 'win32' ? 'yt-dlp.exe' : 'yt-dlp'); | ||
| // Termux détecté | ||
| // Termux override | ||
| if (process.env.TERMUX_VERSION) { | ||
@@ -46,3 +46,3 @@ FFMPEG_PATH = '/data/data/com.termux/files/usr/bin/ffmpeg'; | ||
| console.log(`🎬 Downloading with yt-dlp: ${url}`); | ||
| const outputDir = path.resolve(`output/${sanitize(url.split('v=')[1] || 'video')}`); | ||
| const outputDir = path.resolve(`output/${Date.now()}`); | ||
| fs.mkdirSync(outputDir, { recursive: true }); | ||
@@ -53,4 +53,7 @@ | ||
| ytdlpProc.on('close', (code) => { | ||
| if (code === 0) console.log(`✅ Audio saved in ${outputDir}`); | ||
| else console.error('❌ yt-dlp failed'); | ||
| if (code === 0) { | ||
| console.log(`✅ Audio saved in ${outputDir}`); | ||
| } else { | ||
| console.error('❌ yt-dlp failed'); | ||
| } | ||
| }); | ||
@@ -57,0 +60,0 @@ } catch (err) { |
@@ -1,8 +0,10 @@ | ||
| #!/usr/bin/env node | ||
| // install-binaries.js | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import os from 'os'; | ||
| import process from 'process'; | ||
| import https from 'https'; | ||
| import { pipeline } from 'stream'; | ||
| import { promisify } from 'util'; | ||
| import os from 'os'; | ||
| import unzipper from 'unzipper'; | ||
@@ -16,21 +18,3 @@ const streamPipeline = promisify(pipeline); | ||
| const BINARIES = [ | ||
| { | ||
| name: 'ffmpeg', | ||
| urls: [ | ||
| 'https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip', | ||
| 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-essentials.zip' | ||
| ], | ||
| filename: os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg', | ||
| zip: true | ||
| }, | ||
| { | ||
| name: 'yt-dlp', | ||
| urls: [ | ||
| 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp' + (os.platform() === 'win32' ? '.exe' : '') | ||
| ], | ||
| filename: os.platform() === 'win32' ? 'yt-dlp.exe' : 'yt-dlp', | ||
| zip: false | ||
| } | ||
| ]; | ||
| if (!fs.existsSync(BIN_DIR)) fs.mkdirSync(BIN_DIR, { recursive: true }); | ||
@@ -54,11 +38,12 @@ async function downloadFile(url, destPath) { | ||
| async function downloadBinary(bin) { | ||
| const destPath = path.join(BIN_DIR, bin.filename); | ||
| if (fs.existsSync(destPath)) { | ||
| console.log(`✅ ${bin.name} already exists at ${destPath}`); | ||
| return; | ||
| async function installFfmpeg() { | ||
| const ffmpegPath = path.join(BIN_DIR, os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'); | ||
| if (fs.existsSync(ffmpegPath)) { | ||
| console.log(`✅ ffmpeg already exists at ${ffmpegPath}`); | ||
| return ffmpegPath; | ||
| } | ||
| // --- DEBUT LOGIQUE TERMUX --- | ||
| if (process.env.TERMUX_VERSION && bin.name === 'ffmpeg') { | ||
| if (process.env.TERMUX_VERSION) { | ||
| const { execSync } = await import('child_process'); | ||
@@ -69,4 +54,4 @@ try { | ||
| console.log('✅ ffmpeg installed via pkg'); | ||
| return; // Skip download | ||
| } catch { | ||
| return '/data/data/com.termux/files/usr/bin/ffmpeg'; | ||
| } catch (err) { | ||
| console.warn('⚠️ pkg install failed, falling back to download...'); | ||
@@ -77,34 +62,47 @@ } | ||
| for (const url of bin.urls) { | ||
| console.log('⬇️ Downloading ffmpeg...'); | ||
| const urls = os.platform() === 'win32' | ||
| ? ['https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip'] | ||
| : ['https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-essentials.zip']; | ||
| for (const url of urls) { | ||
| try { | ||
| console.log(`⬇️ Downloading ${bin.name} from ${url}...`); | ||
| const tmpPath = path.join(BIN_DIR, bin.zip ? `${bin.name}.zip` : bin.filename); | ||
| const tmpPath = path.join(BIN_DIR, 'ffmpeg.zip'); | ||
| await downloadFile(url, tmpPath); | ||
| if (bin.zip) { | ||
| console.log(`📦 Extracting ${bin.name}...`); | ||
| const unzipper = await import('unzipper'); | ||
| await fs.createReadStream(tmpPath).pipe(unzipper.Extract({ path: BIN_DIR })).promise(); | ||
| fs.unlinkSync(tmpPath); | ||
| } | ||
| if (os.platform() !== 'win32') fs.chmodSync(destPath, 0o755); | ||
| console.log(`✅ ${bin.name} installed at ${destPath}`); | ||
| return; | ||
| console.log(`📦 Extracting ffmpeg...`); | ||
| await fs.createReadStream(tmpPath).pipe(unzipper.Extract({ path: BIN_DIR })).promise(); | ||
| fs.unlinkSync(tmpPath); | ||
| console.log(`✅ ffmpeg installed at ${ffmpegPath}`); | ||
| return ffmpegPath; | ||
| } catch (err) { | ||
| console.warn(`⚠️ Failed to download ${bin.name} from ${url}: ${err.message}`); | ||
| console.warn(`⚠️ Failed to download/extract ffmpeg from ${url}: ${err.message}`); | ||
| } | ||
| } | ||
| console.error(`❌ Could not install ${bin.name}, all sources failed.`); | ||
| throw new Error('❌ Could not install ffmpeg'); | ||
| } | ||
| async function installAll() { | ||
| if (!fs.existsSync(BIN_DIR)) fs.mkdirSync(BIN_DIR, { recursive: true }); | ||
| for (const bin of BINARIES) { | ||
| await downloadBinary(bin); | ||
| async function installYtdlp() { | ||
| const ytdlpPath = path.join(BIN_DIR, os.platform() === 'win32' ? 'yt-dlp.exe' : 'yt-dlp'); | ||
| if (fs.existsSync(ytdlpPath)) { | ||
| console.log(`✅ yt-dlp already exists at ${ytdlpPath}`); | ||
| return ytdlpPath; | ||
| } | ||
| const url = 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp' + (os.platform() === 'win32' ? '.exe' : ''); | ||
| console.log(`⬇️ Downloading yt-dlp from ${url}...`); | ||
| await downloadFile(url, ytdlpPath); | ||
| if (os.platform() !== 'win32') fs.chmodSync(ytdlpPath, 0o755); | ||
| console.log(`✅ yt-dlp installed at ${ytdlpPath}`); | ||
| return ytdlpPath; | ||
| } | ||
| installAll(); | ||
| (async () => { | ||
| try { | ||
| await installFfmpeg(); | ||
| await installYtdlp(); | ||
| } catch (err) { | ||
| console.error(err.message); | ||
| process.exit(1); | ||
| } | ||
| })(); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
32254
0.62%160
0.63%