mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Using native yt-dlp on Linux instead of the wrapper one
This commit is contained in:
parent
0df4b3f387
commit
76683d8381
@ -7,14 +7,16 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const ytDlpPaths = {
|
||||
linux: path.resolve(__dirname, '../plugins/yt-dlp/yt-dlp'),
|
||||
win32: path.resolve(__dirname, '../plugins/yt-dlp/yt-dlp.exe'),
|
||||
darwin: path.resolve(__dirname, '../plugins/yt-dlp/yt-dlp_macos'),
|
||||
};
|
||||
|
||||
function getYtDlpPath() {
|
||||
const platform = os.platform();
|
||||
return ytDlpPaths[platform] || ytDlpPaths.linux;
|
||||
if (platform === 'linux') {
|
||||
return 'yt-dlp';
|
||||
}l
|
||||
return ytDlpPaths[platform] || 'yt-dlp';
|
||||
};
|
||||
|
||||
async function downloadFromYoutube(command, args) {
|
||||
|
@ -6,18 +6,27 @@ const os = require('os');
|
||||
const downloadDir = path.resolve(__dirname, 'yt-dlp');
|
||||
|
||||
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',
|
||||
darwin: 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos',
|
||||
};
|
||||
|
||||
function getDownloadUrl() {
|
||||
const platform = os.platform();
|
||||
return urls[platform] || urls.linux;
|
||||
return urls[platform];
|
||||
};
|
||||
|
||||
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();
|
||||
if (!url) {
|
||||
console.error('Unsupported platform for yt-dlp download.');
|
||||
return;
|
||||
}
|
||||
|
||||
const fileName = url.split('/').pop();
|
||||
const filePath = path.join(downloadDir, fileName);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user