Added Spotify Support
This commit is contained in:
parent
1c0928c405
commit
b9b42c5ea7
20
.env.example
20
.env.example
|
@ -1 +1,19 @@
|
||||||
MASTER_KEY=masterKey
|
# API Webserver
|
||||||
|
MASTER_KEY=
|
||||||
|
PORT=
|
||||||
|
|
||||||
|
# Spotify API
|
||||||
|
SPOTIFY_API_AUTH_KEY=
|
||||||
|
SPOTIFY_REFRESH_TOKEN=
|
||||||
|
|
||||||
|
# Osu! API
|
||||||
|
OSU_API_KEY=
|
||||||
|
OSU_API_CLIENT_ID=
|
||||||
|
OSU_API_CLIENT_SECRET=
|
||||||
|
|
||||||
|
# Youtube API
|
||||||
|
YOUTUBE_API_KEY=
|
||||||
|
|
||||||
|
# Bravo68web API Key
|
||||||
|
B68W_API_EMAIL=
|
||||||
|
B68W_API_KEY=
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
export const show = ({ params }, res, next) => {
|
import axios from "axios";
|
||||||
res.status(200).json({});
|
const { v2 } = require("osu-api-extended");
|
||||||
|
|
||||||
|
v2.login(process.env.OSU_API_CLIENT_ID, process.env.OSU_API_CLIENT_SECRET);
|
||||||
|
|
||||||
|
export const show = (req, res, next) => {
|
||||||
|
var config = {
|
||||||
|
method: "get",
|
||||||
|
url: `http://bravo68web-api.herokuapp.com/api/private/spotify/track/${req.params.trackID}`,
|
||||||
|
headers: {
|
||||||
|
apikey: process.env.B68W_API_KEY,
|
||||||
|
email: process.env.B68W_API_EMAIL,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
axios(config)
|
||||||
|
.then(async function (response) {
|
||||||
|
const data = await v2.beatmaps.search({ query: response.data.name.name });
|
||||||
|
res.json(data);
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
res.status(500).json({ error: err.message });
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Router } from 'express'
|
import { Router } from "express";
|
||||||
import { show } from './controller'
|
import { show } from "./controller";
|
||||||
|
|
||||||
const router = new Router()
|
const router = new Router();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /spot/:id Retrieve spotify
|
* @api {get} /spot/:id Retrieve spotify
|
||||||
|
@ -11,7 +11,6 @@ const router = new Router()
|
||||||
* @apiError {Object} 400 Some parameters may contain invalid values.
|
* @apiError {Object} 400 Some parameters may contain invalid values.
|
||||||
* @apiError 404 Spotify not found.
|
* @apiError 404 Spotify not found.
|
||||||
*/
|
*/
|
||||||
router.get('/:id',
|
router.get("/:trackID", show);
|
||||||
show)
|
|
||||||
|
|
||||||
export default router
|
export default router;
|
||||||
|
|
|
@ -26,7 +26,6 @@ export const show = ({ params }, res, next) => {
|
||||||
title = videoTitle.substring(0, bracketIndex);
|
title = videoTitle.substring(0, bracketIndex);
|
||||||
}
|
}
|
||||||
const data = await v2.beatmaps.search({ query: title });
|
const data = await v2.beatmaps.search({ query: title });
|
||||||
console.log(title);
|
|
||||||
res.json(data);
|
res.json(data);
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
|
|
Loading…
Reference in New Issue