Added search song genius API
This commit is contained in:
18
genius.js
Normal file
18
genius.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const axios = require("axios");
|
||||
const config = require("./config/config.json");
|
||||
|
||||
class Genius {
|
||||
async search_song(q, callback) {
|
||||
axios({
|
||||
method: "get",
|
||||
url: "https://api.genius.com/search?q=" + q,
|
||||
headers: {'Authorization': 'Bearer ' + config["genius-token"]}
|
||||
}).then(response => {
|
||||
return callback(response.data.response.hits[0]);
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new Genius();
|
||||
Reference in New Issue
Block a user