HerzaJ commited on
Commit
33643e3
·
verified ·
1 Parent(s): 79b96bf

Create whatsong.js

Browse files
Files changed (1) hide show
  1. plugins/whatsong.js +39 -0
plugins/whatsong.js ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { whatmusic } = require('notmebotz-tools');
2
+
3
+ const handler = async (req, res) => {
4
+ try {
5
+ const { url } = req.query;
6
+
7
+ if (!url) {
8
+ return res.status(400).json({
9
+ success: false,
10
+ error: 'Missing required parameter: url'
11
+ });
12
+ }
13
+
14
+ const result = await whatmusic(url);
15
+ res.json({
16
+ author: "Herza",
17
+ success: true,
18
+ data: result.results
19
+ });
20
+
21
+ } catch (error) {
22
+ res.status(500).json({
23
+ success: false,
24
+ error: error.message
25
+ });
26
+ }
27
+ };
28
+
29
+ module.exports = {
30
+ name: 'What Music',
31
+ description: 'Search an song only by song URL',
32
+ type: 'GET',
33
+ routes: ['api/search/whatmusic'],
34
+ tags: ['downloader', 'tools', 'misc'],
35
+ parameters: ['url', 'key'],
36
+ enabled: true,
37
+ main: ['Downloader'],
38
+ handler
39
+ }