remove //
This commit is contained in:
parent
14f4753b27
commit
13d3607a54
@ -183,10 +183,10 @@ class DownloadVideo {
|
||||
title: info.title,
|
||||
description: info.description,
|
||||
uploader: info.uploader,
|
||||
duration: info.duration, // секунды
|
||||
duration: info.duration,
|
||||
thumbnail:
|
||||
info.thumbnails?.[info.thumbnails.length - 1]?.url ||
|
||||
info.thumbnail, // лучшее превью
|
||||
info.thumbnail,
|
||||
url: info.webpage_url,
|
||||
thumbnails: info.thumbnails
|
||||
});
|
||||
@ -239,33 +239,19 @@ class DownloadVideo {
|
||||
const formats = await this.getFormats();
|
||||
const q = {};
|
||||
|
||||
// Перебираем форматы и группируем по расширению
|
||||
formats.forEach(f => {
|
||||
if (!f.ext || !f.format_id) return;
|
||||
//if (!q[f.ext]) q[f.ext] = [];
|
||||
|
||||
const resolution = f.height ? `${f.height}p` : 'audio-only';
|
||||
|
||||
let flag = `bestaudio[ext=${f.ext}]`;
|
||||
if (f.height) {
|
||||
//flag = `best[height<=${f.height}][ext=${f.ext}]`;
|
||||
flag = [
|
||||
`best[height<=${
|
||||
f.height
|
||||
}]`,
|
||||
/*`bestvideo[height<=${
|
||||
f.height
|
||||
}]+bestaudio[ext=m4a]/best`,*/
|
||||
/*`bestvideo[height<=${
|
||||
f.height
|
||||
}][vcodec^=avc1]+bestaudio[ext=m4a]/best[ext=${f.ext}]`,*/
|
||||
/*`bestvideo[height<=${
|
||||
f.height
|
||||
}][vcodec^=mov]+bestaudio[ext=m4a]/best`,*/
|
||||
"--merge-output-format", f.ext
|
||||
];
|
||||
}
|
||||
//const flag = f.format_id;
|
||||
|
||||
const mimeType = mime.getType(f.ext);
|
||||
const type = (resolution === "audio-only" || /^audio\//m.test(mimeType)) ? "audio" : (
|
||||
@ -324,22 +310,17 @@ class DownloadVideo {
|
||||
const params = [
|
||||
"--cookies", "cookies.txt",
|
||||
"--user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
|
||||
//"--extractor-args", "youtube:player-client=default,mweb;po_token=mweb.gvs+XXX",
|
||||
"--extractor-args", "youtube:player_client=default,mweb",
|
||||
"-f", ...flags,
|
||||
"-o", !isPath ? "-" : isStream, this.url,
|
||||
];
|
||||
d("yt-dlp " + params.join(" "));
|
||||
//console.debug({ HOME: process.env.HOME });
|
||||
const child = spawn("yt-dlp", params, {
|
||||
env: {
|
||||
...process.env,
|
||||
//HOME: process.env.HOME,
|
||||
LANG: "en_US.UTF-8",
|
||||
},
|
||||
stdio: ["pipe","pipe","pipe"],
|
||||
//stdio: ["pipe","inherit","pipe"],
|
||||
//stdio: ["inherit", "inherit", "inherit"],
|
||||
});
|
||||
let downloaded = 0;
|
||||
let percent = 0;
|
||||
@ -349,8 +330,6 @@ class DownloadVideo {
|
||||
|
||||
const stderrHandler = (data) => {
|
||||
const str = data.toString();
|
||||
//console.debug("DEBUG >>>>>>", str);
|
||||
//console.debug(str);
|
||||
const match = str.match(/(\d+\.\d+)%/);
|
||||
if (match && cb) {
|
||||
percent = parseFloat(match[1]);
|
||||
@ -364,7 +343,6 @@ class DownloadVideo {
|
||||
child.stdout.on("data", stderrHandler);
|
||||
|
||||
child.on("close", async (code) => {
|
||||
//console.debug(">>>>>>>>>>>>>FINISHED");
|
||||
signal.emit("finish");
|
||||
fine = true;
|
||||
if (code !== 0) {
|
||||
@ -377,10 +355,8 @@ class DownloadVideo {
|
||||
return resolve(isStream);
|
||||
const ffmpeg = new FFMPEG(isStream);
|
||||
const fileConverted = isStream +
|
||||
//".converted." +
|
||||
".mp3";
|
||||
const videoInfo = await this.getVideoInfo();
|
||||
//console.debug("videoInfo::thumbnails", videoInfo.thumbnails);
|
||||
return ffmpeg.convertMusic(FFMPEG.fromFile(
|
||||
isStream, fileConverted, videoInfo.thumbnail
|
||||
)).then(readyFile => {
|
||||
@ -415,11 +391,8 @@ class DownloadVideo {
|
||||
});
|
||||
|
||||
child.on("error", reject);
|
||||
//return resolve(stream);
|
||||
//console.debug(this.quality);
|
||||
const resultedStream = this.quality.type === "video" ?
|
||||
(await ffmpeg.convert()) : stream;
|
||||
//const resultedStream = stream;
|
||||
|
||||
resultedStream.on("data", chunk => {
|
||||
sizeTg += chunk.length;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user