[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
0

Configure Feed

Select the types of activity you want to include in your feed.

feat(musikcube): Provide more error logging and example config

* Update iso-websockets to fix typing exports and get node network error from WS error
* Add url example to config

FoxxMD (Jul 23, 2024, 12:11 PM EDT) 91e52c4c 9735b980

+18 -39
+1
config/musikcube.json.example
··· 4 4 "enable": true, 5 5 "name": "musikcube", 6 6 "data": { 7 + "url": "ws://localhost:7905", 7 8 "password": "MY_PASSWORD" 8 9 } 9 10 }
+9 -9
package-lock.json
··· 45 45 "fixed-size-list": "^0.3.0", 46 46 "formidable": "^2.1", 47 47 "gotify": "^1.1.0", 48 - "iso-websocket": "^0.2.0", 48 + "iso-websocket": "^0.3.0", 49 49 "iti": "^0.6.0", 50 50 "json5": "^2.2.3", 51 51 "kodi-api": "^0.2.1", ··· 6085 6085 "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" 6086 6086 }, 6087 6087 "node_modules/iso-websocket": { 6088 - "version": "0.2.0", 6089 - "resolved": "https://registry.npmjs.org/iso-websocket/-/iso-websocket-0.2.0.tgz", 6090 - "integrity": "sha512-imBalzmPSq0C9CfMouimB2kZ5X1qS4Yai8kGTQdluGRb0T0iu+BkPcakFelh4FIlTM8y6+BNuCEGog3lf8HC4A==", 6088 + "version": "0.3.0", 6089 + "resolved": "https://registry.npmjs.org/iso-websocket/-/iso-websocket-0.3.0.tgz", 6090 + "integrity": "sha512-RCzPkKMtX36F1FnoII4TO42aQF+ypGgtNuIamR2TwM+9a8JGBbxkxOcFf1WJKsSAh8sv1HXSjR+Lu+jGz/6oVA==", 6091 6091 "dependencies": { 6092 - "debug": "^4.3.4", 6092 + "debug": "^4.3.5", 6093 6093 "retry": "^0.13.1", 6094 6094 "typescript-event-target": "^1.1.0", 6095 6095 "unws": "^0.2.4", 6096 - "ws": "^8.16.0" 6096 + "ws": "^8.18.0" 6097 6097 } 6098 6098 }, 6099 6099 "node_modules/isomorphic-ws": { ··· 10539 10539 "peer": true 10540 10540 }, 10541 10541 "node_modules/ws": { 10542 - "version": "8.17.1", 10543 - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", 10544 - "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", 10542 + "version": "8.18.0", 10543 + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", 10544 + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", 10545 10545 "engines": { 10546 10546 "node": ">=10.0.0" 10547 10547 },
+1 -1
package.json
··· 80 80 "fixed-size-list": "^0.3.0", 81 81 "formidable": "^2.1", 82 82 "gotify": "^1.1.0", 83 - "iso-websocket": "^0.2.0", 83 + "iso-websocket": "^0.3.0", 84 84 "iti": "^0.6.0", 85 85 "json5": "^2.2.3", 86 86 "kodi-api": "^0.2.1",
+7 -29
src/backend/sources/MusikcubeSource.ts
··· 1 1 import { childLogger } from "@foxxmd/logging"; 2 2 import { EventEmitter } from "events"; 3 - import { WS } from 'iso-websocket' 4 - // TODO remove when/if iso-websocket exports these 5 - // @ ts-expect-error not exported properly by package 6 - //import { CloseEvent, ErrorEvent, RetryEvent } from "iso-websocket/dist/src/events.js"; 3 + import { WS, CloseEvent, ErrorEvent, RetryEvent } from 'iso-websocket' 7 4 import { randomUUID } from "node:crypto"; 8 5 import normalizeUrl from 'normalize-url'; 9 6 import pEvent from 'p-event'; ··· 102 99 automaticOpen: false, 103 100 retry: { 104 101 retries: 0 105 - }, 106 - //errorInfo: true 102 + } 107 103 }); 108 104 const wsLogger = childLogger(this.logger, 'WS'); 109 105 this.client.addEventListener('retry', (e) => { ··· 128 124 this.connectionOK = false; 129 125 this.authed = false; 130 126 } 131 - if(e.error.message === ('Websocket error')) { 132 - wsLogger.error('Communication with server failed => Websocket error'); 133 - 134 - } else { 135 - wsLogger.error(new Error('Communication with server failed', {cause: e.error})); 136 - } 127 + const hint = e.error?.cause?.message ?? undefined; 128 + wsLogger.error(new Error(`Communication with server failed${hint !== undefined ? ` (${hint})` : ''}`, {cause: e.error})); 137 129 }); 138 130 139 131 this.client.addEventListener('message', (e) => { ··· 148 140 protected async doCheckConnection(): Promise<true | string | undefined> { 149 141 try { 150 142 this.client.open(); 151 - const e = await pEvent(this.client, 'open'); 143 + const opened = await pEvent(this.client, 'open'); 152 144 return true; 153 145 } catch (e) { 154 146 this.client.close(); 155 - throw new Error(`Could not connect to Musikcube metadata server`); 147 + const hint = e.error?.cause?.message ?? undefined; 148 + throw new Error(`Could not connect to Musikcube metadata server${hint !== undefined ? ` (${hint})` : ''}`, {cause: e.error ?? e}); 156 149 } 157 150 158 151 } ··· 282 275 } 283 276 const isRetryEvent = (e: Event): e is RetryEvent => { 284 277 return e.type === 'retry'; 285 - } 286 - 287 - // TODO remove when/if iso-websockets exports these 288 - interface ErrorEvent extends Event { 289 - type: 'error' 290 - error: Error 291 - message: string 292 - } 293 - interface CloseEvent extends Event { 294 - type: 'close' 295 - reason: string 296 - code: number 297 - } 298 - interface RetryEvent extends Event { 299 - type: 'retry' 300 278 } 301 279 302 280 const isAuthenticateResponse = (data: any): data is MCAuthenticateResponse => {