refactor: move track resolving to player

This commit is contained in:
Mateusz Pstrucha committed 2021-10-21 01:29:54 +02:00
1 parent 8c2034ce5b
commit 4dba724336
3 files changed
+1 -104

No files matched your search

-93
View File
@@ -4,15 +4,6 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@ksolo/spotify-search": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@ksolo/spotify-search/-/spotify-search-1.0.0.tgz",
"integrity": "sha512-8Ud6chwN3FRqDgup7Fo2iHFcYzedp63cxvIrrqnt8PU74TzvKe4gKFwBv5O3H/skWONtrk3sz3X2HPO1Tg0s3Q==",
"requires": {
"axios": "^0.21.1",
"buffer": "^6.0.3"
}
},
"@sindresorhus/is": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.2.0.tgz",
@@ -146,24 +137,11 @@
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"axios": {
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"requires": {
"follow-redirects": "^1.14.0"
}
},
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
},
"binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
@@ -257,15 +235,6 @@
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz",
"integrity": "sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg=="
},
"buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"requires": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
@@ -452,14 +421,6 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
"cross-fetch": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
"requires": {
"node-fetch": "2.6.1"
}
},
"crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@@ -681,11 +642,6 @@
}
}
},
"follow-redirects": {
"version": "1.14.4",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz",
"integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g=="
},
"form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
@@ -802,11 +758,6 @@
"resolved": "https://registry.npmjs.org/has-yarn/-/has-yarn-2.1.0.tgz",
"integrity": "sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw=="
},
"himalaya": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/himalaya/-/himalaya-1.1.0.tgz",
"integrity": "sha512-LLase1dHCRMel68/HZTFft0N0wti0epHr3nNY7ynpLbyZpmrKMQ8YIpiOV77TM97cNpC8Wb2n6f66IRggwdWPw=="
},
"http-cache-semantics": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
@@ -848,11 +799,6 @@
"safer-buffer": ">= 2.1.2 < 3"
}
},
"ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
},
"ignore-by-default": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
@@ -1231,11 +1177,6 @@
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"nodemon": {
"version": "2.0.13",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.13.tgz",
@@ -1766,32 +1707,6 @@
"memory-pager": "^1.0.2"
}
},
"spotify-to-yt": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/spotify-to-yt/-/spotify-to-yt-1.0.5.tgz",
"integrity": "sha512-tjudSnTkTDR8eAqylVbo35BFp+ogYpFEkZxsjh59NXw7UvAJ87sZG5b0WroFjJ0XeAriMTj1A7ZDO2VABjRrwg==",
"requires": {
"@ksolo/spotify-search": "^1.0.0",
"spotify-uri": "^2.2.0",
"spotify-url-info": "^2.2.3",
"youtube-sr": "^4.1.5"
}
},
"spotify-uri": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/spotify-uri/-/spotify-uri-2.2.0.tgz",
"integrity": "sha512-uUybj02bfyfCoZ0MJ80MkqbKxtIVRJfbRGk05KJFq1li3zb7yNfN1f+TAw4wcXgp7jLWExeiw2wyPQXZ8PHtfg=="
},
"spotify-url-info": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/spotify-url-info/-/spotify-url-info-2.2.3.tgz",
"integrity": "sha512-cZTE5nOnaAjIiaHG9psVYqKXWOlNUIgSU2e+bNInRaYZNgmVgOcKH0D7V1nSER3gv3h5BXvOo0EJTtrMQQo1bA==",
"requires": {
"cross-fetch": "~3.1.4",
"himalaya": "~1.1.0",
"spotify-uri": "~2.2.0"
}
},
"spotify-web-api-node": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/spotify-web-api-node/-/spotify-web-api-node-5.0.2.tgz",
@@ -2113,14 +2028,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
},
"youtube-sr": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/youtube-sr/-/youtube-sr-4.1.7.tgz",
"integrity": "sha512-OKbm+561Fq5RlnUtJBmPhnyfS6Zon44zdPhY1v/Y9vpAHzqdfxomD43yc0ZQv6zNsVzSlAkGeWhoweNd6DUUjQ==",
"requires": {
"node-fetch": "^2.6.1"
}
}
}
}
-1
View File
@@ -34,7 +34,6 @@
"mongoose": "^5.13.9",
"nodemon": "^2.0.13",
"redis": "^3.1.2",
"spotify-to-yt": "^1.0.5",
"spotify-web-api-node": "^5.0.2",
"ws": "^8.2.2"
}
+1 -10
View File
@@ -1,9 +1,7 @@
import dotenv from 'dotenv'
import express from 'express'
import spotifyToYt from 'spotify-to-yt'
import db from '../db.js'
import Track from '../Track.js'
dotenv.config()
@@ -91,14 +89,7 @@ router.get('/get/top/', ({ headers: { authorization } }, res) => {
if (authorization != playerSecret) return res.status(403).end('Token invalid')
db.top.get().then(({ top }) => {
Promise.all(
top.map((tid) => spotifyToYt.trackGet(`spotify:track:${tid}`))
).then((yts) => {
top.map((tid, i) => {
yts[i].tid = tid
})
res.json(yts)
})
res.json(top)
})
})