-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
let fetch = require('fetch') | ||
let { JSDOM } = require('jsdom') | ||
let handler = async (m, { conn, text }) => { | ||
conn.reply(m.chat, Object.entries(await stylizeText(text ? text : m.quoted && m.quoted.text ? m.quoted.text : m.text)).map(([name, value]) => `*${name}*\n${value}`).join`\n\n`, m) | ||
} | ||
handler.help = ['style'].map(v => v + ' <text>') | ||
handler.tags = ['tools'] | ||
handler.command = /^(style)$/i | ||
handler.owner = false | ||
handler.mods = false | ||
handler.premium = false | ||
handler.group = false | ||
handler.private = false | ||
|
||
handler.admin = false | ||
handler.botAdmin = false | ||
|
||
handler.fail = null | ||
handler.exp = 0 | ||
|
||
module.exports = handler | ||
|
||
async function stylizeText(text) { | ||
let res = await fetch('http://qaz.wtf/u/convert.cgi?text=' + encodeURIComponent(text)) | ||
let html = await res.text() | ||
let dom = new JSDOM(html) | ||
let table = dom.window.document.querySelector('table').children[0].children | ||
let obj = {} | ||
for (let tr of table) { | ||
let name = tr.querySelector('.aname').innerHTML | ||
let content = tr.children[1].textContent.replace(/^\n/, '').replace(/\n$/, '') | ||
obj[name + (obj[name] ? ' Reversed' : '')] = content | ||
} | ||
return obj | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
let fetch = require('fetch') | ||
let { JSDOM } = require('jsdom') | ||
let limit = 300 | ||
let handler = async (m, { conn, args }) => { | ||
if (!args || !args[0]) return conn.reply(m.chat, 'Uhm... urlnya mana?', m) | ||
let { dl_link, thumb, title, filesize, filesizeF} = await ytv(args[0]) | ||
let isLimit = limit * 1024 < filesize | ||
conn.sendFile(m.chat, thumb, 'thumbnail.jpg', ` | ||
*Title:* ${title} | ||
*Filesize:* ${filesizeF} | ||
*${isLimit ? 'Pakai ': ''}Link:* ${dl_link} | ||
`.trim(), m) | ||
if (!isLimit) conn.sendFile(m.chat, dl_link, 'video.mp4', ` | ||
*Title:* ${title} | ||
*Filesize:* ${filesizeF} | ||
`.trim(), m) | ||
} | ||
handler.help = ['mp3','a'].map(v => 'yt' + v + ' <url>') | ||
handler.tags = ['downloader'] | ||
handler.command = /^yt(a|mp3)$/i | ||
handler.owner = false | ||
handler.mods = false | ||
handler.premium = false | ||
handler.group = false | ||
handler.private = false | ||
|
||
handler.admin = false | ||
handler.botAdmin = false | ||
|
||
handler.fail = null | ||
handler.exp = 0 | ||
handler.limit = true | ||
|
||
module.exports = handler | ||
|
||
function post(url, formdata) { | ||
console.log(Object.keys(formdata).map(key => `${key}=${encodeURIComponent(formdata[key])}`).join('&')) | ||
return fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
accept: "*/*", | ||
'accept-language': "en-US,en;q=0.9", | ||
'content-type': "application/x-www-form-urlencoded; charset=UTF-8" | ||
}, | ||
body: Object.keys(formdata).map(key => `${key}=${encodeURIComponent(formdata[key])}`).join('&') | ||
}) | ||
} | ||
const ytIdRegex = /(?:http(?:s|):\/\/|)(?:(?:www\.|)youtube(?:\-nocookie|)\.com\/(?:watch\?.*(?:|\&)v=|embed\/|v\/)|youtu\.be\/)([-_0-9A-Za-z]{11})/ | ||
function ytv(url) { | ||
return new Promise((resolve, reject) => { | ||
if (ytIdRegex.test(url)) { | ||
let ytId = ytIdRegex.exec(url) | ||
url = 'https://youtu.be/' + ytId[1] | ||
post('https://www.y2mate.com/mates/en60/analyze/ajax', { | ||
url, | ||
q_auto: 0, | ||
ajax: 1 | ||
}) | ||
.then(res => res.json()) | ||
.then(res => { | ||
console.log('Scraping...') | ||
document = (new JSDOM(res.result)).window.document | ||
yaha = document.querySelectorAll('td') | ||
filesize = yaha[yaha.length - 23].innerHTML | ||
id = /var k__id = "(.*?)"/.exec(document.body.innerHTML) || ['', ''] | ||
thumb = document.querySelector('img').src | ||
title = document.querySelector('b').innerHTML | ||
|
||
post('https://www.y2mate.com/mates/en60/convert', { | ||
type: 'youtube', | ||
_id: id[1], | ||
v_id: ytId[1], | ||
ajax: '1', | ||
token: '', | ||
ftype: 'mp3', | ||
fquality: 128 | ||
}) | ||
.then(res => res.json()) | ||
.then(res => { | ||
let KB = parseFloat(filesize) * (1000 * /MB$/.test(filesize)) | ||
resolve({ | ||
dl_link: /<a.+?href="(.+?)"/.exec(res.result)[1], | ||
thumb, | ||
title, | ||
filesizeF: filesize, | ||
filesize: KB | ||
}) | ||
}).catch(reject) | ||
}).catch(reject) | ||
} else reject('URL INVALID') | ||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
let fetch = require('fetch') | ||
let { JSDOM } = require('jsdom') | ||
let limit = 300 | ||
let handler = async (m, { conn, args }) => { | ||
if (!args || !args[0]) return conn.reply(m.chat, 'Uhm... urlnya mana?', m) | ||
let { dl_link, thumb, title, filesize, filesizeF} = await ytv(args[0]) | ||
let isLimit = limit * 1024 < filesize | ||
conn.sendFile(m.chat, thumb, 'thumbnail.jpg', ` | ||
*Title:* ${title} | ||
*Filesize:* ${filesizeF} | ||
*${isLimit ? 'Pakai ': ''}Link:* ${dl_link} | ||
`.trim(), m) | ||
if (!isLimit) conn.sendFile(m.chat, dl_link, 'video.mp4', ` | ||
*Title:* ${title} | ||
*Filesize:* ${filesizeF} | ||
`.trim(), m) | ||
} | ||
handler.help = ['mp4','v',''].map(v => 'yt' + v + ' <url>') | ||
handler.tags = ['downloader'] | ||
handler.command = /^yt(v|mp4)?$/i | ||
handler.owner = false | ||
handler.mods = false | ||
handler.premium = false | ||
handler.group = false | ||
handler.private = false | ||
|
||
handler.admin = false | ||
handler.botAdmin = false | ||
|
||
handler.fail = null | ||
handler.exp = 0 | ||
handler.limit = true | ||
|
||
module.exports = handler | ||
|
||
function post(url, formdata) { | ||
console.log(Object.keys(formdata).map(key => `${key}=${encodeURIComponent(formdata[key])}`).join('&')) | ||
return fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
accept: "*/*", | ||
'accept-language': "en-US,en;q=0.9", | ||
'content-type': "application/x-www-form-urlencoded; charset=UTF-8" | ||
}, | ||
body: Object.keys(formdata).map(key => `${key}=${encodeURIComponent(formdata[key])}`).join('&') | ||
}) | ||
} | ||
const ytIdRegex = /(?:http(?:s|):\/\/|)(?:(?:www\.|)youtube(?:\-nocookie|)\.com\/(?:watch\?.*(?:|\&)v=|embed\/|v\/)|youtu\.be\/)([-_0-9A-Za-z]{11})/ | ||
function ytv(url) { | ||
return new Promise((resolve, reject) => { | ||
if (ytIdRegex.test(url)) { | ||
let ytId = ytIdRegex.exec(url) | ||
url = 'https://youtu.be/' + ytId[1] | ||
post('https://www.y2mate.com/mates/en60/analyze/ajax', { | ||
url, | ||
q_auto: 0, | ||
ajax: 1 | ||
}) | ||
.then(res => res.json()) | ||
.then(res => { | ||
console.log('Scraping...') | ||
document = (new JSDOM(res.result)).window.document | ||
yaha = document.querySelectorAll('td') | ||
filesize = yaha[yaha.length - 23].innerHTML | ||
id = /var k__id = "(.*?)"/.exec(document.body.innerHTML) || ['', ''] | ||
thumb = document.querySelector('img').src | ||
title = document.querySelector('b').innerHTML | ||
|
||
post('https://www.y2mate.com/mates/en60/convert', { | ||
type: 'youtube', | ||
_id: id[1], | ||
v_id: ytId[1], | ||
ajax: '1', | ||
token: '', | ||
ftype: 'mp4', | ||
fquality: 360 | ||
}) | ||
.then(res => res.json()) | ||
.then(res => { | ||
let KB = parseFloat(filesize) * (1000 * /MB$/.test(filesize)) | ||
resolve({ | ||
dl_link: /<a.+?href="(.+?)"/.exec(res.result)[1], | ||
thumb, | ||
title, | ||
filesizeF: filesize, | ||
filesize: KB | ||
}) | ||
}).catch(reject) | ||
}).catch(reject) | ||
} else reject('URL INVALID') | ||
}) | ||
} | ||
|