prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Problem with sabnzbd after upgrade to version 2.0.5
  Hi,
  
  Last night I upgraded to version 2.0.5 from 1.2.521. I haven't made any config changes. Everything seems to work except adding downloads to sabnzbd. Reverting back to version 1.2.521 made everything work again.
  
  ```
  2016-04-27 07:30 CRITICAL sabnzbd       usenet          Failed to use sabnzbd. Requested http://sabnzbd:8080/sabnzbd/api?nzbname=REL_NAME&apikey=11111&mode=addurl&name=URL_THAT_WORKS
  2016-04-27 07:30 CRITICAL sabnzbd       usenet          Result was: 'Task' object has no attribute 'get'
  2016-04-27 07:30 ERROR    entry         usenet          Failed REL_NAME (sabnzbd unreachable) 
  ```
  
  Manually clicking the url does add the nzb to sabznbd. 
  
  This runs in a FreeBSD 10.3 jail using Python 2.7.11 installed and upgraded using pip.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `flexget/plugins/output/sabnzbd.py`
  Content:
  ```
  1 from __future__ import unicode_literals, division, absolute_import
  2 from builtins import *
  3 from future.moves.urllib.parse import urlencode
  4 
  5 import logging
  6 
  7 from flexget import plugin
  8 from flexget.event import event
  9 
  10 log = logging.getLogger('sabnzbd')
  11 
  12 
  13 class OutputSabnzbd(object):
  14     """
  15     Example::
  16 
  17       sabnzbd:
  18         apikey: 123456
  19         url: http://localhost/sabnzbd/api?
  20         category: movies
  21 
  22     All parameters::
  23 
  24       sabnzbd:
  25         apikey: ...
  26         url: ...
  27         category: ...
  28         script: ...
  29         pp: ...
  30         priority: ...
  31     """
  32     schema = {
  33         'type': 'object',
  34         'properties': {
  35             'key': {'type': 'string'},
  36             'url': {'type': 'string', 'format': 'url'},
  37             'category': {'type': 'string'},
  38             'script': {'type': 'string'},
  39             'pp': {'type': 'string'},
  40             'priority': {'type': 'integer'},
  41             'password': {'type': 'string'},
  42             'username': {'type': 'string'},
  43         },
  44         'required': ['key', 'url'],
  45         'additionalProperties': False,
  46     }
  47 
  48     def get_params(self, config):
  49         params = {}
  50         if 'key' in config:
  51             params['apikey'] = config['key']
  52         if 'category' in config:
  53             params['cat'] = '%s' % config['category']
  54         if 'script' in config:
  55             params['script'] = config['script']
  56         if 'pp' in config:
  57             params['pp'] = config['pp']
  58         if 'priority' in config:
  59             params['priority'] = config['priority']
  60         if 'username' in config:
  61             params['ma_username'] = config['username']
  62         if 'password' in config:
  63             params['ma_password'] = config['password']
  64         params['mode'] = 'addurl'
  65         return params
  66 
  67     def on_task_output(self, task, config):
  68         for entry in task.accepted:
  69             if task.options.test:
  70                 log.info('Would add into sabnzbd: %s' % entry['title'])
  71                 continue
  72 
  73             params = self.get_params(config)
  74             # allow overriding the category
  75             if 'category' in entry:
  76                 # Dirty hack over the next few lines to strip out non-ascii
  77                 # chars. We're going to urlencode this, which causes
  78                 # serious issues in python2.x if it's not ascii input.
  79                 params['cat'] = ''.join([x for x in entry['category'] if ord(x) < 128])
  80             params['name'] = ''.join([x for x in entry['url'] if ord(x) < 128])
  81             # add cleaner nzb name (undocumented api feature)
  82             params['nzbname'] = ''.join([x for x in entry['title'] if ord(x) < 128])
  83 
  84             request_url = config['url'] + urlencode(params)
  85             log.debug('request_url: %s' % request_url)
  86             try:
  87                 response = task.get(request_url)
  88             except Exception as e:
  89                 log.critical('Failed to use sabnzbd. Requested %s' % request_url)
  90                 log.critical('Result was: %s' % e)
  91                 entry.fail('sabnzbd unreachable')
  92                 if task.options.debug:
  93                     log.exception(e)
  94                 continue
  95 
  96             if 'error' in response.text.lower():
  97                 entry.fail(response.text.replace('\n', ''))
  98             else:
  99                 log.info('Added `%s` to SABnzbd' % (entry['title']))
  100 
  101 
  102 @event('plugin.register')
  103 def register_plugin():
  104     plugin.register(OutputSabnzbd, 'sabnzbd', api_ver=2)
  105
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/flexget/plugins/output/sabnzbd.py b/flexget/plugins/output/sabnzbd.py
  --- a/flexget/plugins/output/sabnzbd.py
  +++ b/flexget/plugins/output/sabnzbd.py
  @@ -6,6 +6,7 @@
   
   from flexget import plugin
   from flexget.event import event
  +from requests import RequestException
   
   log = logging.getLogger('sabnzbd')
   
  @@ -84,10 +85,10 @@
               request_url = config['url'] + urlencode(params)
               log.debug('request_url: %s' % request_url)
               try:
  -                response = task.get(request_url)
  -            except Exception as e:
  +                response = task.requests.get(request_url)
  +            except RequestException as e:
                   log.critical('Failed to use sabnzbd. Requested %s' % request_url)
  -                log.critical('Result was: %s' % e)
  +                log.critical('Result was: %s' % e.args[0])
                   entry.fail('sabnzbd unreachable')
                   if task.options.debug:
                       log.exception(e)
  
verification_info: {"golden_diff": "diff --git a/flexget/plugins/output/sabnzbd.py b/flexget/plugins/output/sabnzbd.py\n--- a/flexget/plugins/output/sabnzbd.py\n+++ b/flexget/plugins/output/sabnzbd.py\n@@ -6,6 +6,7 @@\n \n from flexget import plugin\n from flexget.event import event\n+from requests import RequestException\n \n log = logging.getLogger('sabnzbd')\n \n@@ -84,10 +85,10 @@\n             request_url = config['url'] + urlencode(params)\n             log.debug('request_url: %s' % request_url)\n             try:\n-                response = task.get(request_url)\n-            except Exception as e:\n+                response = task.requests.get(request_url)\n+            except RequestException as e:\n                 log.critical('Failed to use sabnzbd. Requested %s' % request_url)\n-                log.critical('Result was: %s' % e)\n+                log.critical('Result was: %s' % e.args[0])\n                 entry.fail('sabnzbd unreachable')\n                 if task.options.debug:\n                     log.exception(e)\n", "issue": "Problem with sabnzbd after upgrade to version 2.0.5\nHi,\n\nLast night I upgraded to version 2.0.5 from 1.2.521. I haven't made any config changes. Everything seems to work except adding downloads to sabnzbd. Reverting back to version 1.2.521 made everything work again.\n\n```\n2016-04-27 07:30 CRITICAL sabnzbd       usenet          Failed to use sabnzbd. Requested http://sabnzbd:8080/sabnzbd/api?nzbname=REL_NAME&apikey=11111&mode=addurl&name=URL_THAT_WORKS\n2016-04-27 07:30 CRITICAL sabnzbd       usenet          Result was: 'Task' object has no attribute 'get'\n2016-04-27 07:30 ERROR    entry         usenet          Failed REL_NAME (sabnzbd unreachable) \n```\n\nManually clicking the url does add the nzb to sabznbd. \n\nThis runs in a FreeBSD 10.3 jail using Python 2.7.11 installed and upgraded using pip.\n\n", "before_files": [{"content": "from __future__ import unicode_literals, division, absolute_import\nfrom builtins import *\nfrom future.moves.urllib.parse import urlencode\n\nimport logging\n\nfrom flexget import plugin\nfrom flexget.event import event\n\nlog = logging.getLogger('sabnzbd')\n\n\nclass OutputSabnzbd(object):\n    \"\"\"\n    Example::\n\n      sabnzbd:\n        apikey: 123456\n        url: http://localhost/sabnzbd/api?\n        category: movies\n\n    All parameters::\n\n      sabnzbd:\n        apikey: ...\n        url: ...\n        category: ...\n        script: ...\n        pp: ...\n        priority: ...\n    \"\"\"\n    schema = {\n        'type': 'object',\n        'properties': {\n            'key': {'type': 'string'},\n            'url': {'type': 'string', 'format': 'url'},\n            'category': {'type': 'string'},\n            'script': {'type': 'string'},\n            'pp': {'type': 'string'},\n            'priority': {'type': 'integer'},\n            'password': {'type': 'string'},\n            'username': {'type': 'string'},\n        },\n        'required': ['key', 'url'],\n        'additionalProperties': False,\n    }\n\n    def get_params(self, config):\n        params = {}\n        if 'key' in config:\n            params['apikey'] = config['key']\n        if 'category' in config:\n            params['cat'] = '%s' % config['category']\n        if 'script' in config:\n            params['script'] = config['script']\n        if 'pp' in config:\n            params['pp'] = config['pp']\n        if 'priority' in config:\n            params['priority'] = config['priority']\n        if 'username' in config:\n            params['ma_username'] = config['username']\n        if 'password' in config:\n            params['ma_password'] = config['password']\n        params['mode'] = 'addurl'\n        return params\n\n    def on_task_output(self, task, config):\n        for entry in task.accepted:\n            if task.options.test:\n                log.info('Would add into sabnzbd: %s' % entry['title'])\n                continue\n\n            params = self.get_params(config)\n            # allow overriding the category\n            if 'category' in entry:\n                # Dirty hack over the next few lines to strip out non-ascii\n                # chars. We're going to urlencode this, which causes\n                # serious issues in python2.x if it's not ascii input.\n                params['cat'] = ''.join([x for x in entry['category'] if ord(x) < 128])\n            params['name'] = ''.join([x for x in entry['url'] if ord(x) < 128])\n            # add cleaner nzb name (undocumented api feature)\n            params['nzbname'] = ''.join([x for x in entry['title'] if ord(x) < 128])\n\n            request_url = config['url'] + urlencode(params)\n            log.debug('request_url: %s' % request_url)\n            try:\n                response = task.get(request_url)\n            except Exception as e:\n                log.critical('Failed to use sabnzbd. Requested %s' % request_url)\n                log.critical('Result was: %s' % e)\n                entry.fail('sabnzbd unreachable')\n                if task.options.debug:\n                    log.exception(e)\n                continue\n\n            if 'error' in response.text.lower():\n                entry.fail(response.text.replace('\\n', ''))\n            else:\n                log.info('Added `%s` to SABnzbd' % (entry['title']))\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(OutputSabnzbd, 'sabnzbd', api_ver=2)\n", "path": "flexget/plugins/output/sabnzbd.py"}], "after_files": [{"content": "from __future__ import unicode_literals, division, absolute_import\nfrom builtins import *\nfrom future.moves.urllib.parse import urlencode\n\nimport logging\n\nfrom flexget import plugin\nfrom flexget.event import event\nfrom requests import RequestException\n\nlog = logging.getLogger('sabnzbd')\n\n\nclass OutputSabnzbd(object):\n    \"\"\"\n    Example::\n\n      sabnzbd:\n        apikey: 123456\n        url: http://localhost/sabnzbd/api?\n        category: movies\n\n    All parameters::\n\n      sabnzbd:\n        apikey: ...\n        url: ...\n        category: ...\n        script: ...\n        pp: ...\n        priority: ...\n    \"\"\"\n    schema = {\n        'type': 'object',\n        'properties': {\n            'key': {'type': 'string'},\n            'url': {'type': 'string', 'format': 'url'},\n            'category': {'type': 'string'},\n            'script': {'type': 'string'},\n            'pp': {'type': 'string'},\n            'priority': {'type': 'integer'},\n            'password': {'type': 'string'},\n            'username': {'type': 'string'},\n        },\n        'required': ['key', 'url'],\n        'additionalProperties': False,\n    }\n\n    def get_params(self, config):\n        params = {}\n        if 'key' in config:\n            params['apikey'] = config['key']\n        if 'category' in config:\n            params['cat'] = '%s' % config['category']\n        if 'script' in config:\n            params['script'] = config['script']\n        if 'pp' in config:\n            params['pp'] = config['pp']\n        if 'priority' in config:\n            params['priority'] = config['priority']\n        if 'username' in config:\n            params['ma_username'] = config['username']\n        if 'password' in config:\n            params['ma_password'] = config['password']\n        params['mode'] = 'addurl'\n        return params\n\n    def on_task_output(self, task, config):\n        for entry in task.accepted:\n            if task.options.test:\n                log.info('Would add into sabnzbd: %s' % entry['title'])\n                continue\n\n            params = self.get_params(config)\n            # allow overriding the category\n            if 'category' in entry:\n                # Dirty hack over the next few lines to strip out non-ascii\n                # chars. We're going to urlencode this, which causes\n                # serious issues in python2.x if it's not ascii input.\n                params['cat'] = ''.join([x for x in entry['category'] if ord(x) < 128])\n            params['name'] = ''.join([x for x in entry['url'] if ord(x) < 128])\n            # add cleaner nzb name (undocumented api feature)\n            params['nzbname'] = ''.join([x for x in entry['title'] if ord(x) < 128])\n\n            request_url = config['url'] + urlencode(params)\n            log.debug('request_url: %s' % request_url)\n            try:\n                response = task.requests.get(request_url)\n            except RequestException as e:\n                log.critical('Failed to use sabnzbd. Requested %s' % request_url)\n                log.critical('Result was: %s' % e.args[0])\n                entry.fail('sabnzbd unreachable')\n                if task.options.debug:\n                    log.exception(e)\n                continue\n\n            if 'error' in response.text.lower():\n                entry.fail(response.text.replace('\\n', ''))\n            else:\n                log.info('Added `%s` to SABnzbd' % (entry['title']))\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(OutputSabnzbd, 'sabnzbd', api_ver=2)\n", "path": "flexget/plugins/output/sabnzbd.py"}]}