@@ -7,6 +7,20 @@ const FormData = require('form-data')
7
7
const os = require ( 'os' )
8
8
const apirizky = require ( 'rzkyfdlh-api' )
9
9
const lolis = require ( 'lolis.life' )
10
+ const buffeerr = require ( 'buffer-from' )
11
+ const spotdl = require ( 'spotifydl-core' ) . default
12
+ const credentials = {
13
+ clientId : '271f6e790fb943cdb34679a4adcc34cc' ,
14
+ clientSecret : 'c009525564304209b7d8b705c28fd294'
15
+ }
16
+ const spotify = new spotdl ( credentials )
17
+ const spotapi = require ( 'spotify-finder' )
18
+ const spotsearch = new spotapi ( {
19
+ consumer : {
20
+ key : '271f6e790fb943cdb34679a4adcc34cc' ,
21
+ secret : 'c009525564304209b7d8b705c28fd294'
22
+ }
23
+ } )
10
24
const loliwrap = new lolis ( )
11
25
const { getSFWImage, getNSFWImage } = require ( 'waifu.pics-wrapper' )
12
26
const speed = require ( 'performance-now' )
@@ -5180,6 +5194,10 @@ module.exports = HandleMsg = async (urbae, message) => {
5180
5194
urbae . sendFileFromUrl ( from , result . nowm , '' , '' , id )
5181
5195
. then ( ( ) => {
5182
5196
console . log ( 'Success sending video' )
5197
+ stalkuy . getMusic ( q )
5198
+ . then ( res => {
5199
+ urbae . sendFileFromUrl ( from , res . playURL , '' , '' , id )
5200
+ } )
5183
5201
} )
5184
5202
. catch ( ( ) => {
5185
5203
urbae . reply ( from , 'Sedang error atau mungkin link video tidak valid' , id )
@@ -5552,23 +5570,49 @@ module.exports = HandleMsg = async (urbae, message) => {
5552
5570
} )
5553
5571
break
5554
5572
case prefix + 'spotify' :
5555
- if ( args . length == 0 ) return urbae . reply ( from , `Untuk mencari lagu dari spotify, gunakan ${ prefix } spotify2 judul lagu` , id )
5556
- const carispot2 = body . slice ( 9 )
5557
- const spos2 = await axios . get ( `https://api.zeks.me/api/spotify?apikey=${ apikeyvinz } &q=${ carispot2 } ` )
5573
+ if ( args . length == 0 ) return urbae . reply ( from , `Untuk mencari lagu dari spotify, gunakan ${ prefix } spotify judul lagu` , id )
5558
5574
urbae . reply ( from , mess . wait , id )
5559
- urbae . sendFileFromUrl ( from , spos2 . data . data [ 0 ] . thumb , 'thumb.jpg' , `「 *SPOTIFY* 」\n\n*•Title:* ${ spos2 . data . data [ 0 ] . title } \n*•Artists:* ${ spos2 . data . data [ 0 ] . artists } \n*•Album:* ${ spos2 . data . data [ 0 ] . album } \n*•Url:* ${ spos2 . data . data [ 0 ] . url } \n\n ${ mess . sendfileaudio } ` , id )
5560
- rugaapi . spotify ( spos2 . data . data [ 0 ] . url )
5561
- . then ( async ( res ) => {
5562
- if ( res . status == 500 ) return urbae . reply ( from , 'Link tidak valid atau rest api sedang error' , id )
5563
- urbae . sendFileFromUrl ( from , res . mp3 , '' , '' , id )
5564
- . catch ( ( ) => {
5565
- urbae . reply ( from , 'Meng-error' , id )
5566
- } )
5575
+ const spos2 = async ( query ) => {
5576
+ searchthis = await spotsearch . search ( { q : query , type : 'track' , limit : 1 } )
5577
+ datpot = searchthis . tracks . items [ 0 ]
5578
+ artis = [ ]
5579
+ datpot . artists . map ( s => {
5580
+ artis . push ( {
5581
+ name : s . name
5582
+ } )
5567
5583
} )
5568
- . catch ( err => {
5569
- console . log ( err )
5570
- urbae . reply ( from , err . message , id )
5584
+ return {
5585
+ title : datpot . name ,
5586
+ artists : artis ,
5587
+ releaseDate : datpot . album . release_date ,
5588
+ popularity : datpot . popularity ,
5589
+ thumb : datpot . album . images [ 0 ] . url ,
5590
+ url : datpot . external_urls . spotify
5591
+ }
5592
+ }
5593
+ spos2 ( q )
5594
+ . then ( res => {
5595
+ if ( res . artists . length == 2 ) {
5596
+ var hasil2 = `${ res . artists [ 0 ] . name } , ${ res . artists [ 1 ] . name } `
5597
+ } else {
5598
+ var hasil2 = res . artists [ 0 ] . name
5599
+ }
5600
+ urbae . sendFileFromUrl ( from , res . thumb , 'thumb.jpg' , `「 *SPOTIFY* 」\n\n*•Title:* ${ res . title } \n*•Artists:* ${ hasil2 } \n*•Release Date:* ${ res . releaseDate } \n*•Popularity:* ${ res . popularity } \n*•Url:* ${ res . url } \n\n${ mess . sendfileaudio } ` , id )
5601
+ spotify . downloadTrack ( res . url )
5602
+ . then ( data => {
5603
+ const buffaudio = buffeerr ( data )
5604
+ fs . writeFile ( `./temp/audio/${ res . title } .mp3` , buffaudio )
5605
+ sleep ( 10000 )
5606
+ urbae . sendFile ( from , `./temp/audio/${ res . title } .mp3` , '' , '' , id )
5607
+ setTimeout ( ( ) => {
5608
+ fs . unlinkSync ( `./temp/audio/${ res . title } .mp3` )
5609
+ } , 5000 )
5571
5610
} )
5611
+ } )
5612
+ . catch ( err => {
5613
+ console . log ( err )
5614
+ urbae . reply ( from , err . message , id )
5615
+ } )
5572
5616
break
5573
5617
case prefix + 'spotify2' :
5574
5618
if ( args . length == 0 ) return urbae . reply ( from , `Untuk mencari lagu dari spotify, gunakan ${ prefix } spotify judul lagu` , id )
0 commit comments