Skip to content

Commit

Permalink
Merge pull request #36 from Oceanity/feature/more-vars-on-track
Browse files Browse the repository at this point in the history
New vars:

    spotifyIsPlaylistActive: bool
    spotifyPlaylistCoverImageUrl: string
    spotifyPlaylistDescription: string
    spotifyPlaylistLength: integer
    spotifyPlaylistUrl: string
    spotifyTrackUri: string
    spotifyTrackId: string

New events:

    Playlist Changed

Various structural changes and fixes
  • Loading branch information
Oceanity committed Jun 7, 2024
2 parents 5cc43a1 + 5da0c58 commit 84625a5
Show file tree
Hide file tree
Showing 38 changed files with 452 additions and 98 deletions.
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,33 @@ This script adds the following features to Firebot
**Any Spotify Account**

- Replace Variables
- spotifyIsPlaying: `bool`
- spotifyTrackAlbum: `string`
- spotifyTrackAlbumArtUrl: `string`
- spotifyTrackArtist: `string`
- spotifyTrackArtists: `string[]`
- spotifyTrackDuration: `string`
- spotifyTrackDurationMs: `number`
- spotifyTrackPosition: `string`
- spotifyTrackPositionMs: `number`
- spotifyTrackRelativePosition: `float`
- spotifyTrackTitle: `string`
- spotifyTrackUrl: `string`
- Player
- spotifyIsPlaying: `bool`
- spotifyPlayerRelativeVolume: `float`
- spotifyPlayerVolume: `integer`
- Playlist
- spotifyIsPlaylistActive: `bool`
- spotifyCoverImageUrl: `string`
- spotifyPlaylistDescription: `string`
- spotifyPlaylistLength: `integer`
- spotifyPlaylistUrl: `string`
- Track
- spotifyTrackAlbum: `string`
- spotifyTrackAlbumArtUrl: `string`
- spotifyTrackArtist: `string`
- spotifyTrackArtists: `string[]`
- spotifyTrackDuration: `string`
- spotifyTrackDurationMs: `integer`
- spotifyTrackId: `string`
- spotifyTrackPosition: `string`
- spotifyTrackPositionMs: `integer`
- spotifyTrackRelativePosition: `float`
- spotifyTrackTitle: `string`
- spotifyTrackUri: `string`
- spotifyTrackUrl: `string`
- Events
- Spotify Tick
- Playback State Changed
- Playlist Changed
- Tick
- Track Changed
- Volume Changed
35 changes: 33 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebot-song-requests",
"scriptOutputName": "oceanitySpotifyIntegration",
"version": "0.6.4",
"version": "0.6.5",
"description": "Adds Spotify Song Requests to Firebot",
"main": "",
"scripts": {
Expand All @@ -16,6 +16,7 @@
"@crowbartools/firebot-custom-scripts-types": "^5.60.1",
"@types/express": "^4.17.21",
"@types/fs-extra": "^11.0.4",
"@types/he": "^1.2.3",
"@types/jest": "^29.5.12",
"@types/node": "^18.18.2",
"@types/webpack": "^5.28.5",
Expand All @@ -26,6 +27,7 @@
"eslint-config-prettier": "^9.1.0",
"fs-extra": "^11.2.0",
"fuse.js": "^7.0.0",
"he": "^1.2.0",
"jest": "^29.7.0",
"node-json-db": "^2.3.0",
"terser-webpack-plugin": "^5.3.10",
Expand Down
39 changes: 25 additions & 14 deletions src/firebot/events/spotifyEventSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,56 @@ export const SpotifyEventSource = {
description: "Events related to Oceanity's Spotify integration",
events: [
{
id: "tick",
name: "Spotify Tick",
description:
"Fired around once per second after current playback state has been updated",
id: "playback-state-changed",
name: "Spotify Playback State Changed",
description: "Spotify playback state changed",
cached: false,
activityFeed: {
icon: "fab fa-spotify",
getMessage: () => "Spotify tick",
getMessage: () => "Spotify playback state changed",
},
},
{
id: "playback-state-changed",
name: "Playback State Changed",
description: "Spotify playback state changed",
id: "playlist-changed",
name: "Spotify Playlist Changed",
description: "Currently active Spotify Playlist has changed",
cached: false,
activityFeed: {
icon: "fab fa-spotify",
getMessage: () => "Spotify playback state changed",
getMessage: () => "Spotify playlist changed",
},
},
{
id: "volume-changed",
name: "Volume Changed",
description: "Spotify volume changed",
id: "tick",
name: "Spotify Tick",
description:
"Fired around once per second after current playback state has been updated",
cached: false,
activityFeed: {
icon: "fab fa-spotify",
getMessage: () => "Spotify volume changed",
getMessage: () => "Spotify tick",
},
},
{
id: "track-changed",
name: "Track Changed",
name: "Spotify Track Changed",
description: "Currently playing Spotify track changed",
cached: false,
activityFeed: {
icon: "fab fa-spotify",
getMessage: () => "Spotify track changed",
},
},
{
id: "volume-changed",
name: "Spotify Volume Changed",
description:
"Spotify volume changed, fires faster if volume is changed via Firebot",
cached: false,
activityFeed: {
icon: "fab fa-spotify",
getMessage: () => "Spotify volume changed",
},
},
],
};
34 changes: 6 additions & 28 deletions src/firebot/variables/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
import { SpotifyIsPlayingVariable } from "./spotifyIsPlaying";
import { SpotifyPlayerVolumeVariable } from "./spotifyPlayerVolume";
import { SpotifyPlayerRelativeVolumeVariable } from "./spotifyPlayerRelativeVolume";
import { SpotifyTrackArtistVariable } from "./spotifyTrackArtist";
import { SpotifyTrackArtistsVariable } from "./spotifyTrackArtists";
import { SpotifyTrackAlbumVariable } from "./spotifyTrackAlbum";
import { SpotifyTrackAlbumArtUrlVariable } from "./spotifyTrackAlbumArtUrl";
import { SpotifyTrackTitleVariable } from "./spotifyTrackTitle";
import { SpotifyTrackUriVariable } from "./spotifyTrackUri";
import { SpotifyTrackDurationVariable } from "./spotifyTrackDuration";
import { SpotifyTrackDurationMsVariable } from "./spotifyTrackDurationMs";
import { SpotifyTrackPositionVariable } from "./spotifyTrackPosition";
import { SpotifyTrackPositionMsVariable } from "./spotifyTrackPositionMs";
import { SpotifyTrackRelativePositionVariable } from "./spotifyTrackRelativePosition";
import { AllSpotifyPlayerVariables } from "./player";
import { AllSpotifyPlaylistVariables } from "./playlist";
import { AllSpotifyTrackVariables } from "./track";

export const AllSpotifyReplaceVariables = [
SpotifyIsPlayingVariable,
SpotifyPlayerVolumeVariable,
SpotifyPlayerRelativeVolumeVariable,
SpotifyTrackArtistVariable,
SpotifyTrackArtistsVariable,
SpotifyTrackAlbumVariable,
SpotifyTrackAlbumArtUrlVariable,
SpotifyTrackTitleVariable,
SpotifyTrackUriVariable,
SpotifyTrackDurationVariable,
SpotifyTrackDurationMsVariable,
SpotifyTrackPositionVariable,
SpotifyTrackPositionMsVariable,
SpotifyTrackRelativePositionVariable,
...AllSpotifyPlayerVariables,
...AllSpotifyPlaylistVariables,
...AllSpotifyTrackVariables,
];
9 changes: 9 additions & 0 deletions src/firebot/variables/player/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { SpotifyIsPlayingVariable } from "./spotifyIsPlaying";
import { SpotifyPlayerVolumeVariable } from "./spotifyPlayerVolume";
import { SpotifyPlayerRelativeVolumeVariable } from "./spotifyPlayerRelativeVolume";

export const AllSpotifyPlayerVariables = [
SpotifyIsPlayingVariable,
SpotifyPlayerVolumeVariable,
SpotifyPlayerRelativeVolumeVariable,
];
File renamed without changes.
13 changes: 13 additions & 0 deletions src/firebot/variables/player/spotifyPlayerRelativeVolume.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { spotify } from "@/main";
import { ReplaceVariable } from "@crowbartools/firebot-custom-scripts-types/types/modules/replace-variable-manager";

export const SpotifyPlayerRelativeVolumeVariable: ReplaceVariable = {
definition: {
handle: "spotifyPlayerRelativeVolume",
description:
"Gets the relative volume of the active Spotify Device as a value from 0.0 to 1.0",
usage: "spotifyPlayerRelativeVolume",
possibleDataOutput: ["number"],
},
evaluator: async () => spotify.player.volume / 100,
};
12 changes: 12 additions & 0 deletions src/firebot/variables/player/spotifyPlayerVolume.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { spotify } from "@/main";
import { ReplaceVariable } from "@crowbartools/firebot-custom-scripts-types/types/modules/replace-variable-manager";

export const SpotifyPlayerVolumeVariable: ReplaceVariable = {
definition: {
handle: "spotifyPlayerVolume",
description: "Gets the volume of the active Spotify device",
usage: "spotifyPlayerVolume",
possibleDataOutput: ["number"],
},
evaluator: async () => spotify.player.volume,
};
15 changes: 15 additions & 0 deletions src/firebot/variables/playlist/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SpotifyIsPlaylistActiveVariable } from "./spotifyIsPlaylistActive";
import { SpotifyPlaylistDescriptionVariable } from "./spotifyPlaylistDescription";
import { SpotifyPlaylistUrlVariable } from "./spotifyPlaylistUrl";
import { SpotifyPlaylistNameVariable } from "./spotifyPlaylistName";
import { SpotifyPlaylistCoverImageUrlVariable } from "./spotifyPlaylistCoverImageUrl";
import { SpotifyPlaylistLengthVariable } from "./spotifyPlaylistLength";

