We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[APP SUBMITTED]: AttributeError: 'BraceAdapter' object has no attribute 'DEBUG'
### INFO
**Python Version**: `2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.15063`
**Locale**: `cp1252`
**Branch**: [develop](../tree/develop)
**Database**: `44.8`
**Commit**: pymedusa/Medusa@a2aaaf4dd43c018019a67fe1a27074b124681fa4
**Link to Log**: https://gist.github.com/66f5f5fc2f3cc2fbaec732d8d994335e
### ERROR
<pre>
2017-05-12 08:29:52 ERROR    SEARCHQUEUE-FORCED-309269 :: [Rarbg] :: [a2aaaf4] Unknown exception while searching Rarbg. Error: "'BraceAdapter' object has no attribute 'DEBUG'"
Traceback (most recent call last):
  File "C:\Medusa\medusa\search\core.py", line 547, in search_providers
    down_cur_quality, manual_search, manual_search_type)
  File "C:\Medusa\medusa\providers\generic_provider.py", line 207, in find_search_results
    items_list += self.search(search_string, ep_obj=episode)
  File "C:\Medusa\medusa\providers\torrent\json\rarbg.py", line 136, in search
    log_level = log.DEBUG
AttributeError: 'BraceAdapter' object has no attribute 'DEBUG'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators

