Spaces:
Paused
Paused
πππ₯π₯πππ π π¨ππππ₯π β‘
commited on
Create search-lyrics.js
Browse files- plugins/search-lyrics.js +51 -0
plugins/search-lyrics.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const axios = require('axios');
|
| 2 |
+
const { cmd } = require('../command');
|
| 3 |
+
|
| 4 |
+
cmd({
|
| 5 |
+
pattern: "lyrics",
|
| 6 |
+
desc: "Get the lyrics of a song.",
|
| 7 |
+
category: "music",
|
| 8 |
+
react: "πΆ",
|
| 9 |
+
filename: __filename
|
| 10 |
+
},
|
| 11 |
+
async (conn, mek, m, { from, reply, text }) => {
|
| 12 |
+
// Extract song title and artist from the message text
|
| 13 |
+
const [songTitle, artist] = text.split('|').map(str => str.trim());
|
| 14 |
+
|
| 15 |
+
if (!songTitle || !artist) {
|
| 16 |
+
return reply("Please provide the song title and artist in the format: `!lyrics <song_title> | <artist>`");
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
try {
|
| 20 |
+
// Replace spaces with '+' for URL encoding
|
| 21 |
+
const song = songTitle.replace(/\s+/g, '+');
|
| 22 |
+
const songArtist = artist.replace(/\s+/g, '+');
|
| 23 |
+
|
| 24 |
+
// Construct the API URL
|
| 25 |
+
const url = `https://api.davidcyriltech.my.id/lyrics?t=song a={songArtist}`;
|
| 26 |
+
|
| 27 |
+
// Fetch lyrics from the API
|
| 28 |
+
const response = await axios.get(url);
|
| 29 |
+
const data = response.data;
|
| 30 |
+
|
| 31 |
+
// Check if the response contains lyrics
|
| 32 |
+
if (data.lyrics) {
|
| 33 |
+
const lyricsMessage = `
|
| 34 |
+
πΆ *Lyrics for*: songTitle by{artist}
|
| 35 |
+
|
| 36 |
+
${data.lyrics}
|
| 37 |
+
|
| 38 |
+
*Lyrics provided by MR FRANK OFC*
|
| 39 |
+
`;
|
| 40 |
+
return reply(lyricsMessage);
|
| 41 |
+
} else {
|
| 42 |
+
return reply("Sorry, I couldn't find the lyrics for this song. Please check the song title and artist.");
|
| 43 |
+
}
|
| 44 |
+
} catch (e) {
|
| 45 |
+
console.error("Error fetching lyrics:", e);
|
| 46 |
+
reply("Β’ΟΟ
ββ Ξ·ΟΡ ΖΡΡΒ’Π½ Ξ± lΡrΞΉc. ΟβΡΞ±ΡΡ ΡΡΡ Ξ±gΞ±ΞΉΞ· βΞ±ΡΡΡ.");
|
| 47 |
+
}
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|