mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-21 13:03:19 +03:00
Removed node-youtube-dl dependency
This commit is contained in:
@@ -7,7 +7,6 @@ const logger = require('./logger');
|
||||
const utils = require('./utils');
|
||||
const CONSTS = require('./consts');
|
||||
const config_api = require('./config.js');
|
||||
const youtubedl = require('youtube-dl');
|
||||
|
||||
const is_windows = process.platform === 'win32';
|
||||
|
||||
@@ -39,7 +38,7 @@ exports.runYoutubeDL = async (url, args, downloadMethod = null) => {
|
||||
}
|
||||
|
||||
// Run youtube-dl in a main thread (with possible downloadMethod)
|
||||
exports.runYoutubeDLMain = async (url, args, downloadMethod = youtubedl.exec) => {
|
||||
exports.runYoutubeDLMain = async (url, args, downloadMethod = defaultDownloadMethod) => {
|
||||
return new Promise(resolve => {
|
||||
downloadMethod(url, args, {maxBuffer: Infinity}, async function(err, output) {
|
||||
const parsed_output = utils.parseOutputJSON(output, err);
|
||||
@@ -68,6 +67,12 @@ async function getYoutubeDLPath() {
|
||||
return guessed_base_path + 'youtube-dl' + (is_windows ? '.exe' : '');
|
||||
}
|
||||
|
||||
async function defaultDownloadMethod(url, args, options, callback) {
|
||||
const {child_process, _} = await runYoutubeDLProcess(url, args);
|
||||
const {stdout, stderr} = await child_process;
|
||||
return await callback(stderr, stdout.trim().split(/\r?\n/));
|
||||
}
|
||||
|
||||
exports.killYoutubeDLProcess = async (child_process) => {
|
||||
kill(child_process.pid, 'SIGKILL');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user