Skip to content

Commit

Permalink
feat: Implement Musikcube source
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Jun 6, 2024
1 parent 3e7e5df commit 5d35b04
Show file tree
Hide file tree
Showing 16 changed files with 869 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ A javascript app to scrobble music you listened to, to [Maloja](https://github.c
* [JRiver](/docsite/docs/configuration/configuration.md#jriver)
* [Kodi](/docsite/docs/configuration/configuration.md#kodi)
* [Google Cast (Chromecast)](/docsite/docs/configuration/configuration.md#google-cast--chromecast-)
* [Musikcube](/docsite/docs/configuration/configuration.md#muikcube)
* Supports scrobbling to many **Clients**
* [Maloja](/docsite/docs/configuration/configuration.md#maloja)
* [Last.fm](/docsite/docs/configuration/configuration.md#lastfm)
Expand Down
10 changes: 10 additions & 0 deletions config/musikcube.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"type": "musikcube",
"enable": true,
"name": "musikcube",
"data": {
"password": "MY_PASSWORD"
}
}
]
32 changes: 32 additions & 0 deletions docsite/docs/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,38 @@ Note: [Manually configuring cast device connections](#connecting-devices) is onl

See [`chromecast.json.example`](https://github.com/FoxxMD/multi-scrobbler/blob/master/config/chromecast.json.example) or [explore the schema with an example and live editor/validator](https://json-schema.app/view/%23%2Fdefinitions%2FChromecastSourceConfig/%23%2Fdefinitions%2FChromecastData?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fmulti-scrobbler%2Fmaster%2Fsrc%2Fbackend%2Fcommon%2Fschema%2Fsource.json)

## [Musikcube](https://musikcube.com)

In order to use Musikcube configure it to accept [websocket connections](https://github.com/clangen/musikcube/wiki/remote-api-documentation) in **server setup**:

* Enable the **Metadata Server**
* Set a **Password**

Both of these settings are found in _Musikcube -> (s)ettings -> server setup_

![Server Setup](musikcube.jpg)

The URL used by MS has the syntax:

```
[ws|wss]://HOST:[PORT]
```

The **port** is the same as shown in the server setup screenshot from above, under **metadata server enabled**. If no port is provided to MS it will default to `7905`.

If no URL is provided to MS it will try to use `ws://localhost:7905`

### ENV-Based

| Environmental Variable | Required? | Default | Description |
|------------------------|-----------|-----------------------|--------------------------------------|
| `MC_URL` | No | `ws://localhost:7905` | Use port set for **metadata server** |
| `MC_PASSWORD` | Yes | | |

### File-Based

See [`musikcube.json.example`](https://github.com/FoxxMD/multi-scrobbler/blob/master/config/chromecast.json.example) or [explore the schema with an example and live editor/validator](https://json-schema.app/view/%23%2Fdefinitions%2FMuikcubeSourceConfig/%23%2Fdefinitions%2FMuikcubeData?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fmulti-scrobbler%2Fmaster%2Fsrc%2Fbackend%2Fcommon%2Fschema%2Fsource.json)

# Client Configurations

## [Maloja](https://github.com/krateng/maloja)
Expand Down
Binary file added docsite/docs/configuration/musikcube.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docsite/src/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ A javascript app to scrobble music you listened to, to [Maloja](https://github.c
* [JRiver](docs/configuration#jriver)
* [Kodi](docs/configuration#kodi)
* [Google Cast (Chromecast)](/docs/configuration#google-cast--chromecast-)
* [Musikcube](docs/configuration#musikcube)
* Supports scrobbling to many **Clients**
* [Maloja](docs/configuration#maloja)
* [Last.fm](docs/configuration#lastfm)
Expand Down
123 changes: 110 additions & 13 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"fixed-size-list": "^0.3.0",
"formidable": "^2.1",
"gotify": "^1.1.0",
"iso-websocket": "^0.2.0",
"iti": "^0.6.0",
"json5": "^2.2.3",
"kodi-api": "^0.2.1",
Expand Down
4 changes: 2 additions & 2 deletions src/backend/common/infrastructure/Atomic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { FixedSizeList } from 'fixed-size-list';
import { PlayMeta, PlayObject } from "../../../core/Atomic.js";
import TupleMap from "../TupleMap.js";

export type SourceType = 'spotify' | 'plex' | 'tautulli' | 'subsonic' | 'jellyfin' | 'lastfm' | 'deezer' | 'ytmusic' | 'mpris' | 'mopidy' | 'listenbrainz' | 'jriver' | 'kodi' | 'webscrobbler' | 'chromecast';
export const sourceTypes: SourceType[] = ['spotify', 'plex', 'tautulli', 'subsonic', 'jellyfin', 'lastfm', 'deezer', 'ytmusic', 'mpris', 'mopidy', 'listenbrainz', 'jriver', 'kodi', 'webscrobbler', 'chromecast'];
export type SourceType = 'spotify' | 'plex' | 'tautulli' | 'subsonic' | 'jellyfin' | 'lastfm' | 'deezer' | 'ytmusic' | 'mpris' | 'mopidy' | 'listenbrainz' | 'jriver' | 'kodi' | 'webscrobbler' | 'chromecast' | 'musikcube';
export const sourceTypes: SourceType[] = ['spotify', 'plex', 'tautulli', 'subsonic', 'jellyfin', 'lastfm', 'deezer', 'ytmusic', 'mpris', 'mopidy', 'listenbrainz', 'jriver', 'kodi', 'webscrobbler', 'chromecast', 'musikcube'];

export const lowGranularitySources: SourceType[] = ['subsonic','ytmusic'];

Expand Down
116 changes: 116 additions & 0 deletions src/backend/common/infrastructure/config/source/musikcube.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { CommonSourceConfig, CommonSourceData } from "./index.js";

export const PLAYBACK_STATUS_PLAYING_MC = 'playing';
export const PLAYBACK_STATUS_PAUSED_MC = 'paused';
export const PLAYBACK_STATUS_STOPPED_MC = 'stopped';

export type MCPlaybackStatus = 'playing' | 'stopped' | 'paused';

export interface MCResponseCommon {
id: string
name: string
type: 'response'
}

export interface MCRequestCommon {
type: 'request'
id: string
name: string
}

export interface MCTrackResponse {
album: string
album_artist: string
album_artist_id: number
album_id: number
artist: string
artist_id: number
external_id: string
genre: string
genre_id: number
id: number
thumbnail_id: number
title: string
track: number
}

export interface MCPlaybackOverviewResponse extends MCResponseCommon {
options: {
muted: boolean
play_queue_position: number
playing_current_time: number
playing_duration: number
playing_track: MCTrackResponse
repeat_mode: string
shuffled: boolean
state: MCPlaybackStatus
track_count: number
volume: number
}
}

export interface MCAuthenticateResponse extends MCResponseCommon {
options: {
authenticated: boolean
environment: {
api_version: number
app_version: string
http_server_enabled: boolean
http_server_port: number
sdk_version: number
}
}
}

export interface MCAuthenticateRequest extends MCRequestCommon {
name: 'authenticate',
device_id: string
options: {
password: string
}
}

export interface MCPlaybackOverviewRequest extends MCRequestCommon {
name: 'get_playback_overview'
device_id: string
}

export interface MusikcubeData extends CommonSourceData {
/**
* URL of the Musikcube Websocket (Metadata) server to connect to
*
* You MUST have enabled 'metadata' server and set a password: https://github.com/clangen/musikcube/wiki/remote-api-documentation
* * musikcube -> settings -> server setup
*
* The URL you provide here will have all parts not explicitly defined filled in for you so if these are not the default you must define them.
*
* Parts => [default value]
*
* * Protocol => `ws://`
* * Hostname => `localhost`
* * Port => `7905`
*
*
* @examples ["ws://localhost:7905"]
* @default "ws://localhost:7905"
* */
url?: string

/**
* Password set in Musikcube https://github.com/clangen/musikcube/wiki/remote-api-documentation
*
* * musikcube -> settings -> server setup -> password
* */
password: string

device_id?: string

}

export interface MusikcubeSourceConfig extends CommonSourceConfig {
data: MusikcubeData
}

export interface MusikcubeSourceAIOConfig extends MusikcubeSourceConfig {
type: 'musikcube'
}
Loading

0 comments on commit 5d35b04

Please sign in to comment.