export const AllSpotifyPlaylistVariables = [
SpotifyIsPlaylistActiveVariable,
SpotifyPlaylistDescriptionVariable,
SpotifyPlaylistUrlVariable,
SpotifyPlaylistNameVariable,
SpotifyPlaylistCoverImageUrlVariable,
SpotifyPlaylistLengthVariable,
];
12 changes: 12 additions & 0 deletions src/firebot/variables/playlist/spotifyIsPlaylistActive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { spotify } from "@/main";
import { ReplaceVariable } from "@crowbartools/firebot-custom-scripts-types/types/modules/replace-variable-manager";

export const SpotifyIsPlaylistActiveVariable: ReplaceVariable = {
definition: {
handle: "spotifyIsPlaylistActive",
description: "Will be `true` if Spotify has playlist open, `false` if not",
usage: "spotifyIsPlaylistActive",
possibleDataOutput: ["number"],
},
evaluator: async () => spotify.player.playlist.isPlaylistActive,
};
13 changes: 13 additions & 0 deletions src/firebot/variables/playlist/spotifyPlaylistCoverImageUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { spotify } from "@/main";
import { ReplaceVariable } from "@crowbartools/firebot-custom-scripts-types/types/modules/replace-variable-manager";

export const SpotifyPlaylistCoverImageUrlVariable: ReplaceVariable = {
definition: {
handle: "spotifyPlaylistCoverImageUrl",
description:
"Gets the Cover Image Url of the currently playing Spotify Playlist",
usage: "spotifyPlaylistCoverImageUrl",
possibleDataOutput: ["number"],
},
evaluator: async () => spotify.player.playlist.coverImageUrl,
};
13 changes: 13 additions & 0 deletions src/firebot/variables/playlist/spotifyPlaylistDescription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { spotify } from "@/main";
import { ReplaceVariable } from "@crowbartools/firebot-custom-scripts-types/types/modules/replace-variable-manager";

