it mostly works!
This commit is contained in:
parent
76543fd220
commit
44cd13f10c
52 changed files with 879 additions and 396 deletions
|
@ -1,20 +1,26 @@
|
|||
import { appleMusicApi } from "../../../api/index.js";
|
||||
import { appleMusicApi } from "../../../appleMusicApi/index.js";
|
||||
import express from "express";
|
||||
import { validate } from "../../validate.js";
|
||||
import { z } from "zod";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const schema = z.object({
|
||||
query: z.object({
|
||||
id: z.string()
|
||||
})
|
||||
});
|
||||
|
||||
// this endpoint isn't actually used for anything by us
|
||||
// it's for people who want to implement apple music downloading into their own apps
|
||||
// it's for people who want to implement apple music downloading into their own apps (ex. discord music bot)
|
||||
// it makes it a bit easier to get the metadata for a track knowing the trackId
|
||||
router.get("/getTrackMetadata", async (req, res, next) => {
|
||||
try {
|
||||
const { trackId } = req.query;
|
||||
if (typeof trackId !== "string") { res.status(400).send("trackId is required and must be a string!"); return; }
|
||||
const { id } = (await validate(req, schema)).query;
|
||||
|
||||
const trackMetadata = await appleMusicApi.getSong(trackId);
|
||||
const trackAttributes = trackMetadata.data[0].attributes;
|
||||
const trackMetadata = await appleMusicApi.getSong(id);
|
||||
|
||||
res.json(trackAttributes);
|
||||
res.json(trackMetadata);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue