Repository: beetbox/beets

Issue:
kodiupdate: support updating multiple Kodi instances
Pretty straitforward ask, it would be nice if when running beets using the Kodi update client that you could enter multiple clients

syntax would be something to the tune of ...

kodi:
    host: x.x.x.x
    port: 8080
    user: user
    pwd: password
kodi:
    host: x.x.x.x
    port: 8080
    user: user
    pwd: password
kodi:
    host: x.x.x.x
    port: 8080
    user: user
    pwd: password
can this please be implemented


Discussion:
Thanks for opening a feature request.

I don't think we can read duplicate keys from our configuration, but I think something like this should work:

```YAML
kodi:
  - host: localhost
    port: 8080
    user: kodi
    pwd: kodi
  - host: localhost
    port: 8081
    user: kodi
    pwd: kodi
```

We'd also still need to support the non-list format for backwards compatibility:

```YAML
kodi:
  host: localhost
  port: 8080
  user: kodi
  pwd: kodi
```
works for me!, thank you for making this change
Very good point, @jackwilsdon!!

Resolving patch:
diff --git a/beetsplug/kodiupdate.py b/beetsplug/kodiupdate.py
--- a/beetsplug/kodiupdate.py
+++ b/beetsplug/kodiupdate.py
@@ -54,11 +54,12 @@ def __init__(self):
         super().__init__()
 
         # Adding defaults.
-        config['kodi'].add({
+        config['kodi'].add([{
             'host': 'localhost',
             'port': 8080,
             'user': 'kodi',
-            'pwd': 'kodi'})
+            'pwd': 'kodi'
+        }])
 
         config['kodi']['pwd'].redact = True
         self.register_listener('database_change', self.listen_for_db_change)
@@ -72,24 +73,34 @@ def update(self, lib):
         """
         self._log.info('Requesting a Kodi library update...')
 
-        # Try to send update request.
-        try:
-            r = update_kodi(
-                config['kodi']['host'].get(),
-                config['kodi']['port'].get(),
-                config['kodi']['user'].get(),
-                config['kodi']['pwd'].get())
-            r.raise_for_status()
-
-        except requests.exceptions.RequestException as e:
-            self._log.warning('Kodi update failed: {0}',
-                              str(e))
-            return
-
-        json = r.json()
-        if json.get('result') != 'OK':
-            self._log.warning('Kodi update failed: JSON response was {0!r}',
-                              json)
-            return
-
-        self._log.info('Kodi update triggered')
+        kodi = config['kodi'].get()
+
+        # Backwards compatibility in case not configured as an array
+        if not isinstance(kodi, list):
+            kodi = [kodi]
+
+        for instance in kodi:
+            # Try to send update request.
+            try:
+                r = update_kodi(
+                    instance['host'],
+                    instance['port'],
+                    instance['user'],
+                    instance['pwd']
+                )
+                r.raise_for_status()
+
+                json = r.json()
+                if json.get('result') != 'OK':
+                    self._log.warning(
+                        'Kodi update failed: JSON response was {0!r}', json
+                    )
+                    continue
+
+                self._log.info(
+                    'Kodi update triggered for {0}:{1}',
+                    instance['host'], instance['port']
+                )
+            except requests.exceptions.RequestException as e:
+                self._log.warning('Kodi update failed: {0}', str(e))
+                continue


Test patch: