Download yt-dlp executable for Linux since using the native one isn't helping too much...

This commit is contained in:
Lucas Gabriel 2024-09-29 23:14:52 -03:00
parent 459a2857b3
commit d5ab223f13
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985

View File

@ -6,27 +6,18 @@ const os = require('os');
const downloadDir = path.resolve(__dirname, 'yt-dlp'); const downloadDir = path.resolve(__dirname, 'yt-dlp');
const urls = { const urls = {
linux: 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp',
win32: 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe', win32: 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe',
darwin: 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos', darwin: 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos',
}; };
function getDownloadUrl() { function getDownloadUrl() {
const platform = os.platform(); const platform = os.platform();
return urls[platform]; return urls[platform] || urls.linux;
}; };
async function downloadYtDlp() { async function downloadYtDlp() {
if (os.platform() === 'linux') {
console.log('Skipping yt-dlp download on Linux. It should be installed via pip.');
return;
}
const url = getDownloadUrl(); const url = getDownloadUrl();
if (!url) {
console.error('Unsupported platform for yt-dlp download.');
return;
}
const fileName = url.split('/').pop(); const fileName = url.split('/').pop();
const filePath = path.join(downloadDir, fileName); const filePath = path.join(downloadDir, fileName);