From 8929a630ed64d62b3acb391b24daebd07ff85b45 Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Thu, 11 Jan 2024 15:25:06 -0500 Subject: [PATCH] docs: chromecast docs and schema --- README.md | 1 + config/chromecast.json.example | 11 ++ docsite/docs/configuration/configuration.md | 23 +++ docsite/src/pages/index.mdx | 1 + src/backend/common/schema/aio-source.json | 182 ++++++++++++++++++++ src/backend/common/schema/aio.json | 182 ++++++++++++++++++++ src/backend/common/schema/source.json | 174 +++++++++++++++++++ 7 files changed, 574 insertions(+) create mode 100644 config/chromecast.json.example diff --git a/README.md b/README.md index 8da712c9..718a841c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ A javascript app to scrobble music you listened to, to [Maloja](https://github.c * [Mopidy](/docsite/docs/configuration/configuration.md#mopidy) * [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-) * Supports scrobbling to many **Clients** * [Maloja](/docsite/docs/configuration/configuration.md#maloja) * [Last.fm](/docsite/docs/configuration/configuration.md#lastfm) diff --git a/config/chromecast.json.example b/config/chromecast.json.example new file mode 100644 index 00000000..a820c5c0 --- /dev/null +++ b/config/chromecast.json.example @@ -0,0 +1,11 @@ +[ + { + "name": "MyCast", + "data": { + "blacklistedDevices": [], + "whitelistedDevices": [], + "blacklistedApps": [], + "whitelistedApps": [] + } + } +] diff --git a/docsite/docs/configuration/configuration.md b/docsite/docs/configuration/configuration.md index 120b4400..4a0a5a47 100644 --- a/docsite/docs/configuration/configuration.md +++ b/docsite/docs/configuration/configuration.md @@ -25,6 +25,7 @@ title: Overview * [JRiver](#jriver) * [Kodi](#kodi) * [WebScrobbler](#webscrobbler) + * [Google Cast (Chromecast)](#google-cast--chromecast-) * [Client Configurations](#client-configurations) * [Maloja](#maloja) * [Last.fm](#lastfm) @@ -694,6 +695,28 @@ MS can be configured to only scrobble, or NOT scrobble, from some WS connectors. See [`webscrobbler.json.example`](https://github.com/FoxxMD/multi-scrobbler/blob/master/config/webscrobbler.json.example) or [explore the schema with an example and live editor/validator](https://json-schema.app/view/%23%2Fdefinitions%2FWebScrobblerSourceConfig/%23%2Fdefinitions%2FWebScrobblerData?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fmulti-scrobbler%2Fmaster%2Fsrc%2Fbackend%2Fcommon%2Fschema%2Fsource.json) +## [Google Cast (Chromecast)](https://www.google.com/chromecast/built-in/) + +If your media device can be **Cast** to using this button ![Chromecast Icon](https://upload.wikimedia.org/wikipedia/commons/2/26/Chromecast_cast_button_icon.svg) on your phone/computer then multi-scrobbler can monitor it in order to scrobble music you play. + +**Note:** This source relies on common, **basic** music data provided by the cast device which will always be less exhaustive than data parsed from full source integrations. If there is an existing [Source](#source-configurations) it is recommended to configure for it and blacklist the app on Google Cast, rather than relying solely on Google Cast for scrobbling. + +The machine and/or container running multi-scrobbler must be configured to allow [mDNS traffic on port 5353/UDP](https://book.hacktricks.xyz/network-services-pentesting/5353-udp-multicast-dns-mdns). + +### ENV-Based + +| Environmental Variable | Required? | Default | Description | +|------------------------|-----------|---------|--------------------------------------------------------------------------------------| +| CC_ENABLE | No | | Set to 'true' to enable Cast monitoring without needing to define other ENVs | +| CC_WHITELIST_DEVICES | No | | Only scrobble from these Cast devices. Comma-delimited list. EX mini-home, family-tv | +| CC_BLACKLIST_DEVICES | No | | Do not scrobble from these Cast devices. Comma-delimited list | +| CC_WHITELIST_APPS | No | | Only scrobble from these casted Apps. Comma-delimited list. EX spotify, pandora | +| CC_BLACKLIST_APPS | No | | Do not scrobble from these casted Apps. Comma-delimited list | + +### File-Based + +See [`chromecast.json.example`](https://github.com/FoxxMD/multi-scrobbler/blob/master/config/webscrobbler.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) + # Client Configurations ## [Maloja](https://github.com/krateng/maloja) diff --git a/docsite/src/pages/index.mdx b/docsite/src/pages/index.mdx index 3612d24a..f8ac6e18 100644 --- a/docsite/src/pages/index.mdx +++ b/docsite/src/pages/index.mdx @@ -26,6 +26,7 @@ A javascript app to scrobble music you listened to, to [Maloja](https://github.c * [Mopidy](docs/configuration#mopidy) * [JRiver](docs/configuration#jriver) * [Kodi](docs/configuration#kodi) + * [Google Cast (Chromecast)](/docs/configuration#google-cast--chromecast-) * Supports scrobbling to many **Clients** * [Maloja](docs/configuration#maloja) * [Last.fm](docs/configuration#lastfm) diff --git a/src/backend/common/schema/aio-source.json b/src/backend/common/schema/aio-source.json index 1d146a85..dde5330d 100644 --- a/src/backend/common/schema/aio-source.json +++ b/src/backend/common/schema/aio-source.json @@ -1,6 +1,185 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { + "ChromecastData": { + "properties": { + "blacklistApps": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "DO NOT scrobble from any application that START WITH these values, case-insensitive", + "examples": [ + [ + "spotify", + "pandora" + ] + ], + "title": "blacklistApps" + }, + "blacklistDevices": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "DO NOT scrobble from any cast devices that START WITH these values, case-insensitive", + "examples": [ + [ + "home-mini", + "family-tv" + ] + ], + "title": "blacklistDevices" + }, + "maxPollRetries": { + "default": 5, + "description": "default # of automatic polling restarts on error", + "examples": [ + 5 + ], + "title": "maxPollRetries", + "type": "number" + }, + "maxRequestRetries": { + "default": 1, + "description": "default # of http request retries a source can make before error is thrown", + "examples": [ + 1 + ], + "title": "maxRequestRetries", + "type": "number" + }, + "options": { + "$ref": "#/definitions/Record", + "title": "options" + }, + "retryMultiplier": { + "default": 1.5, + "description": "default retry delay multiplier (retry attempt * multiplier = # of seconds to wait before retrying)", + "examples": [ + 1.5 + ], + "title": "retryMultiplier", + "type": "number" + }, + "scrobbleThresholds": { + "$ref": "#/definitions/ScrobbleThresholds", + "description": "Set thresholds for when multi-scrobbler should consider a tracked play to be \"scrobbable\". If both duration and percent are defined then if either condition is met the track is scrobbled.", + "title": "scrobbleThresholds" + }, + "whitelistApps": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "ONLY scrobble from any application that START WITH these values, case-insensitive\n\nIf whitelist is present then blacklist is ignored", + "examples": [ + [ + "spotify", + "pandora" + ] + ], + "title": "whitelistApps" + }, + "whitelistDevices": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "ONLY scrobble from any cast device that START WITH these values, case-insensitive\n\nIf whitelist is present then blacklist is ignored", + "examples": [ + [ + "home-mini", + "family-tv" + ] + ], + "title": "whitelistDevices" + } + }, + "title": "ChromecastData", + "type": "object" + }, + "ChromecastSourceAIOConfig": { + "properties": { + "clients": { + "description": "Restrict scrobbling tracks played from this source to Clients with names from this list. If list is empty is not present Source scrobbles to all configured Clients.", + "examples": [ + [ + "MyMalojaConfigName", + "MyLastFMConfigName" + ] + ], + "items": { + "type": "string" + }, + "title": "clients", + "type": "array" + }, + "data": { + "$ref": "#/definitions/ChromecastData", + "title": "data" + }, + "enable": { + "default": true, + "description": "Should MS use this client/source? Defaults to true", + "examples": [ + true + ], + "title": "enable", + "type": "boolean" + }, + "name": { + "description": "Unique identifier for this source.", + "title": "name", + "type": "string" + }, + "options": { + "$ref": "#/definitions/CommonSourceOptions", + "title": "options" + }, + "type": { + "enum": [ + "chromecast" + ], + "title": "type", + "type": "string" + } + }, + "required": [ + "data", + "type" + ], + "title": "ChromecastSourceAIOConfig", + "type": "object" + }, "CommonSourceOptions": { "properties": { "logFilterFailure": { @@ -1461,6 +1640,9 @@ }, { "$ref": "#/definitions/WebScrobblerSourceAIOConfig" + }, + { + "$ref": "#/definitions/ChromecastSourceAIOConfig" } ], "title": "SourceAIOConfig" diff --git a/src/backend/common/schema/aio.json b/src/backend/common/schema/aio.json index 4ceaad69..8a87500c 100644 --- a/src/backend/common/schema/aio.json +++ b/src/backend/common/schema/aio.json @@ -1,6 +1,185 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { + "ChromecastData": { + "properties": { + "blacklistApps": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "DO NOT scrobble from any application that START WITH these values, case-insensitive", + "examples": [ + [ + "spotify", + "pandora" + ] + ], + "title": "blacklistApps" + }, + "blacklistDevices": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "DO NOT scrobble from any cast devices that START WITH these values, case-insensitive", + "examples": [ + [ + "home-mini", + "family-tv" + ] + ], + "title": "blacklistDevices" + }, + "maxPollRetries": { + "default": 5, + "description": "default # of automatic polling restarts on error", + "examples": [ + 5 + ], + "title": "maxPollRetries", + "type": "number" + }, + "maxRequestRetries": { + "default": 1, + "description": "default # of http request retries a source can make before error is thrown", + "examples": [ + 1 + ], + "title": "maxRequestRetries", + "type": "number" + }, + "options": { + "$ref": "#/definitions/Record", + "title": "options" + }, + "retryMultiplier": { + "default": 1.5, + "description": "default retry delay multiplier (retry attempt * multiplier = # of seconds to wait before retrying)", + "examples": [ + 1.5 + ], + "title": "retryMultiplier", + "type": "number" + }, + "scrobbleThresholds": { + "$ref": "#/definitions/ScrobbleThresholds", + "description": "Set thresholds for when multi-scrobbler should consider a tracked play to be \"scrobbable\". If both duration and percent are defined then if either condition is met the track is scrobbled.", + "title": "scrobbleThresholds" + }, + "whitelistApps": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "ONLY scrobble from any application that START WITH these values, case-insensitive\n\nIf whitelist is present then blacklist is ignored", + "examples": [ + [ + "spotify", + "pandora" + ] + ], + "title": "whitelistApps" + }, + "whitelistDevices": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "ONLY scrobble from any cast device that START WITH these values, case-insensitive\n\nIf whitelist is present then blacklist is ignored", + "examples": [ + [ + "home-mini", + "family-tv" + ] + ], + "title": "whitelistDevices" + } + }, + "title": "ChromecastData", + "type": "object" + }, + "ChromecastSourceAIOConfig": { + "properties": { + "clients": { + "description": "Restrict scrobbling tracks played from this source to Clients with names from this list. If list is empty is not present Source scrobbles to all configured Clients.", + "examples": [ + [ + "MyMalojaConfigName", + "MyLastFMConfigName" + ] + ], + "items": { + "type": "string" + }, + "title": "clients", + "type": "array" + }, + "data": { + "$ref": "#/definitions/ChromecastData", + "title": "data" + }, + "enable": { + "default": true, + "description": "Should MS use this client/source? Defaults to true", + "examples": [ + true + ], + "title": "enable", + "type": "boolean" + }, + "name": { + "description": "Unique identifier for this source.", + "title": "name", + "type": "string" + }, + "options": { + "$ref": "#/definitions/CommonSourceOptions", + "title": "options" + }, + "type": { + "enum": [ + "chromecast" + ], + "title": "type", + "type": "string" + } + }, + "required": [ + "data", + "type" + ], + "title": "ChromecastSourceAIOConfig", + "type": "object" + }, "ClientAIOConfig": { "anyOf": [ { @@ -2183,6 +2362,9 @@ }, { "$ref": "#/definitions/WebScrobblerSourceAIOConfig" + }, + { + "$ref": "#/definitions/ChromecastSourceAIOConfig" } ], "title": "SourceAIOConfig" diff --git a/src/backend/common/schema/source.json b/src/backend/common/schema/source.json index fa1b4a7c..288985fa 100644 --- a/src/backend/common/schema/source.json +++ b/src/backend/common/schema/source.json @@ -42,9 +42,183 @@ }, { "$ref": "#/definitions/WebScrobblerSourceConfig" + }, + { + "$ref": "#/definitions/ChromecastSourceConfig" } ], "definitions": { + "ChromecastData": { + "properties": { + "blacklistApps": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "DO NOT scrobble from any application that START WITH these values, case-insensitive", + "examples": [ + [ + "spotify", + "pandora" + ] + ], + "title": "blacklistApps" + }, + "blacklistDevices": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "DO NOT scrobble from any cast devices that START WITH these values, case-insensitive", + "examples": [ + [ + "home-mini", + "family-tv" + ] + ], + "title": "blacklistDevices" + }, + "maxPollRetries": { + "default": 5, + "description": "default # of automatic polling restarts on error", + "examples": [ + 5 + ], + "title": "maxPollRetries", + "type": "number" + }, + "maxRequestRetries": { + "default": 1, + "description": "default # of http request retries a source can make before error is thrown", + "examples": [ + 1 + ], + "title": "maxRequestRetries", + "type": "number" + }, + "options": { + "$ref": "#/definitions/Record", + "title": "options" + }, + "retryMultiplier": { + "default": 1.5, + "description": "default retry delay multiplier (retry attempt * multiplier = # of seconds to wait before retrying)", + "examples": [ + 1.5 + ], + "title": "retryMultiplier", + "type": "number" + }, + "scrobbleThresholds": { + "$ref": "#/definitions/ScrobbleThresholds", + "description": "Set thresholds for when multi-scrobbler should consider a tracked play to be \"scrobbable\". If both duration and percent are defined then if either condition is met the track is scrobbled.", + "title": "scrobbleThresholds" + }, + "whitelistApps": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "ONLY scrobble from any application that START WITH these values, case-insensitive\n\nIf whitelist is present then blacklist is ignored", + "examples": [ + [ + "spotify", + "pandora" + ] + ], + "title": "whitelistApps" + }, + "whitelistDevices": { + "anyOf": [ + { + "items": { + "type": "string" + }, + "type": "array" + }, + { + "type": "string" + } + ], + "description": "ONLY scrobble from any cast device that START WITH these values, case-insensitive\n\nIf whitelist is present then blacklist is ignored", + "examples": [ + [ + "home-mini", + "family-tv" + ] + ], + "title": "whitelistDevices" + } + }, + "title": "ChromecastData", + "type": "object" + }, + "ChromecastSourceConfig": { + "properties": { + "clients": { + "description": "Restrict scrobbling tracks played from this source to Clients with names from this list. If list is empty is not present Source scrobbles to all configured Clients.", + "examples": [ + [ + "MyMalojaConfigName", + "MyLastFMConfigName" + ] + ], + "items": { + "type": "string" + }, + "title": "clients", + "type": "array" + }, + "data": { + "$ref": "#/definitions/ChromecastData", + "title": "data" + }, + "enable": { + "default": true, + "description": "Should MS use this client/source? Defaults to true", + "examples": [ + true + ], + "title": "enable", + "type": "boolean" + }, + "name": { + "description": "Unique identifier for this source.", + "title": "name", + "type": "string" + }, + "options": { + "$ref": "#/definitions/CommonSourceOptions", + "title": "options" + } + }, + "required": [ + "data" + ], + "title": "ChromecastSourceConfig", + "type": "object" + }, "CommonSourceOptions": { "properties": { "logFilterFailure": { -- 2.51.2