Merge branch 'teste_yt'

This commit is contained in:
GiovaniFZ 2024-09-26 21:43:28 -03:00
commit 9e2c1104ba
No known key found for this signature in database
GPG Key ID: 63DD92181B575322
4 changed files with 40 additions and 1 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@
node_modules node_modules
__pycache__ __pycache__
props props
!props/resources.json !props/resources.json
*.mp4

28
commands/youtube.js Normal file
View File

@ -0,0 +1,28 @@
var exec = require('child_process').exec;
async function DownloadFromYoutube(command) {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
reject({ error, stdout, stderr });
} else {
resolve({ error, stdout, stderr });
}
});
});
}
module.exports = (bot) => {
bot.command('yt', async (ctx) => {
const args = ctx.message.text.split(' ').slice(1).join(' ');
const ytCommand = 'yt-dlp ' + args + ' -o video.mp4';
await DownloadFromYoutube(ytCommand);
try{
await ctx.replyWithVideo({source: 'video.mp4'});
}catch (error){
console.log(error);
}
}
)
}

9
package-lock.json generated
View File

@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"axios": "^1.7.7", "axios": "^1.7.7",
"child_process": "^1.0.2", "child_process": "^1.0.2",
"commander": "^12.1.0",
"node-html-parser": "^6.1.13", "node-html-parser": "^6.1.13",
"nodemon": "^3.1.4", "nodemon": "^3.1.4",
"telegraf": "^4.16.3", "telegraf": "^4.16.3",
@ -252,6 +253,14 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/commander": {
"version": "12.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
"engines": {
"node": ">=18"
}
},
"node_modules/concat-map": { "node_modules/concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",

View File

@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"axios": "^1.7.7", "axios": "^1.7.7",
"child_process": "^1.0.2", "child_process": "^1.0.2",
"commander": "^12.1.0",
"node-html-parser": "^6.1.13", "node-html-parser": "^6.1.13",
"nodemon": "^3.1.4", "nodemon": "^3.1.4",
"telegraf": "^4.16.3", "telegraf": "^4.16.3",