prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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.
  
  
  </issue>
  <code>
  [start of beetsplug/plexupdate.py]
  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 of beetsplug/plexupdate.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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:
  
verification_info: {"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"}]}