Skip to content

Instantly share code, notes, and snippets.

@yusufusta
Forked from kursadHD/video.js
Last active December 15, 2020 20:31
Show Gist options
  • Save yusufusta/01e1e055c9d7263aebd767013f8129f5 to your computer and use it in GitHub Desktop.
Save yusufusta/01e1e055c9d7263aebd767013f8129f5 to your computer and use it in GitHub Desktop.
const Asena = require('../events');
const {MessageType,Mimetype} = require('@adiwajshing/baileys');
const translatte = require('translatte');
const config = require('../config');
const ytdl = require('ytdl-core');
const ffmpeg = require('fluent-ffmpeg');
const yts = require( 'yt-search' )
const got = require("got");
const fs = require('fs');
const ID3Writer = require('browser-id3-writer');
const SpotifyWebApi = require('spotify-web-api-node');
const Language = require('../language');
const Lang = Language.getString('scrapers');
Asena.addCommand({pattern: 'video ?(.*)', fromMe: false, desc: Lang.VIDEO_DESC}, (async (message, match) => {
if (match[1] === '') return await message.sendMessage(Lang.NEED_VIDEO);
try {
var arama = await yts({videoId: ytdl.getURLVideoID(match[1])});
} catch {
return await message.sendMessage(Lang.NO_RESULT);
}
var reply = await message.reply(Lang.DOWNLOADING_VIDEO);
var yt = ytdl(arama.videoId, {filter: format => format.container === 'mp4' && ['720p', '480p', '360p', '240p', '144p'].map(() => true)});
yt.pipe(fs.createWriteStream('./' + arama.videoId + '.mp4'));
yt.on('end', async () => {
await reply.delete();
reply = await message.reply(Lang.UPLOADING_VIDEO);
await message.client.sendMessage(message.jid, fs.readFileSync('./' + arama.videoId + '.mp4'), MessageType.video, {mimetype: Mimetype.mp4, caption: 'deneme'});
await reply.delete();
});
}));
Asena.addCommand({pattern: 'yt ?(.*)', fromMe: false, desc: Lang.YT_DESC}, (async (message, match) => {
if (match[1] === '') return await message.sendMessage(Lang.NEED_WORDS);
var reply = await message.reply(Lang.GETTING_VIDEOS);
try {
var arama = await yts(match[1]);
} catch {
return await message.sendMessage(Lang.NOT_FOUND);
}
var mesaj = '';
arama.all.map((video) => {
mesaj += '*' + video.title + '* - ' + video.url + '\n'
});
await message.sendMessage(mesaj);
await reply.delete();
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment