Compare commits
10 Commits
b91197f70d
...
37c0e14f7b
| Author | SHA1 | Date | |
|---|---|---|---|
| 37c0e14f7b | |||
| 486bf7cce7 | |||
| 2d2d3404c1 | |||
| a5f5637322 | |||
| 0f195a0ac7 | |||
| 88cc7073cc | |||
| 20026ecca7 | |||
| 601f71d2fd | |||
| c97ffb878e | |||
| 7228d92fbc |
@ -1,5 +1,6 @@
|
||||
FROM node:23.6-bullseye-slim
|
||||
VOLUME /opt/prod/storage
|
||||
|
||||
RUN apt-get update && apt-get install curl -y
|
||||
|
||||
WORKDIR /opt/prod/app
|
||||
COPY . .
|
||||
15
dist/start.js
vendored
15
dist/start.js
vendored
@ -4,8 +4,6 @@ const cors = require("cors");
|
||||
const https = require("https");
|
||||
const fs = require("fs/promises");
|
||||
|
||||
fs.writeFile("/opt/prod/stoage/test.txt", "text");
|
||||
|
||||
const agent = new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
@ -36,9 +34,11 @@ const apiCache = {
|
||||
};
|
||||
|
||||
app.get("/getMostRecentSpotifyTrack", async function (req, res) {
|
||||
console.log(apiCache.get("getMostRecentSpotifyTrack"));
|
||||
if (apiCache.get("getMostRecentSpotifyTrack")) {
|
||||
res.send(JSON.stringify(apiCache.get("getMostRecentSpotifyTrack")));
|
||||
} else {
|
||||
console.log("new")
|
||||
const lastfmResponse = await fetch(
|
||||
`http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=jdf221&api_key=${process.env.LASTFM_API_KEY}&format=json`
|
||||
).then((res) => res.json());
|
||||
@ -51,13 +51,14 @@ app.get("/getMostRecentSpotifyTrack", async function (req, res) {
|
||||
const track = lastfmResponse?.["recenttracks"]?.["track"]?.[0];
|
||||
response.track = track?.name;
|
||||
response.artist = track?.artist?.["#text"];
|
||||
console.log(response)
|
||||
|
||||
apiCache.set("getMostRecentSpotifyTrack", response);
|
||||
res.send(JSON.stringify(response));
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(3000);`2`
|
||||
app.listen(3000);
|
||||
|
||||
async function getSpotifyApi() {
|
||||
return {
|
||||
@ -239,8 +240,12 @@ async function weeklySpotifyHandler() {
|
||||
)
|
||||
) {
|
||||
createdPlaylists[currentPlaylistInternalId].tracks.push(track.uri);
|
||||
console.log(`Adding ${lastfmTrack.name}} to ${currentPlaylistInternalId}`)
|
||||
newTracksToAdd.push(track.uri);
|
||||
}
|
||||
else {
|
||||
console.log(`Skipping ${lastfmTrack.name}}, already added to ${currentPlaylistInternalId}`)
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -263,6 +268,4 @@ setInterval(() => {
|
||||
) {
|
||||
weeklySpotifyHandler();
|
||||
}
|
||||
}, 1000 * 60 * 30); // Every 30 minutes
|
||||
|
||||
weeklySpotifyHandler();
|
||||
}, 1000 * 60 * 30); // Every 30 minutes
|
||||
Loading…
x
Reference in New Issue
Block a user