youtube-dl -> yt-dlp
This commit is contained in:
parent
dcc7fab10c
commit
e56cf37f61
|
@ -6,8 +6,16 @@ import fetch from "flumm-fetch-cookies";
|
|||
|
||||
import fs from "fs";
|
||||
import { exec as _exec } from "child_process";
|
||||
import { promisify } from "util";
|
||||
const exec = promisify(_exec);
|
||||
|
||||
const exec = cmd => new Promise((resolve, reject) => {
|
||||
_exec(cmd, { maxBuffer: 5e3 * 1024 }, (err, stdout, stderr) => {
|
||||
if(err)
|
||||
return reject(err);
|
||||
if(stderr)
|
||||
console.error(stderr);
|
||||
resolve({ stdout: stdout });
|
||||
});
|
||||
});
|
||||
|
||||
//const regex = /https?:\/\/[\w\S(\.|:|/)]+/gi;
|
||||
const regex = /https?:\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/gi;
|
||||
|
@ -49,7 +57,7 @@ export default async bot => {
|
|||
let meta;
|
||||
// read metadata
|
||||
try {
|
||||
meta = JSON.parse((await exec(`youtube-dl -f "bestvideo[ext=mp4,filesize<${maxfilesize}k][width<2000][height<=1200]+bestaudio[ext=m4a,filesize<${maxfilesize}k]/bestvideo[width<2000][height<=1200]+bestaudio/best[width<2000][height<=1200]/best" --skip-download --dump-json "${link}"`)).stdout);
|
||||
meta = JSON.parse((await exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --skip-download --dump-json "${link}"`)).stdout);
|
||||
}
|
||||
catch(err) {
|
||||
e.reply("[error] f0ck has no bock :(");
|
||||
|
@ -73,12 +81,12 @@ export default async bot => {
|
|||
const start = new Date();
|
||||
let source;
|
||||
if(meta.ext === "mp4") {
|
||||
source = (await exec(`youtube-dl "${link}" --max-filesize ${maxfilesize}k -f "bestvideo[ext=mp4,filesize<${maxfilesize}k][width<2000][height<=1200]+bestaudio[ext=m4a,filesize<${maxfilesize}k]/bestvideo[width<2000][height<=1200]+bestaudio/best[width<2000][height<=1200]/best" --merge-output-format mp4 -o ./tmp/${filename}`)).stdout.trim();
|
||||
source = (await exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' "${link}" --max-filesize ${maxfilesize}k --merge-output-format mp4 -o ./tmp/${filename}`)).stdout.trim();
|
||||
//change yt-dlp to youtube-dl if problem ^
|
||||
//console.log("mp4 lol");
|
||||
}
|
||||
else {
|
||||
source = (await exec(`youtube-dl "${link}" --max-filesize ${maxfilesize}k -f "bestvideo[filesize<${maxfilesize}k][width<2000][height<=1200][ext=${meta.ext}]+bestaudio[filesize<${maxfilesize}k][ext=${meta.ext}]/best" -o ./tmp/${filename}`)).stdout.trim();
|
||||
source = (await exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' "${link}" --max-filesize ${maxfilesize}k -o ./tmp/${filename}`)).stdout.trim();
|
||||
//change yt-dlp to youtube-dl if problem ^
|
||||
//console.log("alles andere lol");
|
||||
}
|
||||
|
@ -126,7 +134,7 @@ export default async bot => {
|
|||
|
||||
// generate thumbnail
|
||||
try {
|
||||
let thumb_orig = (await exec(`youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --get-thumbnail "${link}"`)).stdout.trim();
|
||||
let thumb_orig = (await exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --get-thumbnail "${link}"`)).stdout.trim();
|
||||
if(!thumb_orig.startsWith("http")) {
|
||||
if(mime.startsWith("image") && mime !== "image/gif")
|
||||
thumb_orig = `./public/b/${filename}`;
|
||||
|
|
Loading…
Reference in New Issue
Block a user