We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
plexupdate: Doesn't work with libaries not named "Music"
I've named my music libaries `Music (New)` and `Music (Untagged)`. The plex update plugin should update the `Music (New)` section, but instead of updating at least both music libaries it doesn't update anything. If I change the library name from `Music (New)` to `Music` it works like a charm. This is specified on line 33 of the beets plugin. A config option to add libraries other than `Music` would make sense imo.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `beetsplug/plexupdate.py`
Content:
```
1 """Updates an Plex library whenever the beets library is changed.
2 
3 Plex Home users enter the Plex Token to enable updating.
4 Put something like the following in your config.yaml to configure:
5     plex:
6         host: localhost
7         port: 32400
8         token: token
9 """
10 from __future__ import (division, absolute_import, print_function,
11                         unicode_literals)
12 
13 import requests
14 from urlparse import urljoin
15 from urllib import urlencode
16 import xml.etree.ElementTree as ET
17 from beets import config
18 from beets.plugins import BeetsPlugin
19 
20 
21 def get_music_section(host, port, token):
22     """Getting the section key for the music library in Plex.
23     """
24     api_endpoint = append_token('library/sections', token)
25     url = urljoin('http://{0}:{1}'.format(host, port), api_endpoint)
26 
27     # Sends request.
28     r = requests.get(url)
29 
30     # Parse xml tree and extract music section key.
31     tree = ET.fromstring(r.text)
32     for child in tree.findall('Directory'):
33         if child.get('title') == 'Music':
34             return child.get('key')
35 
36 
37 def update_plex(host, port, token):
38     """Sends request to the Plex api to start a library refresh.
39     """
40     # Getting section key and build url.
41     section_key = get_music_section(host, port, token)
42     api_endpoint = 'library/sections/{0}/refresh'.format(section_key)
43     api_endpoint = append_token(api_endpoint, token)
44     url = urljoin('http://{0}:{1}'.format(host, port), api_endpoint)
45 
46     # Sends request and returns requests object.
47     r = requests.get(url)
48     return r
49 
50 
51 def append_token(url, token):
52     """Appends the Plex Home token to the api call if required.
53     """
54     if token:
55         url += '?' + urlencode({'X-Plex-Token': token})
56     return url
57 
58 
59 class PlexUpdate(BeetsPlugin):
60     def __init__(self):
61         super(PlexUpdate, self).__init__()
62 
63         # Adding defaults.
64         config['plex'].add({
65             u'host': u'localhost',
66             u'port': 32400,
67             u'token': u''})
68 
69         self.register_listener('database_change', self.listen_for_db_change)
70 
71     def listen_for_db_change(self, lib, model):
72         """Listens for beets db change and register the update for the end"""
73         self.register_listener('cli_exit', self.update)
74 
75     def update(self, lib):
76         """When the client exists try to send refresh request to Plex server.
77         """
78         self._log.info('Updating Plex library...')
79 
80         # Try to send update request.
81         try:
82             update_plex(
83                 config['plex']['host'].get(),
84                 config['plex']['port'].get(),
85                 config['plex']['token'].get())
86             self._log.info('... started.')
87 
88         except requests.exceptions.RequestException:
89             self._log.warning('Update failed.')
90
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/beetsplug/plexupdate.py b/beetsplug/plexupdate.py
--- a/beetsplug/plexupdate.py
+++ b/beetsplug/plexupdate.py
@@ -18,7 +18,7 @@
 from beets.plugins import BeetsPlugin
 
 
-def get_music_section(host, port, token):
+def get_music_section(host, port, token, library_name):
     """Getting the section key for the music library in Plex.
     """
     api_endpoint = append_token('library/sections', token)
@@ -30,15 +30,15 @@
     # Parse xml tree and extract music section key.
     tree = ET.fromstring(r.text)
     for child in tree.findall('Directory'):
-        if child.get('title') == 'Music':
+        if child.get('title') == library_name:
             return child.get('key')
 
 
-def update_plex(host, port, token):
+def update_plex(host, port, token, library_name):
     """Sends request to the Plex api to start a library refresh.
     """
     # Getting section key and build url.
-    section_key = get_music_section(host, port, token)
+    section_key = get_music_section(host, port, token, library_name)
     api_endpoint = 'library/sections/{0}/refresh'.format(section_key)
     api_endpoint = append_token(api_endpoint, token)
     url = urljoin('http://{0}:{1}'.format(host, port), api_endpoint)
@@ -64,7 +64,8 @@
         config['plex'].add({
             u'host': u'localhost',
             u'port': 32400,
-            u'token': u''})
+            u'token': u'',
+            u'library_name': u'Music'})
 
         self.register_listener('database_change', self.listen_for_db_change)
 
@@ -82,7 +83,8 @@
             update_plex(
                 config['plex']['host'].get(),
                 config['plex']['port'].get(),
-                config['plex']['token'].get())
+                config['plex']['token'].get(),
+                config['plex']['library_name'].get())
             self._log.info('... started.')
 
         except requests.exceptions.RequestException:

{"golden_diff": "diff --git a/beetsplug/plexupdate.py b/beetsplug/plexupdate.py\n--- a/beetsplug/plexupdate.py\n+++ b/beetsplug/plexupdate.py\n@@ -18,7 +18,7 @@\n from beets.plugins import BeetsPlugin\n \n \n-def get_music_section(host, port, token):\n+def get_music_section(host, port, token, library_name):\n     \"\"\"Getting the section key for the music library in Plex.\n     \"\"\"\n     api_endpoint = append_token('library/sections', token)\n@@ -30,15 +30,15 @@\n     # Parse xml tree and extract music section key.\n     tree = ET.fromstring(r.text)\n     for child in tree.findall('Directory'):\n-        if child.get('title') == 'Music':\n+        if child.get('title') == library_name:\n             return child.get('key')\n \n \n-def update_plex(host, port, token):\n+def update_plex(host, port, token, library_name):\n     \"\"\"Sends request to the Plex api to start a library refresh.\n     \"\"\"\n     # Getting section key and build url.\n-    section_key = get_music_section(host, port, token)\n+    section_key = get_music_section(host, port, token, library_name)\n     api_endpoint = 'library/sections/{0}/refresh'.format(section_key)\n     api_endpoint = append_token(api_endpoint, token)\n     url = urljoin('http://{0}:{1}'.format(host, port), api_endpoint)\n@@ -64,7 +64,8 @@\n         config['plex'].add({\n             u'host': u'localhost',\n             u'port': 32400,\n-            u'token': u''})\n+            u'token': u'',\n+            u'library_name': u'Music'})\n \n         self.register_listener('database_change', self.listen_for_db_change)\n \n@@ -82,7 +83,8 @@\n             update_plex(\n                 config['plex']['host'].get(),\n                 config['plex']['port'].get(),\n-                config['plex']['token'].get())\n+                config['plex']['token'].get(),\n+                config['plex']['library_name'].get())\n             self._log.info('... started.')\n \n         except requests.exceptions.RequestException:\n", "issue": "plexupdate: Doesn't work with libaries not named \"Music\"\nI've named my music libaries `Music (New)` and `Music (Untagged)`. The plex update plugin should update the `Music (New)` section, but instead of updating at least both music libaries it doesn't update anything. If I change the library name from `Music (New)` to `Music` it works like a charm. This is specified on line 33 of the beets plugin. A config option to add libraries other than `Music` would make sense imo.\n\n", "before_files": [{"content": "\"\"\"Updates an Plex library whenever the beets library is changed.\n\nPlex Home users enter the Plex Token to enable updating.\nPut something like the following in your config.yaml to configure:\n    plex:\n        host: localhost\n        port: 32400\n        token: token\n\"\"\"\nfrom __future__ import (division, absolute_import, print_function,\n                        unicode_literals)\n\nimport requests\nfrom urlparse import urljoin\nfrom urllib import urlencode\nimport xml.etree.ElementTree as ET\nfrom beets import config\nfrom beets.plugins import BeetsPlugin\n\n\ndef get_music_section(host, port, token):\n    \"\"\"Getting the section key for the music library in Plex.\n    \"\"\"\n    api_endpoint = append_token('library/sections', token)\n    url = urljoin('http://{0}:{1}'.format(host, port), api_endpoint)\n\n    # Sends request.\n    r = requests.get(url)\n\n    # Parse xml tree and extract music section key.\n    tree = ET.fromstring(r.text)\n    for child in tree.findall('Directory'):\n        if child.get('title') == 'Music':\n            return child.get('key')\n\n\ndef update_plex(host, port, token):\n    \"\"\"Sends request to the Plex api to start a library refresh.\n    \"\"\"\n    # Getting section key and build url.\n    section_key = get_music_section(host, port, token)\n    api_endpoint = 'library/sections/{0}/refresh'.format(section_key)\n    api_endpoint = append_token(api_endpoint, token)\n    url = urljoin('http://{0}:{1}'.format(host, port), api_endpoint)\n\n    # Sends request and returns requests object.\n    r = requests.get(url)\n    return r\n\n\ndef append_token(url, token):\n    \"\"\"Appends the Plex Home token to the api call if required.\n    \"\"\"\n    if token:\n        url += '?' + urlencode({'X-Plex-Token': token})\n    return url\n\n\nclass PlexUpdate(BeetsPlugin):\n    def __init__(self):\n        super(PlexUpdate, self).__init__()\n\n        # Adding defaults.\n        config['plex'].add({\n            u'host': u'localhost',\n            u'port': 32400,\n            u'token': u''})\n\n        self.register_listener('database_change', self.listen_for_db_change)\n\n    def listen_for_db_change(self, lib, model):\n        \"\"\"Listens for beets db change and register the update for the end\"\"\"\n        self.register_listener('cli_exit', self.update)\n\n    def update(self, lib):\n        \"\"\"When the client exists try to send refresh request to Plex server.\n        \"\"\"\n        self._log.info('Updating Plex library...')\n\n        # Try to send update request.\n        try:\n            update_plex(\n                config['plex']['host'].get(),\n                config['plex']['port'].get(),\n                config['plex']['token'].get())\n            self._log.info('... started.')\n\n        except requests.exceptions.RequestException:\n            self._log.warning('Update failed.')\n", "path": "beetsplug/plexupdate.py"}], "after_files": [{"content": "\"\"\"Updates an Plex library whenever the beets library is changed.\n\nPlex Home users enter the Plex Token to enable updating.\nPut something like the following in your config.yaml to configure:\n    plex:\n        host: localhost\n        port: 32400\n        token: token\n\"\"\"\nfrom __future__ import (division, absolute_import, print_function,\n                        unicode_literals)\n\nimport requests\nfrom urlparse import urljoin\nfrom urllib import urlencode\nimport xml.etree.ElementTree as ET\nfrom beets import config\nfrom beets.plugins import BeetsPlugin\n\n\ndef get_music_section(host, port, token, library_name):\n    \"\"\"Getting the section key for the music library in Plex.\n    \"\"\"\n    api_endpoint = append_token('library/sections', token)\n    url = urljoin('http://{0}:{1}'.format(host, port), api_endpoint)\n\n    # Sends request.\n    r = requests.get(url)\n\n    # Parse xml tree and extract music section key.\n    tree = ET.fromstring(r.text)\n    for child in tree.findall('Directory'):\n        if child.get('title') == library_name:\n            return child.get('key')\n\n\ndef update_plex(host, port, token, library_name):\n    \"\"\"Sends request to the Plex api to start a library refresh.\n    \"\"\"\n    # Getting section key and build url.\n    section_key = get_music_section(host, port, token, library_name)\n    api_endpoint = 'library/sections/{0}/refresh'.format(section_key)\n    api_endpoint = append_token(api_endpoint, token)\n    url = urljoin('http://{0}:{1}'.format(host, port), api_endpoint)\n\n    # Sends request and returns requests object.\n    r = requests.get(url)\n    return r\n\n\ndef append_token(url, token):\n    \"\"\"Appends the Plex Home token to the api call if required.\n    \"\"\"\n    if token:\n        url += '?' + urlencode({'X-Plex-Token': token})\n    return url\n\n\nclass PlexUpdate(BeetsPlugin):\n    def __init__(self):\n        super(PlexUpdate, self).__init__()\n\n        # Adding defaults.\n        config['plex'].add({\n            u'host': u'localhost',\n            u'port': 32400,\n            u'token': u'',\n            u'library_name': u'Music'})\n\n        self.register_listener('database_change', self.listen_for_db_change)\n\n    def listen_for_db_change(self, lib, model):\n        \"\"\"Listens for beets db change and register the update for the end\"\"\"\n        self.register_listener('cli_exit', self.update)\n\n    def update(self, lib):\n        \"\"\"When the client exists try to send refresh request to Plex server.\n        \"\"\"\n        self._log.info('Updating Plex library...')\n\n        # Try to send update request.\n        try:\n            update_plex(\n                config['plex']['host'].get(),\n                config['plex']['port'].get(),\n                config['plex']['token'].get(),\n                config['plex']['library_name'].get())\n            self._log.info('... started.')\n\n        except requests.exceptions.RequestException:\n            self._log.warning('Update failed.')\n", "path": "beetsplug/plexupdate.py"}]}