Compare commits
No commits in common. "37c0e14f7be49c61217bd02cdd604b424b2144e9" and "b91197f70d0e3218d45f428fa7a9472b9cf8159f" have entirely different histories.
37c0e14f7b
...
b91197f70d
@ -1,6 +1,5 @@
|
||||
FROM node:23.6-bullseye-slim
|
||||
|
||||
RUN apt-get update && apt-get install curl -y
|
||||
VOLUME /opt/prod/storage
|
||||
|
||||
WORKDIR /opt/prod/app
|
||||
COPY . .
|
||||
13
dist/start.js
vendored
13
dist/start.js
vendored
@ -4,6 +4,8 @@ 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,
|
||||
});
|
||||
@ -34,11 +36,9 @@ 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,14 +51,13 @@ 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);
|
||||
app.listen(3000);`2`
|
||||
|
||||
async function getSpotifyApi() {
|
||||
return {
|
||||
@ -240,12 +239,8 @@ 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;
|
||||
}
|
||||
}
|
||||
@ -269,3 +264,5 @@ setInterval(() => {
|
||||
weeklySpotifyHandler();
|
||||
}
|
||||
}, 1000 * 60 * 30); // Every 30 minutes
|
||||
|
||||
weeklySpotifyHandler();
|
||||
Loading…
x
Reference in New Issue
Block a user