diff --git a/README.md b/README.md index a7fe5eb3..fa758ad9 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ A javascript app to scrobble music you listened to, to [Maloja](https://github.c * [Google Cast (Chromecast)](https://foxxmd.github.io/multi-scrobbler/docs/configuration#google-cast-chromecast) * [Musikcube](https://foxxmd.github.io/multi-scrobbler/docs/configuration#muikcube) * [MPD (Music Player Daemon)](https://foxxmd.github.io/multi-scrobbler/docs/configuration#mpd-music-player-daemon) + * [VLC](https://foxxmd.github.io/multi-scrobbler/docs/configuration#vlc) * Supports scrobbling to many **Clients** * [Maloja](https://foxxmd.github.io/multi-scrobbler/docs/configuration#maloja) * [Last.fm](https://foxxmd.github.io/multi-scrobbler/docs/configuration#lastfm) diff --git a/config/vlc.json.example b/config/vlc.json.example new file mode 100644 index 00000000..988040c5 --- /dev/null +++ b/config/vlc.json.example @@ -0,0 +1,10 @@ +[ + { + "enable": true, + "name": "MyVlc", + "data": { + "url": "localhost:8080", + "password": "changeme" + } + } +] diff --git a/docsite/docs/configuration/configuration.mdx b/docsite/docs/configuration/configuration.mdx index d0f1f6ed..d6b40b72 100644 --- a/docsite/docs/configuration/configuration.mdx +++ b/docsite/docs/configuration/configuration.mdx @@ -28,6 +28,7 @@ import SubsonicConfig from '!!raw-loader!../../../config/subsonic.json.example'; import TautulliConfig from '!!raw-loader!../../../config/tautulli.json.example'; import WebscrobblerConfig from '!!raw-loader!../../../config/webscrobbler.json.example'; import YTMusicConfig from '!!raw-loader!../../../config/ytmusic.json.example'; +import VLCConfig from '!!raw-loader!../../../config/vlc.json.example'; # Configuration @@ -1317,6 +1318,122 @@ port "6600" +### [VLC](https://www.videolan.org/vlc/) + +MS communicates with VLC using the [Web (`http`) interface module](https://wiki.videolan.org/VLC_HTTP_requests/) + +#### Enable HTTP Interface + +Open VLC, then + +* **Tools** Menu -> Preferences + * In the bottom left change **Show Settings** from `Simple` to `All` + * In the updated window select Interface -> Main interfaces + * In the **Extra interface modules** section enable **Web** and verify that `http` is shown in the textbox + * Select Interface -> Main interfaces -> Lua + * In Lua HTTP -> Password -> set a password in this box + * Click **Save** at the bottom to persist your changes +* Restart VLC +* Verify the HTTP interface is accessible by navigating to `http://localhost:8080` in your browser + +If the interface is accessible, after typing in your password, VLC is now ready to be used by MS. + +##### Setting VLC Interface and Port + +These can be set by starting VLC from command line with specific options: + +* `vlc --http-host yourHostIp:yourPort` or +* `vlc --http-port yourPort` or +* modify the configuration file for VLC by editing keys with the same values as from the command line (`http-host` and `http-port`) + + +#### Configuration + + + + | Environmental Variable | Required? | Default | Description | + |------------------------|------------|------------------|-------------| + | `VLC_URL` | No | `localhost:8080` | | + | `VLC_PASSWORD` | Yes | | | + + +
+ + Example + + {VLCConfig} + +
+ + or +
+ +
+ + Example + + + +
+ + or +
+
+ +#### Filename Parsing + +If the file being played in VLC does not have ID3 tags/metadata information multi-scrobbler can attempt to extract artist, title, and album information from the raw filename using regular expressions. Mutli-scrobbler will only do this if there is **no other information** reported by VLC about these fields. + +To extract this information use [named capture groups](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Named_capturing_group) in your expression matching the field that should be extracted: `artist` `title` and/or `album`. MS accepts multiple expressions, the first one that matches a filename will be used. + +
+ + Example + + Example usage in [a file-based config:](./configuration?configType=file#webscrobbler-config) + + ```json5 title="config/vlc.json" {10-16} + [ + { + "name": "MyVlc", + "enable": true, + "data": { + // ... + }, + "options": { + "filenamePatterns": [ + // Extracts artist and title from filenames that look like: + // My Artist - My Cool title.mp4 + "/^\\s*(?.+?) - (?.+?)\\.\\w+$/i" + ], + // logs to DEBUG when MS tries to extract data from a filename + "logFilenamePatterns": true, + } + } + ] + ``` + +</details> + +#### Vlc Information Reporting + +If you find that VLC is correctly reporting track information (in its interface) but multi-scrobbler is not parsing it correctly it may be due to the _name_ of the fields VLC is reporting. mutli-scrobbler uses the most common field name but does not cover all use cases. Before reporting an issue please turn on metadata logging and include output from your logs while it is turned on: + +```json5 title="config/vlc.json" {10-10} + [ + { + "name": "MyVlc", + "enable": true, + "data": { + // ... + }, + "options": { + "dumpVlcMetadata": true + } + } + ] + ``` + ## Client Configurations ### [Maloja](https://github.com/krateng/maloja) diff --git a/docsite/src/pages/index.mdx b/docsite/src/pages/index.mdx index 21d04d43..c28b0abc 100644 --- a/docsite/src/pages/index.mdx +++ b/docsite/src/pages/index.mdx @@ -29,6 +29,7 @@ A javascript app to scrobble music you listened to, to [Maloja](https://github.c * [Google Cast (Chromecast)](docs/configuration#google-cast-chromecast) * [Musikcube](docs/configuration#musikcube) * [MPD (Music Player Daemon)](docs/configuration#mpd-music-player-daemon) + * [VLC](docs/configuration#vlc) * Supports scrobbling to many **Clients** * [Maloja](docs/configuration#maloja) * [Last.fm](docs/configuration#lastfm) diff --git a/src/backend/common/infrastructure/config/source/vlc.ts b/src/backend/common/infrastructure/config/source/vlc.ts index dab26cd4..43261cfa 100644 --- a/src/backend/common/infrastructure/config/source/vlc.ts +++ b/src/backend/common/infrastructure/config/source/vlc.ts @@ -44,7 +44,7 @@ export interface VLCSourceOptions extends CommonSourceOptions { export interface VLCSourceConfig extends CommonSourceConfig { data: VLCData - options: VLCSourceOptions + options?: VLCSourceOptions } export interface VLCSourceAIOConfig extends VLCSourceConfig { diff --git a/src/backend/common/schema/aio-client.json b/src/backend/common/schema/aio-client.json index befd264e..540f004d 100644 --- a/src/backend/common/schema/aio-client.json +++ b/src/backend/common/schema/aio-client.json @@ -356,7 +356,6 @@ "title": "options" }, "type": { - "default": "maloja", "enum": [ "maloja" ], diff --git a/src/backend/common/schema/aio-source.json b/src/backend/common/schema/aio-source.json index 424a2f52..fc226ad8 100644 --- a/src/backend/common/schema/aio-source.json +++ b/src/backend/common/schema/aio-source.json @@ -2213,7 +2213,6 @@ }, "required": [ "data", - "options", "type" ], "title": "VLCSourceAIOConfig", diff --git a/src/backend/common/schema/aio.json b/src/backend/common/schema/aio.json index 7afeb24a..1a1db46e 100644 --- a/src/backend/common/schema/aio.json +++ b/src/backend/common/schema/aio.json @@ -1928,7 +1928,6 @@ "title": "options" }, "type": { - "default": "maloja", "enum": [ "maloja" ], @@ -3138,7 +3137,6 @@ }, "required": [ "data", - "options", "type" ], "title": "VLCSourceAIOConfig", diff --git a/src/backend/common/schema/source.json b/src/backend/common/schema/source.json index af2ba41a..7ac0896e 100644 --- a/src/backend/common/schema/source.json +++ b/src/backend/common/schema/source.json @@ -2049,8 +2049,7 @@ } }, "required": [ - "data", - "options" + "data" ], "title": "VLCSourceConfig", "type": "object" diff --git a/src/backend/sources/ScrobbleSources.ts b/src/backend/sources/ScrobbleSources.ts index ecf4857f..4e2a0c18 100644 --- a/src/backend/sources/ScrobbleSources.ts +++ b/src/backend/sources/ScrobbleSources.ts @@ -20,7 +20,7 @@ import { SourceAIOConfig, SourceConfig } from "../common/infrastructure/config/s import { SpotifySourceConfig, SpotifySourceData } from "../common/infrastructure/config/source/spotify.js"; import { SubsonicData, SubSonicSourceConfig } from "../common/infrastructure/config/source/subsonic.js"; import { TautulliSourceConfig } from "../common/infrastructure/config/source/tautulli.js"; -import { VLCSourceConfig } from "../common/infrastructure/config/source/vlc.js"; +import { VLCData, VLCSourceConfig } from "../common/infrastructure/config/source/vlc.js"; import { WebScrobblerSourceConfig } from "../common/infrastructure/config/source/webscrobbler.js"; import { YTMusicSourceConfig } from "../common/infrastructure/config/source/ytmusic.js"; import * as aioSchema from "../common/schema/aio-source.json"; @@ -365,6 +365,22 @@ export default class ScrobbleSources { }); } break; + case 'vlc': + const vlc = { + url: process.env.VLC_URL, + password: process.env.VLC_PASSWORD + } + if (!Object.values(vlc).every(x => x === undefined)) { + configs.push({ + type: 'vlc', + name: 'unnamed', + source: 'ENV', + mode: 'single', + configureAs: defaultConfigureAs, + data: vlc as VLCData + }); + } + break; default: break; }