--- 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/providers/torrent/json/rarbg.py`
Content:
```
1 # coding=utf-8
2 
3 """Provider code for RARBG."""
4 
5 from __future__ import unicode_literals
6 
7 import datetime
8 import logging
9 import time
10 import traceback
11 
12 from medusa import (
13     app,
14     tv,
15 )
16 from medusa.helper.common import convert_size, try_int
17 from medusa.logger.adapters.style import BraceAdapter
18 from medusa.providers.torrent.torrent_provider import TorrentProvider
19 
20 log = BraceAdapter(logging.getLogger(__name__))
21 log.logger.addHandler(logging.NullHandler())
22 
23 
24 class RarbgProvider(TorrentProvider):
25     """RARBG Torrent provider."""
26 
27     def __init__(self):
28         """Initialize the class."""
29         super(self.__class__, self).__init__('Rarbg')
30 
31         # Credentials
32         self.public = True
33         self.token = None
34         self.token_expires = None
35 
36         # URLs
37         self.url = 'https://rarbg.com'  # Spec: https://torrentapi.org/apidocs_v2.txt
38         self.urls = {
39             'api': 'http://torrentapi.org/pubapi_v2.php',
40         }
41 
42         # Proper Strings
43         self.proper_strings = ['{{PROPER|REPACK|REAL|RERIP}}']
44 
45         # Miscellaneous Options
46         self.ranked = None
47         self.sorting = None
48 
49         # Torrent Stats
50         self.minseed = None
51         self.minleech = None
52 
53         # Cache
54         self.cache = tv.Cache(self, min_time=10)  # only poll RARBG every 10 minutes max
55 
56     def search(self, search_strings, age=0, ep_obj=None):
57         """
58         Search a provider and parse the results.
59 
60         :param search_strings: A dict with mode (key) and the search value (value)
61         :param age: Not used
62         :param ep_obj: Not used
63         :returns: A list of search results (structure)
64         """
65         results = []
66         if not self.login():
67             return results
68 
69         # Search Params
70         search_params = {
71             'app_id': app.RARBG_APPID,
72             'category': 'tv',
73             'min_seeders': try_int(self.minseed),
74             'min_leechers': try_int(self.minleech),
75             'limit': 100,
76             'format': 'json_extended',
77             'ranked': try_int(self.ranked),
78             'token': self.token,
79             'sort': 'last',
80             'mode': 'list',
81         }
82 
83         for mode in search_strings:
84             log.debug('Search mode: {0}', mode)
85 
86             if mode == 'RSS':
87                 search_params['search_string'] = None
88                 search_params['search_tvdb'] = None
89             else:
90                 search_params['sort'] = self.sorting if self.sorting else 'seeders'
91                 search_params['mode'] = 'search'
92                 search_params['search_tvdb'] = self._get_tvdb_id()
93 
94             for search_string in search_strings[mode]:
95                 if mode != 'RSS':
96                     log.debug('Search string: {search}',
97                               {'search': search_string})
98                     if self.ranked:
99                         log.debug('Searching only ranked torrents')
100 
101                 search_params['search_string'] = search_string
102 
103                 # Check if token is still valid before search
104                 if not self.login():
105                     continue
106 
107                 # Maximum requests allowed are 1req/2sec
108                 # Changing to 5 because of server clock desync
109                 time.sleep(5)
110 
111                 search_url = self.urls['api']
112                 response = self.get_url(search_url, params=search_params, returns='response')
113                 if not response or not response.content:
114                     log.debug('No data returned from provider')
115                     continue
116 
117                 try:
118                     jdata = response.json()
119                 except ValueError:
120                     log.debug('No data returned from provider')
121                     continue
122 
123                 error = jdata.get('error')
124                 error_code = jdata.get('error_code')
125                 if error:
126                     # List of errors: https://github.com/rarbg/torrentapi/issues/1#issuecomment-114763312
127                     if error_code == 5:
128                         # 5 = Too many requests per second
129                         log_level = log.INFO
130                     elif error_code not in (4, 8, 10, 12, 14, 20):
131                         # 4 = Invalid token. Use get_token for a new one!
132                         # 8, 10, 12, 14 = Cant find * in database. Are you sure this * exists?
133                         # 20 = No results found
134                         log_level = log.WARNING
135                     else:
136                         log_level = log.DEBUG
137                     log.log(log_level, '{msg} Code: {code}', {'msg': error, 'code': error_code})
138                     continue
139 
140                 results += self.parse(jdata, mode)
141 
142         return results
143 
144     def parse(self, data, mode):
145         """
146         Parse search results for items.
147 
148         :param data: The raw response from a search
149         :param mode: The current mode used to search, e.g. RSS
150 
151         :return: A list of items found
152         """
153         items = []
154 
155         torrent_rows = data.get('torrent_results', {})
156 
157         if not torrent_rows:
158             log.debug('Data returned from provider does not contain any torrents')
159             return items
160 
161         for row in torrent_rows:
162             try:
163                 title = row.pop('title')
164                 download_url = row.pop('download') + self._custom_trackers
165                 if not all([title, download_url]):
166                     continue
167 
168                 seeders = row.pop('seeders')
169                 leechers = row.pop('leechers')
170 
171                 # Filter unseeded torrent
172                 if seeders < min(self.minseed, 1):
173                     if mode != 'RSS':
174                         log.debug("Discarding torrent because it doesn't meet the"
175                                   " minimum seeders: {0}. Seeders: {1}",
176                                   title, seeders)
177                     continue
178 
179                 torrent_size = row.pop('size', -1)
180                 size = convert_size(torrent_size) or -1
181 
182                 pubdate_raw = row.pop('pubdate')
183                 pubdate = self._parse_pubdate(pubdate_raw)
184 
185                 item = {
186                     'title': title,
187                     'link': download_url,
188                     'size': size,
189                     'seeders': seeders,
190                     'leechers': leechers,
191                     'pubdate': pubdate,
192                 }
193                 if mode != 'RSS':
194                     log.debug('Found result: {0} with {1} seeders and {2} leechers',
195                               title, seeders, leechers)
196 
197                 items.append(item)
198             except (AttributeError, TypeError, KeyError, ValueError, IndexError):
199                 log.error('Failed parsing provider. Traceback: {0!r}',
200                           traceback.format_exc())
201 
202         return items
203 
204     def login(self):
205         """Login method used for logging in before doing search and torrent downloads."""
206         if self.token and self.token_expires and datetime.datetime.now() < self.token_expires:
207             return True
208 
209         login_params = {
210             'get_token': 'get_token',
211             'format': 'json',
212             'app_id': app.RARBG_APPID,
213         }
214 
215         response = self.get_url(self.urls['api'], params=login_params, returns='json')
216         if not response:
217             log.warning('Unable to connect to provider')
218             return False
219 
220         self.token = response.get('token')
221         self.token_expires = datetime.datetime.now() + datetime.timedelta(minutes=14) if self.token else None
222         return self.token is not None
223 
224 
225 provider = RarbgProvider()
226
```
--- 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/providers/torrent/json/rarbg.py b/medusa/providers/torrent/json/rarbg.py
--- a/medusa/providers/torrent/json/rarbg.py
+++ b/medusa/providers/torrent/json/rarbg.py
@@ -126,14 +126,14 @@
                     # List of errors: https://github.com/rarbg/torrentapi/issues/1#issuecomment-114763312
                     if error_code == 5:
                         # 5 = Too many requests per second
-                        log_level = log.INFO
+                        log_level = logging.INFO
                     elif error_code not in (4, 8, 10, 12, 14, 20):
                         # 4 = Invalid token. Use get_token for a new one!
                         # 8, 10, 12, 14 = Cant find * in database. Are you sure this * exists?
                         # 20 = No results found
-                        log_level = log.WARNING
+                        log_level = logging.WARNING
                     else:
-                        log_level = log.DEBUG
+                        log_level = logging.DEBUG
                     log.log(log_level, '{msg} Code: {code}', {'msg': error, 'code': error_code})
                     continue

{"golden_diff": "diff --git a/medusa/providers/torrent/json/rarbg.py b/medusa/providers/torrent/json/rarbg.py\n--- a/medusa/providers/torrent/json/rarbg.py\n+++ b/medusa/providers/torrent/json/rarbg.py\n@@ -126,14 +126,14 @@\n                     # List of errors: https://github.com/rarbg/torrentapi/issues/1#issuecomment-114763312\n                     if error_code == 5:\n                         # 5 = Too many requests per second\n-                        log_level = log.INFO\n+                        log_level = logging.INFO\n                     elif error_code not in (4, 8, 10, 12, 14, 20):\n                         # 4 = Invalid token. Use get_token for a new one!\n                         # 8, 10, 12, 14 = Cant find * in database. Are you sure this * exists?\n                         # 20 = No results found\n-                        log_level = log.WARNING\n+                        log_level = logging.WARNING\n                     else:\n-                        log_level = log.DEBUG\n+                        log_level = logging.DEBUG\n                     log.log(log_level, '{msg} Code: {code}', {'msg': error, 'code': error_code})\n                     continue\n", "issue": "[APP SUBMITTED]: AttributeError: 'BraceAdapter' object has no attribute 'DEBUG'\n### INFO\n**Python Version**: `2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]`\n**Operating System**: `Windows-10-10.0.15063`\n**Locale**: `cp1252`\n**Branch**: [develop](../tree/develop)\n**Database**: `44.8`\n**Commit**: pymedusa/Medusa@a2aaaf4dd43c018019a67fe1a27074b124681fa4\n**Link to Log**: https://gist.github.com/66f5f5fc2f3cc2fbaec732d8d994335e\n### ERROR\n<pre>\n2017-05-12 08:29:52 ERROR    SEARCHQUEUE-FORCED-309269 :: [Rarbg] :: [a2aaaf4] Unknown exception while searching Rarbg. Error: \"'BraceAdapter' object has no attribute 'DEBUG'\"\nTraceback (most recent call last):\n  File \"C:\\Medusa\\medusa\\search\\core.py\", line 547, in search_providers\n    down_cur_quality, manual_search, manual_search_type)\n  File \"C:\\Medusa\\medusa\\providers\\generic_provider.py\", line 207, in find_search_results\n    items_list += self.search(search_string, ep_obj=episode)\n  File \"C:\\Medusa\\medusa\\providers\\torrent\\json\\rarbg.py\", line 136, in search\n    log_level = log.DEBUG\nAttributeError: 'BraceAdapter' object has no attribute 'DEBUG'\n</pre>\n---\n_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators\n", "before_files": [{"content": "# coding=utf-8\n\n\"\"\"Provider code for RARBG.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport datetime\nimport logging\nimport time\nimport traceback\n\nfrom medusa import (\n    app,\n    tv,\n)\nfrom medusa.helper.common import convert_size, try_int\nfrom medusa.logger.adapters.style import BraceAdapter\nfrom medusa.providers.torrent.torrent_provider import TorrentProvider\n\nlog = BraceAdapter(logging.getLogger(__name__))\nlog.logger.addHandler(logging.NullHandler())\n\n\nclass RarbgProvider(TorrentProvider):\n    \"\"\"RARBG Torrent provider.\"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the class.\"\"\"\n        super(self.__class__, self).__init__('Rarbg')\n\n        # Credentials\n        self.public = True\n        self.token = None\n        self.token_expires = None\n\n        # URLs\n        self.url = 'https://rarbg.com'  # Spec: https://torrentapi.org/apidocs_v2.txt\n        self.urls = {\n            'api': 'http://torrentapi.org/pubapi_v2.php',\n        }\n\n        # Proper Strings\n        self.proper_strings = ['{{PROPER|REPACK|REAL|RERIP}}']\n\n        # Miscellaneous Options\n        self.ranked = None\n        self.sorting = None\n\n        # Torrent Stats\n        self.minseed = None\n        self.minleech = None\n\n        # Cache\n        self.cache = tv.Cache(self, min_time=10)  # only poll RARBG every 10 minutes max\n\n    def search(self, search_strings, age=0, ep_obj=None):\n        \"\"\"\n        Search a provider and parse the results.\n\n        :param search_strings: A dict with mode (key) and the search value (value)\n        :param age: Not used\n        :param ep_obj: Not used\n        :returns: A list of search results (structure)\n        \"\"\"\n        results = []\n        if not self.login():\n            return results\n\n        # Search Params\n        search_params = {\n            'app_id': app.RARBG_APPID,\n            'category': 'tv',\n            'min_seeders': try_int(self.minseed),\n            'min_leechers': try_int(self.minleech),\n            'limit': 100,\n            'format': 'json_extended',\n            'ranked': try_int(self.ranked),\n            'token': self.token,\n            'sort': 'last',\n            'mode': 'list',\n        }\n\n        for mode in search_strings:\n            log.debug('Search mode: {0}', mode)\n\n            if mode == 'RSS':\n                search_params['search_string'] = None\n                search_params['search_tvdb'] = None\n            else:\n                search_params['sort'] = self.sorting if self.sorting else 'seeders'\n                search_params['mode'] = 'search'\n                search_params['search_tvdb'] = self._get_tvdb_id()\n\n            for search_string in search_strings[mode]:\n                if mode != 'RSS':\n                    log.debug('Search string: {search}',\n                              {'search': search_string})\n                    if self.ranked:\n                        log.debug('Searching only ranked torrents')\n\n                search_params['search_string'] = search_string\n\n                # Check if token is still valid before search\n                if not self.login():\n                    continue\n\n                # Maximum requests allowed are 1req/2sec\n                # Changing to 5 because of server clock desync\n                time.sleep(5)\n\n                search_url = self.urls['api']\n                response = self.get_url(search_url, params=search_params, returns='response')\n                if not response or not response.content:\n                    log.debug('No data returned from provider')\n                    continue\n\n                try:\n                    jdata = response.json()\n                except ValueError:\n                    log.debug('No data returned from provider')\n                    continue\n\n                error = jdata.get('error')\n                error_code = jdata.get('error_code')\n                if error:\n                    # List of errors: https://github.com/rarbg/torrentapi/issues/1#issuecomment-114763312\n                    if error_code == 5:\n                        # 5 = Too many requests per second\n                        log_level = log.INFO\n                    elif error_code not in (4, 8, 10, 12, 14, 20):\n                        # 4 = Invalid token. Use get_token for a new one!\n                        # 8, 10, 12, 14 = Cant find * in database. Are you sure this * exists?\n                        # 20 = No results found\n                        log_level = log.WARNING\n                    else:\n                        log_level = log.DEBUG\n                    log.log(log_level, '{msg} Code: {code}', {'msg': error, 'code': error_code})\n                    continue\n\n                results += self.parse(jdata, mode)\n\n        return results\n\n    def parse(self, data, mode):\n        \"\"\"\n        Parse search results for items.\n\n        :param data: The raw response from a search\n        :param mode: The current mode used to search, e.g. RSS\n\n        :return: A list of items found\n        \"\"\"\n        items = []\n\n        torrent_rows = data.get('torrent_results', {})\n\n        if not torrent_rows:\n            log.debug('Data returned from provider does not contain any torrents')\n            return items\n\n        for row in torrent_rows:\n            try:\n                title = row.pop('title')\n                download_url = row.pop('download') + self._custom_trackers\n                if not all([title, download_url]):\n                    continue\n\n                seeders = row.pop('seeders')\n                leechers = row.pop('leechers')\n\n                # Filter unseeded torrent\n                if seeders < min(self.minseed, 1):\n                    if mode != 'RSS':\n                        log.debug(\"Discarding torrent because it doesn't meet the\"\n                                  \" minimum seeders: {0}. Seeders: {1}\",\n                                  title, seeders)\n                    continue\n\n                torrent_size = row.pop('size', -1)\n                size = convert_size(torrent_size) or -1\n\n                pubdate_raw = row.pop('pubdate')\n                pubdate = self._parse_pubdate(pubdate_raw)\n\n                item = {\n                    'title': title,\n                    'link': download_url,\n                    'size': size,\n                    'seeders': seeders,\n                    'leechers': leechers,\n                    'pubdate': pubdate,\n                }\n                if mode != 'RSS':\n                    log.debug('Found result: {0} with {1} seeders and {2} leechers',\n                              title, seeders, leechers)\n\n                items.append(item)\n            except (AttributeError, TypeError, KeyError, ValueError, IndexError):\n                log.error('Failed parsing provider. Traceback: {0!r}',\n                          traceback.format_exc())\n\n        return items\n\n    def login(self):\n        \"\"\"Login method used for logging in before doing search and torrent downloads.\"\"\"\n        if self.token and self.token_expires and datetime.datetime.now() < self.token_expires:\n            return True\n\n        login_params = {\n            'get_token': 'get_token',\n            'format': 'json',\n            'app_id': app.RARBG_APPID,\n        }\n\n        response = self.get_url(self.urls['api'], params=login_params, returns='json')\n        if not response:\n            log.warning('Unable to connect to provider')\n            return False\n\n        self.token = response.get('token')\n        self.token_expires = datetime.datetime.now() + datetime.timedelta(minutes=14) if self.token else None\n        return self.token is not None\n\n\nprovider = RarbgProvider()\n", "path": "medusa/providers/torrent/json/rarbg.py"}], "after_files": [{"content": "# coding=utf-8\n\n\"\"\"Provider code for RARBG.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport datetime\nimport logging\nimport time\nimport traceback\n\nfrom medusa import (\n    app,\n    tv,\n)\nfrom medusa.helper.common import convert_size, try_int\nfrom medusa.logger.adapters.style import BraceAdapter\nfrom medusa.providers.torrent.torrent_provider import TorrentProvider\n\nlog = BraceAdapter(logging.getLogger(__name__))\nlog.logger.addHandler(logging.NullHandler())\n\n\nclass RarbgProvider(TorrentProvider):\n    \"\"\"RARBG Torrent provider.\"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the class.\"\"\"\n        super(self.__class__, self).__init__('Rarbg')\n\n        # Credentials\n        self.public = True\n        self.token = None\n        self.token_expires = None\n\n        # URLs\n        self.url = 'https://rarbg.com'  # Spec: https://torrentapi.org/apidocs_v2.txt\n        self.urls = {\n            'api': 'http://torrentapi.org/pubapi_v2.php',\n        }\n\n        # Proper Strings\n        self.proper_strings = ['{{PROPER|REPACK|REAL|RERIP}}']\n\n        # Miscellaneous Options\n        self.ranked = None\n        self.sorting = None\n\n        # Torrent Stats\n        self.minseed = None\n        self.minleech = None\n\n        # Cache\n        self.cache = tv.Cache(self, min_time=10)  # only poll RARBG every 10 minutes max\n\n    def search(self, search_strings, age=0, ep_obj=None):\n        \"\"\"\n        Search a provider and parse the results.\n\n        :param search_strings: A dict with mode (key) and the search value (value)\n        :param age: Not used\n        :param ep_obj: Not used\n        :returns: A list of search results (structure)\n        \"\"\"\n        results = []\n        if not self.login():\n            return results\n\n        # Search Params\n        search_params = {\n            'app_id': app.RARBG_APPID,\n            'category': 'tv',\n            'min_seeders': try_int(self.minseed),\n            'min_leechers': try_int(self.minleech),\n            'limit': 100,\n            'format': 'json_extended',\n            'ranked': try_int(self.ranked),\n            'token': self.token,\n            'sort': 'last',\n            'mode': 'list',\n        }\n\n        for mode in search_strings:\n            log.debug('Search mode: {0}', mode)\n\n            if mode == 'RSS':\n                search_params['search_string'] = None\n                search_params['search_tvdb'] = None\n            else:\n                search_params['sort'] = self.sorting if self.sorting else 'seeders'\n                search_params['mode'] = 'search'\n                search_params['search_tvdb'] = self._get_tvdb_id()\n\n            for search_string in search_strings[mode]:\n                if mode != 'RSS':\n                    log.debug('Search string: {search}',\n                              {'search': search_string})\n                    if self.ranked:\n                        log.debug('Searching only ranked torrents')\n\n                search_params['search_string'] = search_string\n\n                # Check if token is still valid before search\n                if not self.login():\n                    continue\n\n                # Maximum requests allowed are 1req/2sec\n                # Changing to 5 because of server clock desync\n                time.sleep(5)\n\n                search_url = self.urls['api']\n                response = self.get_url(search_url, params=search_params, returns='response')\n                if not response or not response.content:\n                    log.debug('No data returned from provider')\n                    continue\n\n                try:\n                    jdata = response.json()\n                except ValueError:\n                    log.debug('No data returned from provider')\n                    continue\n\n                error = jdata.get('error')\n                error_code = jdata.get('error_code')\n                if error:\n                    # List of errors: https://github.com/rarbg/torrentapi/issues/1#issuecomment-114763312\n                    if error_code == 5:\n                        # 5 = Too many requests per second\n                        log_level = logging.INFO\n                    elif error_code not in (4, 8, 10, 12, 14, 20):\n                        # 4 = Invalid token. Use get_token for a new one!\n                        # 8, 10, 12, 14 = Cant find * in database. Are you sure this * exists?\n                        # 20 = No results found\n                        log_level = logging.WARNING\n                    else:\n                        log_level = logging.DEBUG\n                    log.log(log_level, '{msg} Code: {code}', {'msg': error, 'code': error_code})\n                    continue\n\n                results += self.parse(jdata, mode)\n\n        return results\n\n    def parse(self, data, mode):\n        \"\"\"\n        Parse search results for items.\n\n        :param data: The raw response from a search\n        :param mode: The current mode used to search, e.g. RSS\n\n        :return: A list of items found\n        \"\"\"\n        items = []\n\n        torrent_rows = data.get('torrent_results', {})\n\n        if not torrent_rows:\n            log.debug('Data returned from provider does not contain any torrents')\n            return items\n\n        for row in torrent_rows:\n            try:\n                title = row.pop('title')\n                download_url = row.pop('download') + self._custom_trackers\n                if not all([title, download_url]):\n                    continue\n\n                seeders = row.pop('seeders')\n                leechers = row.pop('leechers')\n\n                # Filter unseeded torrent\n                if seeders < min(self.minseed, 1):\n                    if mode != 'RSS':\n                        log.debug(\"Discarding torrent because it doesn't meet the\"\n                                  \" minimum seeders: {0}. Seeders: {1}\",\n                                  title, seeders)\n                    continue\n\n                torrent_size = row.pop('size', -1)\n                size = convert_size(torrent_size) or -1\n\n                pubdate_raw = row.pop('pubdate')\n                pubdate = self._parse_pubdate(pubdate_raw)\n\n                item = {\n                    'title': title,\n                    'link': download_url,\n                    'size': size,\n                    'seeders': seeders,\n                    'leechers': leechers,\n                    'pubdate': pubdate,\n                }\n                if mode != 'RSS':\n                    log.debug('Found result: {0} with {1} seeders and {2} leechers',\n                              title, seeders, leechers)\n\n                items.append(item)\n            except (AttributeError, TypeError, KeyError, ValueError, IndexError):\n                log.error('Failed parsing provider. Traceback: {0!r}',\n                          traceback.format_exc())\n\n        return items\n\n    def login(self):\n        \"\"\"Login method used for logging in before doing search and torrent downloads.\"\"\"\n        if self.token and self.token_expires and datetime.datetime.now() < self.token_expires:\n            return True\n\n        login_params = {\n            'get_token': 'get_token',\n            'format': 'json',\n            'app_id': app.RARBG_APPID,\n        }\n\n        response = self.get_url(self.urls['api'], params=login_params, returns='json')\n        if not response:\n            log.warning('Unable to connect to provider')\n            return False\n\n        self.token = response.get('token')\n        self.token_expires = datetime.datetime.now() + datetime.timedelta(minutes=14) if self.token else None\n        return self.token is not None\n\n\nprovider = RarbgProvider()\n", "path": "medusa/providers/torrent/json/rarbg.py"}]}