Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions samples/spotify-current-song/extension/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NodeCG } from "nodecg/types/server";
import { requireService } from "nodecg-io-core/extension/serviceClientWrapper";
import { SpotifyServiceClient } from "nodecg-io-spotify";

module.exports = function (nodecg: NodeCG) {
nodecg.log.info("Sample bundle for spotify started");

const service = requireService<SpotifyServiceClient>(nodecg, "spotify");
service?.onAvailable(async (client) => {
nodecg.log.info("Client has been updated.");

const track = await client.getNativeClient().getMyCurrentPlayingTrack();
const name = track.body.item?.name;
const artists = track.body.item?.artists.map((a) => a.name);
nodecg.log.info(`Currently playing "${name}" by "${artists}".`);
});

service?.onUnavailable(() => nodecg.log.info("Client has been unset."));
};
24 changes: 24 additions & 0 deletions samples/spotify-current-song/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "spotify-current-song",
"private": true,
"version": "0.1.0",
"nodecg": {
"compatibleRange": "^1.1.1",
"bundleDependencies": {
"nodecg-io-spotify": "^0.1.0"
}
},
"scripts": {
"build": "tsc -b",
"watch": "tsc -b -w",
"clean": "tsc -b --clean"
},
"license": "MIT",
"dependencies": {
"nodecg-io-spotify": "^0.1.0",
"nodecg-io-core": "^0.1.0",
"@types/node": "^14.14.13",
"nodecg": "^1.7.4",
"typescript": "^4.1.3"
}
}
3 changes: 3 additions & 0 deletions samples/spotify-current-song/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.common.json"
}