Ledger Nano X - The secure hardware wallet
SHARE
TWEET

YtdL

IbnuSyawall May 20th, 2020 (edited) 972 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   - name: Yt Downloader
  3.   - author: ibnusyawall
  4.   - challange by: Bilal
  5.   - require: node [needle, superagent, html-to-json, readline, colors, ora]
  6.   - install: wget https://pastebin.com/raw/Y7m1JMpv -O ytdl.js
  7. */
  8.  
  9. const needle = require('needle')
  10. const ora = require('ora')
  11. const fs  = require('fs')
  12. const superagent = require('superagent')
  13. const html2json  = require('html-to-json')
  14. const readline = require('readline')
  15. const spinner  = ora('[+] Downloading ... ')
  16. require('colors')
  17. spinner.color = 'yellow'
  18.  
  19. const ask = readline.createInterface({
  20.   input : process.stdin,
  21.   output: process.stdout
  22. })
  23.  
  24. const log = console.log
  25.  
  26. log('\n['.green, '       YTdL by Ibnusyawall       ', ']'.green)
  27. log('          Black Coder Crush      ')
  28.  
  29. const config = {
  30.   _url: `https://stafaband-76.com/grab/search/`
  31. }
  32.  
  33. const _getId = (link, callback) => {
  34.   superagent.post('https://mate12.y2mate.com/mp3/ajax').send({
  35.     url: link,
  36.     ajax: '1',
  37.   }).set('content-type', 'application/x-www-form-urlencoded; charset=UTF-8').end((err, res) => {
  38.     if (err) throw err;
  39.     const data = JSON.parse(res.text)
  40.     const html = data.result
  41.     const _id_ = html.indexOf('_id:')
  42.     const _vid = html.indexOf('v_id:')
  43.     const __id = html.slice(_id_, _id_+31).split(' ')[1]
  44.     const __vid= html.slice(_vid, _vid+19).split(' ')[1]
  45.     callback(undefined, {
  46.       id: __id.replace(/[\']/gi, ""),
  47.       vid: __vid.replace(/[\']/gi, "")
  48.     })
  49.   })
  50. }
  51.  
  52. const _getLink = (_link, callback) => {
  53.   _getId(_link, (error, {id, vid} = {}) => {
  54.     superagent.post('https://mate06.y2mate.com/mp3Convert').send({
  55.       type: 'youtube',
  56.       _id: `${id}`,
  57.       v_id: `${vid}`,
  58.       mp3_type: '128'
  59.     }).set('content-type', 'application/x-www-form-urlencoded; charset=UTF-8').end((err, res) => {
  60.       if (err) throw err;
  61.       const data = JSON.parse(res.text)
  62.       const html = data.result
  63.       html2json.parse(`${html}`, {
  64.         'link': ['a', (alink) => {
  65.           return alink.attr('href')
  66.         }]
  67.       }, (err, result) => {
  68.         if (err) throw err
  69.         callback(undefined, {
  70.           link: result['link']['0']
  71.         })
  72.       })
  73.     })
  74.   })
  75. }
  76.  
  77. ask.question('\n[?] Query: ', (q) => {
  78.   if (q == '') {
  79.     log('[!] Harap masukan query.'); process.exit()
  80.   } else {
  81.     superagent.get(`${config._url}${q}`).end((err, res) => {
  82.       if (err) throw err
  83.       let i = 0
  84.       const json = [... res['body']]
  85.       log('\n[+] Total: ', json.length, '\n')
  86.         let jd = new Array()
  87.         json.forEach(({title}) => {
  88.           log(`[${i++}]`, title)
  89.           return jd.push(title)
  90.         })
  91.         const _cari = (_title, callback) => {
  92.           const _dt = json.find((obj) => {
  93.             return obj.title === _title
  94.           })
  95.           callback(undefined, {
  96.             _dtch: _dt
  97.           })
  98.         }
  99.         ask.question(`\n[?] choice [0-${json.length-1}]: `, (_ch) => {
  100.           if (_ch >= json.length-1) {
  101.             log('\n[!] Tidak ditemukan nomor', _ch)
  102.           } else {
  103.             _cari(jd[`${_ch}`], (error, {_dtch} = {}) => {
  104.               log('\njudul :', _dtch['title'])
  105.               log('durasi:', _dtch['videoTime'])
  106.               _getLink(`https://youtu.be/${_dtch['id']}`, (error, {link} = {}) => {
  107.                 spinner.start()
  108.                 const output = fs.createWriteStream(`./ostch | ${_dtch['title']}.mp3`)
  109.                 needle.get(link).pipe(output).on('finish', () => {
  110.                   spinner.text = 'Selesai.'
  111.                   spinner.succeed(`Berhasil didownload: ${_dtch['title']}`)
  112.                 })
  113.               })
  114.             })
  115.           }
  116.         })
  117.     })
  118.   }
  119. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top