From 4744fe769a87720419c309589dc36561b894565b Mon Sep 17 00:00:00 2001 From: Casey Fitzpatrick Date: Thu, 20 Jan 2022 08:48:41 -0500 Subject: [PATCH 1/2] fix: Handle albumArtURI when extra attributes are given When extra attributes are given to upnp:albumArtURI, the "main" value of albumArtURI is assigned to '_' inside a dict. This seems to happen for tracks played over DLNA. Handle this case so albumArtURI and consequently albumArtURL is parsed correctly and doesn't error out. --- lib/helpers.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/helpers.js b/lib/helpers.js index f83a072..2b21d83 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -275,6 +275,9 @@ Helpers.dropIDNamespace = function (value) { Helpers.ParseDIDLItem = function (item, host, port, trackUri) { let albumArtURI = item['upnp:albumArtURI'] || null + if (albumArtURI && albumArtURI.constructor === Object) { + albumArtURI = albumArtURI['_'] + } if (albumArtURI && Array.isArray(albumArtURI)) { albumArtURI = albumArtURI.length > 0 ? albumArtURI[0] : null } From d8dfa067ad3eed848af973fb4192f405926e8f81 Mon Sep 17 00:00:00 2001 From: Casey Fitzpatrick Date: Thu, 20 Jan 2022 08:55:29 -0500 Subject: [PATCH 2/2] fix: Swallow errors when parsing albumArtURI in getting current track In case a parsing error occurs attempting to create albumArtURL, just log the problem to console rather than throwing an exception and failing out. --- lib/services/AVTransport.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/services/AVTransport.js b/lib/services/AVTransport.js index 09c5cd0..19594ae 100644 --- a/lib/services/AVTransport.js +++ b/lib/services/AVTransport.js @@ -196,9 +196,13 @@ class AVTransport extends Service { const track = Helpers.ParseDIDL(metadata) track.position = position track.duration = duration - track.albumArtURL = !track.albumArtURI ? null - : track.albumArtURI.startsWith('http') ? track.albumArtURI - : 'http://' + this.host + ':' + this.port + track.albumArtURI + try { + track.albumArtURL = !track.albumArtURI ? null + : track.albumArtURI.startsWith('http') ? track.albumArtURI + : 'http://' + this.host + ':' + this.port + track.albumArtURI + } catch (err) { + console.log('Could not parse this albumArtURI into albumArtURL: ', track.albumArtURI) + } if (trackUri) track.uri = trackUri track.queuePosition = queuePosition return track