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