export const SpotifyPlaylistDescriptionVariable: ReplaceVariable = {
definition: {
handle: "spotifyPlaylistDescription",
description:
"Gets the Description of the currently playing Spotify Playlist",
usage: "spotifyPlaylistDescription",
possibleDataOutput: ["number"],
},
evaluator: async () => spotify.player.playlist.description,
};
12 changes: 12 additions & 0 deletions src/firebot/variables/playlist/spotifyPlaylistLength.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { spotify } from "@/main";
import { ReplaceVariable } from "@crowbartools/firebot-custom-scripts-types/types/modules/replace-variable-manager";

export const SpotifyPlaylistLengthVariable: ReplaceVariable = {
definition: {
handle: "spotifyPlaylistLength",
description: "Gets the Length of the currently playing Spotify Playlist",
usage: "spotifyPlaylistLength",
possibleDataOutput: ["number"],
},
evaluator: async () => spotify.player.playlist.length,
};
12 changes: 12 additions & 0 deletions src/firebot/variables/playlist/spotifyPlaylistName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { spotify } from "@/main";
import { ReplaceVariable } from "@crowbartools/firebot-custom-scripts-types/types/modules/replace-variable-manager";

export const SpotifyPlaylistNameVariable: ReplaceVariable = {
definition: {
handle: "spotifyPlaylistName",
description: "Gets the Name of the currently playing Spotify Playlist",
usage: "spotifyPlaylistName",
possibleDataOutput: ["number"],
},
evaluator: async () => spotify.player.playlist.name,
};
12 changes: 12 additions & 0 deletions src/firebot/variables/playlist/spotifyPlaylistUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { spotify } from "@/main";
import { ReplaceVariable } from "@crowbartools/firebot-custom-scripts-types/types/modules/replace-variable-manager";

export const SpotifyPlaylistUrlVariable: ReplaceVariable = {
definition: {
handle: "spotifyPlaylistUrl",
description: "Gets the Url of the currently playing Spotify Playlist",
usage: "spotifyPlaylistUrl",
possibleDataOutput: ["number"],
},
evaluator: async () => spotify.player.playlist.url,
};
Loading

0 comments on commit 84625a5

Please sign in to comment.