We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
qbittorrent: Unable to set the pause for Torrent (new qBit 4.1.0)
### Before submitting your issue:

Enable debug logging in Medusa settings, reproduce the error (be sure to disable after the bug is fixed)

**Branch/Commit:**
77b2091
**OS:**
Linux Mint 18.2 Cinnamon
**What you did:**
I updated to qBittorrent 4.1.0 earlier today, prior to that I was using Qbittorrent 4.0.4, so I figure maybe this is something with Medusa + qBittorrent 4.1.0....I didn't do any manual pause or anything so no idea what it would be pausing or why.
I do *not* have this checked:
Start torrent paused
add .torrent to client but do not start downloading
In the Search Settings -> Torrent Search config in Medusa, in case anybody is wondering.
**What happened:**
Some kind of red error about pausing a torrent with Qbittorrent
**What you expected:**
No error
**Logs:**
```
2018-05-06 17:59:02 INFO     SEARCHQUEUE-DAILY-SEARCH :: [77b2091] Prowl notifications sent.
2018-05-06 17:59:01 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] qbittorrent: Unable to set the pause for Torrent
2018-05-06 17:59:01 INFO     SEARCHQUEUE-DAILY-SEARCH :: [77b2091] qbittorrent: Bad Request
2018-05-06 17:59:00 INFO     SEARCHQUEUE-DAILY-SEARCH :: [77b2091] Downloading (censored) with 13 seeders and 2 leechers and size (censored) MB from (censored)
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `medusa/clients/torrent/qbittorrent_client.py`
Content:
```
1 # coding=utf-8
2 
3 """qBittorrent Client."""
4 
5 from __future__ import unicode_literals
6 
7 import logging
8 
9 from medusa import app
10 from medusa.clients.torrent.generic import GenericClient
11 from medusa.logger.adapters.style import BraceAdapter
12 
13 from requests.auth import HTTPDigestAuth
14 
15 log = BraceAdapter(logging.getLogger(__name__))
16 log.logger.addHandler(logging.NullHandler())
17 
18 
19 class QBittorrentAPI(GenericClient):
20     """qBittorrent API class."""
21 
22     def __init__(self, host=None, username=None, password=None):
23         """Constructor.
24 
25         :param host:
26         :type host: string
27         :param username:
28         :type username: string
29         :param password:
30         :type password: string
31         """
32         super(QBittorrentAPI, self).__init__('qbittorrent', host, username, password)
33         self.url = self.host
34         self.session.auth = HTTPDigestAuth(self.username, self.password)
35 
36     @property
37     def api(self):
38         """Get API version."""
39         try:
40             self.url = '{host}version/api'.format(host=self.host)
41             version = int(self.session.get(self.url, verify=app.TORRENT_VERIFY_CERT).content)
42         except Exception:
43             version = 1
44         return version
45 
46     def _get_auth(self):
47 
48         if self.api > 1:
49             self.url = '{host}login'.format(host=self.host)
50             data = {
51                 'username': self.username,
52                 'password': self.password,
53             }
54             try:
55                 self.response = self.session.post(self.url, data=data)
56             except Exception:
57                 return None
58 
59         else:
60             try:
61                 self.response = self.session.get(self.host, verify=app.TORRENT_VERIFY_CERT)
62                 self.auth = self.response.content
63             except Exception:
64                 return None
65 
66         self.session.cookies = self.response.cookies
67         self.auth = self.response.content
68 
69         return self.auth if not self.response.status_code == 404 else None
70 
71     def _add_torrent_uri(self, result):
72 
73         self.url = '{host}command/download'.format(host=self.host)
74         data = {
75             'urls': result.url,
76         }
77         return self._request(method='post', data=data, cookies=self.session.cookies)
78 
79     def _add_torrent_file(self, result):
80 
81         self.url = '{host}command/upload'.format(host=self.host)
82         files = {
83             'torrents': (
84                 '{result}.torrent'.format(result=result.name),
85                 result.content,
86             ),
87         }
88         return self._request(method='post', files=files, cookies=self.session.cookies)
89 
90     def _set_torrent_label(self, result):
91 
92         label = app.TORRENT_LABEL_ANIME if result.series.is_anime else app.TORRENT_LABEL
93 
94         if self.api > 6 and label:
95             label_key = 'Category' if self.api >= 10 else 'Label'
96             self.url = '{host}command/set{key}'.format(
97                 host=self.host,
98                 key=label_key,
99             )
100             data = {
101                 'hashes': result.hash.lower(),
102                 label_key.lower(): label.replace(' ', '_'),
103             }
104             return self._request(method='post', data=data, cookies=self.session.cookies)
105         return True
106 
107     def _set_torrent_priority(self, result):
108 
109         self.url = '{host}command/{method}Prio'.format(host=self.host,
110                                                        method='increase' if result.priority == 1 else 'decrease')
111         data = {
112             'hashes': result.hash.lower(),
113         }
114         ok = self._request(method='post', data=data, cookies=self.session.cookies)
115 
116         if self.response.status_code == 403:
117             log.info('{name}: Unable to set torrent priority because torrent queueing'
118                      ' is disabled in {name} settings.', {'name': self.name})
119             ok = True
120 
121         return ok
122 
123     def _set_torrent_pause(self, result):
124         self.url = '{host}command/{state}'.format(host=self.host,
125                                                   state='pause' if app.TORRENT_PAUSED else 'resume')
126         data = {
127             'hash': result.hash,
128         }
129         return self._request(method='post', data=data, cookies=self.session.cookies)
130 
131     def remove_torrent(self, info_hash):
132         """Remove torrent from client using given info_hash.
133 
134         :param info_hash:
135         :type info_hash: string
136         :return
137         :rtype: bool
138         """
139         self.url = '{host}command/deletePerm'.format(host=self.host)
140         data = {
141             'hashes': info_hash.lower(),
142         }
143 
144         return self._request(method='post', data=data, cookies=self.session.cookies)
145 
146 
147 api = QBittorrentAPI
148
```
--- 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/medusa/clients/torrent/qbittorrent_client.py b/medusa/clients/torrent/qbittorrent_client.py
--- a/medusa/clients/torrent/qbittorrent_client.py
+++ b/medusa/clients/torrent/qbittorrent_client.py
@@ -123,8 +123,9 @@
     def _set_torrent_pause(self, result):
         self.url = '{host}command/{state}'.format(host=self.host,
                                                   state='pause' if app.TORRENT_PAUSED else 'resume')
+        hashes_key = 'hashes' if self.api >= 18 else 'hash'
         data = {
-            'hash': result.hash,
+            hashes_key: result.hash.lower(),
         }
         return self._request(method='post', data=data, cookies=self.session.cookies)

{"golden_diff": "diff --git a/medusa/clients/torrent/qbittorrent_client.py b/medusa/clients/torrent/qbittorrent_client.py\n--- a/medusa/clients/torrent/qbittorrent_client.py\n+++ b/medusa/clients/torrent/qbittorrent_client.py\n@@ -123,8 +123,9 @@\n     def _set_torrent_pause(self, result):\n         self.url = '{host}command/{state}'.format(host=self.host,\n                                                   state='pause' if app.TORRENT_PAUSED else 'resume')\n+        hashes_key = 'hashes' if self.api >= 18 else 'hash'\n         data = {\n-            'hash': result.hash,\n+            hashes_key: result.hash.lower(),\n         }\n         return self._request(method='post', data=data, cookies=self.session.cookies)\n", "issue": "qbittorrent: Unable to set the pause for Torrent (new qBit 4.1.0)\n### Before submitting your issue:\r\n\r\nEnable debug logging in Medusa settings, reproduce the error (be sure to disable after the bug is fixed)\r\n\r\n**Branch/Commit:**\r\n77b2091\r\n**OS:**\r\nLinux Mint 18.2 Cinnamon\r\n**What you did:**\r\nI updated to qBittorrent 4.1.0 earlier today, prior to that I was using Qbittorrent 4.0.4, so I figure maybe this is something with Medusa + qBittorrent 4.1.0....I didn't do any manual pause or anything so no idea what it would be pausing or why.\r\nI do *not* have this checked:\r\nStart torrent paused\r\nadd .torrent to client but do not start downloading\r\nIn the Search Settings -> Torrent Search config in Medusa, in case anybody is wondering.\r\n**What happened:**\r\nSome kind of red error about pausing a torrent with Qbittorrent\r\n**What you expected:**\r\nNo error\r\n**Logs:**\r\n```\r\n2018-05-06 17:59:02 INFO     SEARCHQUEUE-DAILY-SEARCH :: [77b2091] Prowl notifications sent.\r\n2018-05-06 17:59:01 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [77b2091] qbittorrent: Unable to set the pause for Torrent\r\n2018-05-06 17:59:01 INFO     SEARCHQUEUE-DAILY-SEARCH :: [77b2091] qbittorrent: Bad Request\r\n2018-05-06 17:59:00 INFO     SEARCHQUEUE-DAILY-SEARCH :: [77b2091] Downloading (censored) with 13 seeders and 2 leechers and size (censored) MB from (censored)\r\n```\r\n\n", "before_files": [{"content": "# coding=utf-8\n\n\"\"\"qBittorrent Client.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport logging\n\nfrom medusa import app\nfrom medusa.clients.torrent.generic import GenericClient\nfrom medusa.logger.adapters.style import BraceAdapter\n\nfrom requests.auth import HTTPDigestAuth\n\nlog = BraceAdapter(logging.getLogger(__name__))\nlog.logger.addHandler(logging.NullHandler())\n\n\nclass QBittorrentAPI(GenericClient):\n    \"\"\"qBittorrent API class.\"\"\"\n\n    def __init__(self, host=None, username=None, password=None):\n        \"\"\"Constructor.\n\n        :param host:\n        :type host: string\n        :param username:\n        :type username: string\n        :param password:\n        :type password: string\n        \"\"\"\n        super(QBittorrentAPI, self).__init__('qbittorrent', host, username, password)\n        self.url = self.host\n        self.session.auth = HTTPDigestAuth(self.username, self.password)\n\n    @property\n    def api(self):\n        \"\"\"Get API version.\"\"\"\n        try:\n            self.url = '{host}version/api'.format(host=self.host)\n            version = int(self.session.get(self.url, verify=app.TORRENT_VERIFY_CERT).content)\n        except Exception:\n            version = 1\n        return version\n\n    def _get_auth(self):\n\n        if self.api > 1:\n            self.url = '{host}login'.format(host=self.host)\n            data = {\n                'username': self.username,\n                'password': self.password,\n            }\n            try:\n                self.response = self.session.post(self.url, data=data)\n            except Exception:\n                return None\n\n        else:\n            try:\n                self.response = self.session.get(self.host, verify=app.TORRENT_VERIFY_CERT)\n                self.auth = self.response.content\n            except Exception:\n                return None\n\n        self.session.cookies = self.response.cookies\n        self.auth = self.response.content\n\n        return self.auth if not self.response.status_code == 404 else None\n\n    def _add_torrent_uri(self, result):\n\n        self.url = '{host}command/download'.format(host=self.host)\n        data = {\n            'urls': result.url,\n        }\n        return self._request(method='post', data=data, cookies=self.session.cookies)\n\n    def _add_torrent_file(self, result):\n\n        self.url = '{host}command/upload'.format(host=self.host)\n        files = {\n            'torrents': (\n                '{result}.torrent'.format(result=result.name),\n                result.content,\n            ),\n        }\n        return self._request(method='post', files=files, cookies=self.session.cookies)\n\n    def _set_torrent_label(self, result):\n\n        label = app.TORRENT_LABEL_ANIME if result.series.is_anime else app.TORRENT_LABEL\n\n        if self.api > 6 and label:\n            label_key = 'Category' if self.api >= 10 else 'Label'\n            self.url = '{host}command/set{key}'.format(\n                host=self.host,\n                key=label_key,\n            )\n            data = {\n                'hashes': result.hash.lower(),\n                label_key.lower(): label.replace(' ', '_'),\n            }\n            return self._request(method='post', data=data, cookies=self.session.cookies)\n        return True\n\n    def _set_torrent_priority(self, result):\n\n        self.url = '{host}command/{method}Prio'.format(host=self.host,\n                                                       method='increase' if result.priority == 1 else 'decrease')\n        data = {\n            'hashes': result.hash.lower(),\n        }\n        ok = self._request(method='post', data=data, cookies=self.session.cookies)\n\n        if self.response.status_code == 403:\n            log.info('{name}: Unable to set torrent priority because torrent queueing'\n                     ' is disabled in {name} settings.', {'name': self.name})\n            ok = True\n\n        return ok\n\n    def _set_torrent_pause(self, result):\n        self.url = '{host}command/{state}'.format(host=self.host,\n                                                  state='pause' if app.TORRENT_PAUSED else 'resume')\n        data = {\n            'hash': result.hash,\n        }\n        return self._request(method='post', data=data, cookies=self.session.cookies)\n\n    def remove_torrent(self, info_hash):\n        \"\"\"Remove torrent from client using given info_hash.\n\n        :param info_hash:\n        :type info_hash: string\n        :return\n        :rtype: bool\n        \"\"\"\n        self.url = '{host}command/deletePerm'.format(host=self.host)\n        data = {\n            'hashes': info_hash.lower(),\n        }\n\n        return self._request(method='post', data=data, cookies=self.session.cookies)\n\n\napi = QBittorrentAPI\n", "path": "medusa/clients/torrent/qbittorrent_client.py"}], "after_files": [{"content": "# coding=utf-8\n\n\"\"\"qBittorrent Client.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport logging\n\nfrom medusa import app\nfrom medusa.clients.torrent.generic import GenericClient\nfrom medusa.logger.adapters.style import BraceAdapter\n\nfrom requests.auth import HTTPDigestAuth\n\nlog = BraceAdapter(logging.getLogger(__name__))\nlog.logger.addHandler(logging.NullHandler())\n\n\nclass QBittorrentAPI(GenericClient):\n    \"\"\"qBittorrent API class.\"\"\"\n\n    def __init__(self, host=None, username=None, password=None):\n        \"\"\"Constructor.\n\n        :param host:\n        :type host: string\n        :param username:\n        :type username: string\n        :param password:\n        :type password: string\n        \"\"\"\n        super(QBittorrentAPI, self).__init__('qbittorrent', host, username, password)\n        self.url = self.host\n        self.session.auth = HTTPDigestAuth(self.username, self.password)\n\n    @property\n    def api(self):\n        \"\"\"Get API version.\"\"\"\n        try:\n            self.url = '{host}version/api'.format(host=self.host)\n            version = int(self.session.get(self.url, verify=app.TORRENT_VERIFY_CERT).content)\n        except Exception:\n            version = 1\n        return version\n\n    def _get_auth(self):\n\n        if self.api > 1:\n            self.url = '{host}login'.format(host=self.host)\n            data = {\n                'username': self.username,\n                'password': self.password,\n            }\n            try:\n                self.response = self.session.post(self.url, data=data)\n            except Exception:\n                return None\n\n        else:\n            try:\n                self.response = self.session.get(self.host, verify=app.TORRENT_VERIFY_CERT)\n                self.auth = self.response.content\n            except Exception:\n                return None\n\n        self.session.cookies = self.response.cookies\n        self.auth = self.response.content\n\n        return self.auth if not self.response.status_code == 404 else None\n\n    def _add_torrent_uri(self, result):\n\n        self.url = '{host}command/download'.format(host=self.host)\n        data = {\n            'urls': result.url,\n        }\n        return self._request(method='post', data=data, cookies=self.session.cookies)\n\n    def _add_torrent_file(self, result):\n\n        self.url = '{host}command/upload'.format(host=self.host)\n        files = {\n            'torrents': (\n                '{result}.torrent'.format(result=result.name),\n                result.content,\n            ),\n        }\n        return self._request(method='post', files=files, cookies=self.session.cookies)\n\n    def _set_torrent_label(self, result):\n\n        label = app.TORRENT_LABEL_ANIME if result.series.is_anime else app.TORRENT_LABEL\n\n        if self.api > 6 and label:\n            label_key = 'Category' if self.api >= 10 else 'Label'\n            self.url = '{host}command/set{key}'.format(\n                host=self.host,\n                key=label_key,\n            )\n            data = {\n                'hashes': result.hash.lower(),\n                label_key.lower(): label.replace(' ', '_'),\n            }\n            return self._request(method='post', data=data, cookies=self.session.cookies)\n        return True\n\n    def _set_torrent_priority(self, result):\n\n        self.url = '{host}command/{method}Prio'.format(host=self.host,\n                                                       method='increase' if result.priority == 1 else 'decrease')\n        data = {\n            'hashes': result.hash.lower(),\n        }\n        ok = self._request(method='post', data=data, cookies=self.session.cookies)\n\n        if self.response.status_code == 403:\n            log.info('{name}: Unable to set torrent priority because torrent queueing'\n                     ' is disabled in {name} settings.', {'name': self.name})\n            ok = True\n\n        return ok\n\n    def _set_torrent_pause(self, result):\n        self.url = '{host}command/{state}'.format(host=self.host,\n                                                  state='pause' if app.TORRENT_PAUSED else 'resume')\n        hashes_key = 'hashes' if self.api >= 18 else 'hash'\n        data = {\n            hashes_key: result.hash.lower(),\n        }\n        return self._request(method='post', data=data, cookies=self.session.cookies)\n\n    def remove_torrent(self, info_hash):\n        \"\"\"Remove torrent from client using given info_hash.\n\n        :param info_hash:\n        :type info_hash: string\n        :return\n        :rtype: bool\n        \"\"\"\n        self.url = '{host}command/deletePerm'.format(host=self.host)\n        data = {\n            'hashes': info_hash.lower(),\n        }\n\n        return self._request(method='post', data=data, cookies=self.session.cookies)\n\n\napi = QBittorrentAPI\n", "path": "medusa/clients/torrent/qbittorrent_client.py"}]}