Skip to content
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
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ changelogs/
package.json

# Ignore TamperMonkey script
src/tamperMonkey
src/tamperMonkey

# Ignore dist
dist/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Spotify Integration by Oceanity <sub style="color:gray">v0.7.7</sub>
# Spotify Integration by Oceanity <sub style="color:gray">0.7.8</sub>

This is a Firebot Script that will allow you to integrate Spotify functionality and information into your Firebot setup. Due to very stict limits on Spotify's API, it does require that you make your own application in Spotify's developer portal and supply your own Client ID and Secret.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "oceanity-spotify",
"displayName": "Spotify (by Oceanity)",
"scriptOutputName": "oceanitySpotifyIntegration",
"version": "0.7.7",
"version": "0.7.8",
"description": "Adds Spotify events, effects and variables to Firebot",
"main": "",
"scripts": {
Expand Down
123 changes: 123 additions & 0 deletions src/md/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Spotify Integration by Oceanity <sub style="color:gray">$PROJECT_VERSION</sub>

This is a Firebot Script that will allow you to integrate Spotify functionality and information into your Firebot setup. Due to very stict limits on Spotify's API, it does require that you make your own application in Spotify's developer portal and supply your own Client ID and Secret.

1. [Setup](#Setup)
2. [Features](#Features)

<div id="Setup" />

### Setup

- Log in to your Spotify Account on https://developer.spotify.com/ and click "Create app"
- App name and description can be whatever you want
- Website is optional, also doesn't matter what you use here
- Callback Url must be `http://localhost:7472/api/v1/auth/callback`
- Change `localhost` to your specified Callback Hostname if you changed that in the script settings
- API/SDKs to use are Web API and Web Playback API
- Click checkbox to agree with Spotify's TOS and Design Guidelines
- Take note of the Client ID and Client Secret, these are required to use this script
- In Firebot, go to Settings > Scripts
- Enable Custom Scripts if they are not currently enabled
- Click Manage Startup Scripts
- Click Add New Script
- Click the "scripts folder" link to open the Scripts Folder and place `oceanitySpotifyIntegration.js` there
- Refresh the list of scripts and pick `oceanitySpotifyIntegration.js` from the dropdown
- In Client Id and Client Secret fields, copy in the two codes from earlier
- Go to Settings > Integrations and click Link next to Spotify (by Oceanity)
- Log in and authorize on the page that pops up
- You should now have the ability to use this script's Effects, Events and Replace Variables in Firebot

### Updating

- Overwrite existing `oceanitySpotifyIntegration.js` with new version
- Restart Firebot

### Lyrics Setup

- Install Tampermonkey from https://www.tampermonkey.net/
- Google Chrome and other Chromium browsers may need to follow instructions here https://www.tampermonkey.net/faq.php#Q209 for this script to work
- Click the lyricsGrabber.user.js file included with the latest Release
- Tampermonkey should prompt you to install the script, click Install
- Visit https://open.spotify.com/lyrics and you should see a modal on the site for the plugin
- As long as the lyrics pane is open, any songs with Lyrics will now forward those to Firebot (they will not render in the browser, this is normal)

<div id="Features" />

### Features

This script adds the following features to Firebot

**Spotify Premium Required**

- Effects
- Change Playback State
- Change Repeat Mode
- Change Volume
- Find and Enqueue Track
- Seek to Position
- Skip Track

**Any Spotify Account**

- Replace Variables
- Lyrics
- spotifyLyricsCurrentLine: `string`
- spotifyTrackHasLyrics: `bool`
- Player
- spotifyIsPlaying: `bool`
- spotifyPlayerRelativeVolume: `float`
- spotifyPlayerVolume: `integer`
- Playlist
- rawSpotifyPlaylist: `object`
- See [Response Sample](https://developer.spotify.com/documentation/web-api/reference/get-playlist) for details
- spotifyIsPlaylistActive: `bool`
- spotifyPlaylist: `object`
- spotifyPlaylist[id]: `string`
- spotifyPlaylist[name]: `string`
- spotifyPlaylist[description]: `string`
- spotifyPlaylist[length]: `integer`
- spotifyPlaylist[coverImageUrl]: `string`
- spotifyPlaylist[owner]: `string`
- spotifyPlaylist[ownerUrl]: `string`
- ## spotifyPlaylist[tracks]: `array`
- spotifyPlaylist[url]: `string`
- spotifyPlaylist[uri]: `string`
- Track
- rawSpotifyTrack: `object`
- See [Response Sample](https://developer.spotify.com/documentation/web-api/reference/get-track) for details
- spotifyTrack: `object`
- spotifyTrack[id]: `string`
- spotifyTrack[title]: `string`
- spotifyTrack[artist]: `string`
- spotifyTrack[artists]: `string[]`
- spotifyTrack[album]: `string`
- spotifyTrack[albumArtUrl]: `string`
- spotifyTrack[duration]: `string`
- spotifyTrack[durationMs]: `integer`
- spotifyTrack[position]: `string`
- spotifyTrack[positionMs]: `integer`
- spotifyTrack[relativePosition]: `float`
- spotifyTrack[url]: `string`
- spotifyTrack[uri]: `string`
- Queue
- rawSpotifyQueue: `object`
- See [Response Sample](https://developer.spotify.com/documentation/web-api/reference/get-queue) for details
- spotifyQueue: `object`
- spotifyQueue[0..20]: `object` (same structure as spotifyTrack var)
- spotifyQueue[0.title]: `string`
- spotifyQueue[0.artist]: `string`
- etc.
- spotifyUserQueues: `object`
- spotifyQueue[0..inf]: `object`
- spotifyQueue[0.queuedBy]: `string`
- spotifyQueue[0.position]: `number`
- spotifyQueue[0.track]: `object` (same structure as spotifyTrack var)
- Events
- Lyrics Changed
- Playback State Changed
- Playlist Changed
- Tick
- Track Changed
- Track Auto-Skipped
- Volume Changed
4 changes: 2 additions & 2 deletions src/tamperMonkey/lyricsGrabber.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Lyric Grabber
// @namespace https://oceanity.github.io
// @version 0.7.7
// @version $PROJECT_VERSION
// @description Sends Spotify lyrics to Firebot
// @author Oceanity
// @match https://open.spotify.com/*
Expand All @@ -16,7 +16,7 @@
fetch: originalFetch
} = window;

const version = "0.7.6";
const version = "$PROJECT_VERSION";

// Consts
const lyricUrlRegex = /https:\/\/spclient\.wg\.spotify\.com\/color-lyrics\/v2\/track\/([a-zA-Z0-9]+)\/image\/.+/;
Expand Down
58 changes: 0 additions & 58 deletions webpack.config.js

This file was deleted.

79 changes: 79 additions & 0 deletions webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import * as CopyWebpackPlugin from "copy-webpack-plugin";
import * as path from "path";
import * as TerserPlugin from "terser-webpack-plugin";
import * as packageJson from "./package.json";

module.exports = {
target: "node",
mode: "production",
devtool: false,
entry: {
main: "@/main.ts",
},
output: {
libraryTarget: "commonjs2",
libraryExport: "default",
path: path.resolve(__dirname, "./dist"),
filename: `${packageJson.scriptOutputName}.js`,
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(
__dirname,
"src/tamperMonkey/lyricsGrabber.user.js"
),
to: path.resolve(__dirname, "dist/lyricsGrabber.user.js"),
transform(content) {
return content
.toString()
.replace(/\$PROJECT_VERSION/g, packageJson.version);
},
},
{
from: path.resolve(__dirname, "src/md/README.md"),
to: path.resolve(__dirname, "README.md"),
transform(content) {
return content
.toString()
.replace(/\$PROJECT_VERSION/g, packageJson.version);
},
},
],
}),
],
resolve: {
extensions: [".ts", ".js"],
alias: {
"@": path.resolve(__dirname, "./src"),
"@models": path.resolve(__dirname, "./src/models"),
"@utils": path.resolve(__dirname, "./src/utils"),
"@shared": path.resolve(__dirname, "./src/shared"),
},
},
module: {
rules: [
{
test: /\.ts$/,
loader: "ts-loader",
},
],
},
optimization: {
minimize: false,

minimizer: [
new TerserPlugin({
terserOptions: {
keep_fnames: /main/,
mangle: false,
format: {
comments: false,
},
},
extractComments: false,
}),
],
},
};