Skip to content
This repository was archived by the owner on Oct 27, 2024. It is now read-only.

Commit 44edc87

Browse files
fixed spotify
1 parent 6e8b6fd commit 44edc87

File tree

2 files changed

+61
-15
lines changed

2 files changed

+61
-15
lines changed

HandleMsg.js

+58-14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ const FormData = require('form-data')
77
const os = require('os')
88
const apirizky = require('rzkyfdlh-api')
99
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+
})
1024
const loliwrap = new lolis()
1125
const { getSFWImage, getNSFWImage } = require('waifu.pics-wrapper')
1226
const speed = require('performance-now')
@@ -5180,6 +5194,10 @@ module.exports = HandleMsg = async (urbae, message) => {
51805194
urbae.sendFileFromUrl(from, result.nowm, '', '', id)
51815195
.then(() => {
51825196
console.log('Success sending video')
5197+
stalkuy.getMusic(q)
5198+
.then(res => {
5199+
urbae.sendFileFromUrl(from, res.playURL, '', '', id)
5200+
})
51835201
})
51845202
.catch(() => {
51855203
urbae.reply(from, 'Sedang error atau mungkin link video tidak valid', id)
@@ -5552,23 +5570,49 @@ module.exports = HandleMsg = async (urbae, message) => {
55525570
})
55535571
break
55545572
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)
55585574
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+
})
55675583
})
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)
55715610
})
5611+
})
5612+
.catch(err => {
5613+
console.log(err)
5614+
urbae.reply(from, err.message, id)
5615+
})
55725616
break
55735617
case prefix + 'spotify2':
55745618
if (args.length == 0) return urbae.reply(from, `Untuk mencari lagu dari spotify, gunakan ${prefix}spotify judul lagu`, id)

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@
6060
"rumus-bdr": "^1.0.0",
6161
"rzkyfdlh-api": "^0.3.2",
6262
"sharp": "0.28.3",
63+
"spotify-finder": "^2.1.1",
64+
"spotifydl-core": "^0.2.0",
6365
"stream": "0.0.2",
6466
"tiktok-scraper-ts": "^1.2.2",
6567
"translatte": "^3.0.1",
6668
"waifu.pics-wrapper": "^1.0.0",
6769
"xfarr-api": "^1.0.3",
6870
"xteam-api": "^0.0.7",
6971
"yt-search": "^2.10.3",
70-
"ytdl-core": "^4.10.1",
72+
"ytdl-core": "^4.11.0",
7173
"yuzzu-api": "^1.0.2"
7274
},
7375
"directories": {

0 commit comments

Comments
 (0)