| 53 | } |
| 54 | |
| 55 | const yta = async yutub => { |
| 56 | function post(url, formdata) { |
| 57 | return fetch(url, { |
| 58 | method: 'POST', |
| 59 | headers: { |
| 60 | accept: '*/*', |
| 61 | 'accept-language': 'en-US,en;q=0.9', |
| 62 | 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', |
| 63 | }, |
| 64 | body: new URLSearchParams(Object.entries(formdata)), |
| 65 | }) |
| 66 | } |
| 67 | const ytIdRegex = |
| 68 | /(?:http(?:s|):\/\/|)(?:(?:www\.|)youtube(?:\-nocookie|)\.com\/(?:watch\?.*(?:|\&)v=|embed\/|v\/)|youtu\.be\/)([-_0-9A-Za-z]{11})/ |
| 69 | let ytId = ytIdRegex.exec(yutub) |
| 70 | url = 'https://youtu.be/' + ytId[1] |
| 71 | let res = await post(`https://www.y2mate.com/mates/en68/analyze/ajax`, { |
| 72 | url, |
| 73 | q_auto: 0, |
| 74 | ajax: 1, |
| 75 | }) |
| 76 | const mela = await res.json() |
| 77 | const $ = cheerio.load(mela.result) |
| 78 | const hasil = [] |
| 79 | let thumb = $('div').find('.thumbnail.cover > a > img').attr('src') |
| 80 | let title = $('div').find('.thumbnail.cover > div > b').text() |
| 81 | let size = $('div').find('#mp3 > table > tbody > tr > td:nth-child(2)').text() |
| 82 | let tipe = $('div').find('#mp3 > table > tbody > tr > td:nth-child(3) > a').attr('data-ftype') |
| 83 | let output = `${title}.` + tipe |
| 84 | let quality = $('div') |
| 85 | .find('#mp3 > table > tbody > tr > td:nth-child(3) > a') |
| 86 | .attr('data-fquality') |
| 87 | let id = /var k__id = "(.*?)"/.exec(mela.result)[1] |
| 88 | let res2 = await post(`https://www.y2mate.com/mates/en68/convert`, { |
| 89 | type: 'youtube', |
| 90 | _id: id, |
| 91 | v_id: ytId[1], |
| 92 | ajax: '1', |
| 93 | token: '', |
| 94 | ftype: tipe, |
| 95 | fquality: quality, |
| 96 | }) |
| 97 | const meme = await res2.json() |
| 98 | const supp = cheerio.load(meme.result) |
| 99 | let link = supp('div').find('a').attr('href') |
| 100 | hasil.push({ thumb, title, quality, tipe, size, output, link }) |
| 101 | return hasil[0] |
| 102 | } |
| 103 | |
| 104 | export { yta, ytv } |
| 105 | /* |