KOW-10 /yt supports more urls and should not be validated yet
This commit is contained in:
parent
fb3193c444
commit
07a6cb2ba8
1 changed files with 6 additions and 8 deletions
|
@ -69,7 +69,7 @@ export default (bot) => {
|
||||||
const ytDlpPath = getYtDlpPath();
|
const ytDlpPath = getYtDlpPath();
|
||||||
const userId: number = ctx.from.id;
|
const userId: number = ctx.from.id;
|
||||||
const videoUrl: string = ctx.message.text.split(' ').slice(1).join(' ');
|
const videoUrl: string = ctx.message.text.split(' ').slice(1).join(' ');
|
||||||
const videoUrlSafe: boolean = ytUrl.valid(videoUrl);
|
const videoIsYoutube: boolean = ytUrl.valid(videoUrl);
|
||||||
const randId: string = Math.random().toString(36).substring(2, 15);
|
const randId: string = Math.random().toString(36).substring(2, 15);
|
||||||
const mp4File: string = `tmp/${userId}-${randId}.mp4`;
|
const mp4File: string = `tmp/${userId}-${randId}.mp4`;
|
||||||
const tempMp4File: string = `tmp/${userId}-${randId}.f137.mp4`;
|
const tempMp4File: string = `tmp/${userId}-${randId}.f137.mp4`;
|
||||||
|
@ -79,20 +79,18 @@ export default (bot) => {
|
||||||
const ffmpegPath: string = getFfmpegPath();
|
const ffmpegPath: string = getFfmpegPath();
|
||||||
const ffmpegArgs: string[] = ['-i', tempMp4File, '-i', tempWebmFile, '-c:v copy -c:a copy -strict -2', mp4File];
|
const ffmpegArgs: string[] = ['-i', tempMp4File, '-i', tempWebmFile, '-c:v copy -c:a copy -strict -2', mp4File];
|
||||||
|
|
||||||
console.log(`DOWNLOADING: ${videoUrl}\nSAFE: ${videoUrlSafe}\n`)
|
console.log(`DOWNLOADING: ${videoUrl}\nYOUTUBE: ${videoIsYoutube}\n`)
|
||||||
|
|
||||||
|
/*
|
||||||
|
for now, no checking is done for the video url
|
||||||
|
yt-dlp should handle the validation, though it supports too many sites to hard-code
|
||||||
|
*/
|
||||||
if (!videoUrl) {
|
if (!videoUrl) {
|
||||||
return ctx.reply(Strings.ytDownload.noLink, {
|
return ctx.reply(Strings.ytDownload.noLink, {
|
||||||
parse_mode: "Markdown",
|
parse_mode: "Markdown",
|
||||||
disable_web_page_preview: true,
|
disable_web_page_preview: true,
|
||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
} else if (!videoUrlSafe) {
|
|
||||||
return ctx.reply(Strings.ytDownload.notYtLink, {
|
|
||||||
parse_mode: "Markdown",
|
|
||||||
disable_web_page_preview: true,
|
|
||||||
reply_to_message_id: ctx.message.message_id
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(path.resolve(__dirname, "../props/cookies.txt"))) {
|
if (fs.existsSync(path.resolve(__dirname, "../props/cookies.txt"))) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue