Advertisement
dangduong06

Untitled

Jun 17th, 2021
1,273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.  
  4. module.exports = {
  5.     keywords: ['soundcloud','scmp3'],
  6.  
  7.     name: 'soundcloud',
  8.  
  9.     description: 'Plugin tải nhạc từ Soundcloud từ url',
  10.  
  11.     guide: '<url>',
  12.  
  13.     childs: [],
  14.  
  15.     permission: {
  16.         '*': '*'
  17.     },
  18.  
  19.     datastoreDesign: {
  20.         account: {
  21.             global: {},
  22.             local: {}
  23.         },
  24.         thread: {
  25.             global: {},
  26.             local: {}
  27.         }
  28.     },
  29.  
  30.     async onLoad() {},
  31.  
  32.     hookType: 'none',
  33.  
  34.     async onMessage(message, reply) {},
  35.  
  36.     async onCall(message, reply) {
  37.         const url = kb2abot.helpers.getParam(message.body);
  38.         if (url){
  39.             const song = url.split('soundcloud.com/')[1].split('?')[0];
  40.             const url_crawl = `https://scr.flawcra.cc/${encodeURIComponent(song)}.mp3`;
  41.             let r = await fetch(url_crawl, {
  42.                 headers:{
  43.                 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063"
  44.             }});
  45.             if (r.status == 200){
  46.                 let buf = await r.buffer();
  47.                 let file = new streamBuffers.ReadableStreamBuffer({frequency: 10, chunkSize: 2048});
  48.                 file.path = "scdl.mp3", file.put(buf), file.stop();
  49.                 reply({attachment: file},   message.threadID, message.messageID)
  50.             } else {
  51.                 reply("err", message.threadID, message.messageID);
  52.             }
  53.         }
  54.        
  55.  
  56.     }
  57. };
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement