Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: TypeError: a bytes-like object is required, not 'str'

### INFO
**Python Version**: `3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]`
**Operating System**: `Linux-4.9.0-4-amd64-x86_64-with-debian-9.6`
**Locale**: `UTF-8`
**Branch**: [feature/py3_2](../tree/feature/py3_2)
**Database**: `44.12`
**Commit**: pymedusa/Medusa@ac61f7ad628d70528cab9e8971071d79c0e90a95
**Link to Log**: https://gist.github.com/ee3a4c1fb32f4ed87dc90f4360ceba99
### ERROR
<pre>
2018-12-03 07:31:45 ERROR    SNATCHQUEUE-SNATCH-114801 :: [ac61f7a] Snatch failed! For result: [HorribleSubs].Fairy.Tail.Final.Season.-.286.[1080p].mkv
Traceback (most recent call last):
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/medusa/search/queue.py#L502">medusa/search/queue.py</a>", line 502, in run
    self.success = snatch_episode(result)
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/medusa/search/core.py#L167">medusa/search/core.py</a>", line 167, in snatch_episode
    result_downloaded = client.send_torrent(result)
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/medusa/clients/torrent/generic.py#L246">medusa/clients/torrent/generic.py</a>", line 246, in send_torrent
    if not self._get_auth():
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/medusa/clients/torrent/rtorrent_client.py#L55">medusa/clients/torrent/rtorrent_client.py</a>", line 55, in _get_auth
    self.auth = RTorrent(self.host, None, None, True)
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/lib/rtorrent/__init__.py#L87">lib/rtorrent/__init__.py</a>", line 87, in __init__
    self._verify_conn()
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/lib/rtorrent/__init__.py#L126">lib/rtorrent/__init__.py</a>", line 126, in _verify_conn
    assert 'system.client_version' in self._get_rpc_methods(
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/lib/rtorrent/__init__.py#L164">lib/rtorrent/__init__.py</a>", line 164, in _get_rpc_methods
    return(self._rpc_methods or self._update_rpc_methods())
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/lib/rtorrent/__init__.py#L154">lib/rtorrent/__init__.py</a>", line 154, in _update_rpc_methods
    self._rpc_methods = self._get_conn().system.listMethods()
  File "/usr/lib/python3.5/xmlrpc/client.py", line 1092, in __call__
    return self.__send(self.__name, args)
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/lib/rtorrent/lib/xmlrpc/scgi.py#L195">lib/rtorrent/lib/xmlrpc/scgi.py</a>", line 195, in __request
    verbose=self.__verbose
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/lib/rtorrent/lib/xmlrpc/scgi.py#L104">lib/rtorrent/lib/xmlrpc/scgi.py</a>", line 104, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/opt/medusa/<a href="../blob/ac61f7ad628d70528cab9e8971071d79c0e90a95/lib/rtorrent/lib/xmlrpc/scgi.py#L135">lib/rtorrent/lib/xmlrpc/scgi.py</a>", line 135, in single_request
    sock.send(request_body)
TypeError: a bytes-like object is required, not 'str'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:
#4982 
Fixed

### INFO
**Python Version**: `3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]`
**Operating System**: `Windows-7-6.1.7601-SP1`
**Locale**: `cp1255`
**Branch**: [develop](../tree/develop)
**Database**: `44.12`
**Commit**: pymedusa/Medusa@dd35d00cdf98119e5ca370e28e4278ec06f64dc1
**Link to Log**: https://gist.github.com/2e38cd3afd879f74e9876dfc04a32ad0
### ERROR
<pre>
2018-12-27 01:14:03 ERROR    TORNADO :: [dd35d00] API :: TypeError("a bytes-like object is required, not 'str'")
Traceback (most recent call last):
  File "C:\Medusa\<a href="../blob/dd35d00cdf98119e5ca370e28e4278ec06f64dc1/medusa/server/api/v1/core.py#L142">medusa\server\api\v1\core.py</a>", line 142, in get
    out_dict = _call_dispatcher(args, kwargs)
  File "C:\Medusa\<a href="../blob/dd35d00cdf98119e5ca370e28e4278ec06f64dc1/medusa/server/api/v1/core.py#L197">medusa\server\api\v1\core.py</a>", line 197, in call_dispatcher
    commands = commands.split('|')
TypeError: a bytes-like object is required, not 'str'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


Resolving patch:
diff --git a/medusa/server/api/v1/core.py b/medusa/server/api/v1/core.py
--- a/medusa/server/api/v1/core.py
+++ b/medusa/server/api/v1/core.py
@@ -112,7 +112,7 @@ def __init__(self, *args, **kwargs):
     #     self.set_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
 
     def get(self, *args, **kwargs):
-        kwargs = self.request.arguments
+        kwargs = {k: self.get_arguments(k) for k in self.request.arguments}
         for arg, value in iteritems(kwargs):
             if len(value) == 1:
                 kwargs[arg] = value[0]


Test patch: