We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[APP SUBMITTED]: No JSON object could be decoded
### INFO

Python Version: **2.7.6 (default, Jun 22 2015, 18:00:18) [GCC 4.8.2]**
Operating System: **Linux-3.19.0-56-generic-i686-with-Ubuntu-14.04-trusty**
Locale: UTF-8
Branch: **develop**
Commit: PyMedusa/SickRage@3351698fd0d3b554f0dd6bbd8d0cbee0b60ce128
Link to Log: https://gist.github.com/0f9bcafda8153bec981bf232c004d72e
### ERROR

```
SEARCHQUEUE-MANUAL-311937 :: [TorrentDay] :: [3351698] Unknown exception while searching TorrentDay. Error: 'No JSON object could be decoded'
Traceback (most recent call last):
  File "/home/home/SickRage/sickbeard/search.py", line 547, in searchProviders
    forced_search, downCurQuality, manual_search, manual_search_type)
  File "/home/home/SickRage/sickrage/providers/GenericProvider.py", line 149, in find_search_results
    items_list += self.search(search_string, ep_obj=episode)
  File "/home/home/SickRage/sickbeard/providers/torrentday.py", line 123, in search
    parsedJSON = self.get_url(self.urls['search'], post_data=post_data, returns='json')
  File "/home/home/SickRage/sickrage/providers/GenericProvider.py", line 356, in get_url
    return getURL(url, post_data, params, self.headers, timeout, self.session, **kwargs)
  File "/home/home/SickRage/sickbeard/helpers.py", line 1472, in getURL
    return resp if response_type == u'response' or response_type is None else resp.json() if response_type == u'json' else getattr(resp, response_type, resp)
  File "/home/home/SickRage/lib/requests/models.py", line 808, in json
    return complexjson.loads(self.text, **kwargs)
  File "/home/home/SickRage/lib/simplejson/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/home/home/SickRage/lib/simplejson/decoder.py", line 335, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/home/SickRage/lib/simplejson/decoder.py", line 353, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
```

---

_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: `sickbeard/providers/torrentday.py`
Content:
```
1 # coding=utf-8
2 # Author: Mr_Orange <mr_orange@hotmail.it>
3 #
4 
5 #
6 # This file is part of SickRage.
7 #
8 # SickRage is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # SickRage is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with SickRage. If not, see <http://www.gnu.org/licenses/>.
20 
21 import re
22 from requests.compat import urljoin
23 from requests.utils import add_dict_to_cookiejar, dict_from_cookiejar
24 
25 from sickbeard import logger, tvcache
26 
27 from sickrage.helper.common import convert_size, try_int
28 from sickrage.providers.torrent.TorrentProvider import TorrentProvider
29 
30 
31 class TorrentDayProvider(TorrentProvider):  # pylint: disable=too-many-instance-attributes
32 
33     def __init__(self):
34 
35         # Provider Init
36         TorrentProvider.__init__(self, "TorrentDay")
37 
38         # Credentials
39         self.username = None
40         self.password = None
41         self._uid = None
42         self._hash = None
43 
44         # Torrent Stats
45         self.minseed = None
46         self.minleech = None
47         self.freeleech = False
48 
49         # URLs
50         self.url = 'https://classic.torrentday.com'
51         self.urls = {
52             'login': urljoin(self.url, '/torrents/'),
53             'search': urljoin(self.url, '/V3/API/API.php'),
54             'download': urljoin(self.url, '/download.php/')
55         }
56 
57         self.cookies = None
58         self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1},
59                            'RSS': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1, 'c14': 1}}
60 
61         # Cache
62         self.cache = tvcache.TVCache(self, min_time=10)  # Only poll IPTorrents every 10 minutes max
63 
64     def login(self):
65         if any(dict_from_cookiejar(self.session.cookies).values()):
66             return True
67 
68         if self._uid and self._hash:
69             add_dict_to_cookiejar(self.session.cookies, self.cookies)
70         else:
71 
72             login_params = {
73                 'username': self.username,
74                 'password': self.password,
75                 'submit.x': 0,
76                 'submit.y': 0
77             }
78 
79             response = self.get_url(self.urls['login'], post_data=login_params, returns='text')
80             if not response:
81                 logger.log(u"Unable to connect to provider", logger.WARNING)
82                 return False
83 
84             if re.search('You tried too often', response):
85                 logger.log(u"Too many login access attempts", logger.WARNING)
86                 return False
87 
88             try:
89                 if dict_from_cookiejar(self.session.cookies)['uid'] and dict_from_cookiejar(self.session.cookies)['pass']:
90                     self._uid = dict_from_cookiejar(self.session.cookies)['uid']
91                     self._hash = dict_from_cookiejar(self.session.cookies)['pass']
92                     self.cookies = {'uid': self._uid,
93                                     'pass': self._hash}
94                     return True
95             except Exception:
96                 pass
97 
98             logger.log(u"Unable to obtain cookie", logger.WARNING)
99             return False
100 
101     def search(self, search_params, age=0, ep_obj=None):  # pylint: disable=too-many-locals
102         results = []
103         if not self.login():
104             return results
105 
106         for mode in search_params:
107             items = []
108             logger.log(u"Search Mode: {}".format(mode), logger.DEBUG)
109             for search_string in search_params[mode]:
110 
111                 if mode != 'RSS':
112                     logger.log(u"Search string: {}".format(search_string.decode("utf-8")),
113                                logger.DEBUG)
114 
115                 search_string = '+'.join(search_string.split())
116 
117                 post_data = dict({'/browse.php?': None, 'cata': 'yes', 'jxt': 8, 'jxw': 'b', 'search': search_string},
118                                  **self.categories[mode])
119 
120                 if self.freeleech:
121                     post_data.update({'free': 'on'})
122 
123                 parsedJSON = self.get_url(self.urls['search'], post_data=post_data, returns='json')
124                 if not parsedJSON:
125                     logger.log(u"No data returned from provider", logger.DEBUG)
126                     continue
127 
128                 try:
129                     torrents = parsedJSON.get('Fs', [])[0].get('Cn', {}).get('torrents', [])
130                 except Exception:
131                     logger.log(u"Data returned from provider does not contain any torrents", logger.DEBUG)
132                     continue
133 
134                 for torrent in torrents:
135 
136                     title = re.sub(r"\[.*\=.*\].*\[/.*\]", "", torrent['name']) if torrent['name'] else None
137                     download_url = urljoin(self.urls['download'], '{}/{}'.format(torrent['id'], torrent['fname'])) if torrent['id'] and torrent['fname'] else None
138 
139                     if not all([title, download_url]):
140                         continue
141 
142                     seeders = int(torrent['seed']) if torrent['seed'] else 1
143                     leechers = int(torrent['leech']) if torrent['leech'] else 0
144 
145                     # Filter unseeded torrent
146                     if seeders < min(self.minseed, 1):
147                         if mode != 'RSS':
148                             logger.log(u"Discarding torrent because it doesn't meet the minimum seeders: {0}. Seeders: {1})".format(title, seeders), logger.DEBUG)
149                         continue
150 
151                     torrent_size = torrent['size']
152                     size = convert_size(torrent_size) or -1
153 
154                     item = {'title': title, 'link': download_url, 'size': size, 'seeders': seeders, 'leechers': leechers, 'pubdate': None, 'hash': None}
155 
156                     if mode != 'RSS':
157                         logger.log(u"Found result: {0} with {1} seeders and {2} leechers".format
158                                    (title, seeders, leechers), logger.DEBUG)
159 
160                     items.append(item)
161 
162             # For each search mode sort all the items by seeders if available
163             items.sort(key=lambda d: try_int(d.get('seeders', 0)), reverse=True)
164             results += items
165 
166         return results
167 
168 
169 provider = TorrentDayProvider()
170
```
--- 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/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py
--- a/sickbeard/providers/torrentday.py
+++ b/sickbeard/providers/torrentday.py
@@ -20,6 +20,7 @@
 
 import re
 from requests.compat import urljoin
+from requests.exceptions import RequestException
 from requests.utils import add_dict_to_cookiejar, dict_from_cookiejar
 
 from sickbeard import logger, tvcache
@@ -120,19 +121,25 @@
                 if self.freeleech:
                     post_data.update({'free': 'on'})
 
-                parsedJSON = self.get_url(self.urls['search'], post_data=post_data, returns='json')
-                if not parsedJSON:
-                    logger.log(u"No data returned from provider", logger.DEBUG)
+                try:
+                    response = self.get_url(self.urls['search'], post_data=post_data)
+                    response.raise_for_status()
+                except RequestException as msg:
+                    logger.log(u'Error while connecting to provider: {error}'.format(error=msg), logger.ERROR)
                     continue
 
                 try:
-                    torrents = parsedJSON.get('Fs', [])[0].get('Cn', {}).get('torrents', [])
-                except Exception:
+                    jdata = response.json()
+                except ValueError:  # also catches JSONDecodeError if simplejson is installed
+                    logger.log(u"Data returned from provider is not json", logger.ERROR)
+                    continue
+
+                torrents = jdata.get('Fs', [dict()])[0].get('Cn', {}).get('torrents', [])
+                if not torrents:
                     logger.log(u"Data returned from provider does not contain any torrents", logger.DEBUG)
                     continue
 
                 for torrent in torrents:
-
                     title = re.sub(r"\[.*\=.*\].*\[/.*\]", "", torrent['name']) if torrent['name'] else None
                     download_url = urljoin(self.urls['download'], '{}/{}'.format(torrent['id'], torrent['fname'])) if torrent['id'] and torrent['fname'] else None

{"golden_diff": "diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py\n--- a/sickbeard/providers/torrentday.py\n+++ b/sickbeard/providers/torrentday.py\n@@ -20,6 +20,7 @@\n \n import re\n from requests.compat import urljoin\n+from requests.exceptions import RequestException\n from requests.utils import add_dict_to_cookiejar, dict_from_cookiejar\n \n from sickbeard import logger, tvcache\n@@ -120,19 +121,25 @@\n                 if self.freeleech:\n                     post_data.update({'free': 'on'})\n \n-                parsedJSON = self.get_url(self.urls['search'], post_data=post_data, returns='json')\n-                if not parsedJSON:\n-                    logger.log(u\"No data returned from provider\", logger.DEBUG)\n+                try:\n+                    response = self.get_url(self.urls['search'], post_data=post_data)\n+                    response.raise_for_status()\n+                except RequestException as msg:\n+                    logger.log(u'Error while connecting to provider: {error}'.format(error=msg), logger.ERROR)\n                     continue\n \n                 try:\n-                    torrents = parsedJSON.get('Fs', [])[0].get('Cn', {}).get('torrents', [])\n-                except Exception:\n+                    jdata = response.json()\n+                except ValueError:  # also catches JSONDecodeError if simplejson is installed\n+                    logger.log(u\"Data returned from provider is not json\", logger.ERROR)\n+                    continue\n+\n+                torrents = jdata.get('Fs', [dict()])[0].get('Cn', {}).get('torrents', [])\n+                if not torrents:\n                     logger.log(u\"Data returned from provider does not contain any torrents\", logger.DEBUG)\n                     continue\n \n                 for torrent in torrents:\n-\n                     title = re.sub(r\"\\[.*\\=.*\\].*\\[/.*\\]\", \"\", torrent['name']) if torrent['name'] else None\n                     download_url = urljoin(self.urls['download'], '{}/{}'.format(torrent['id'], torrent['fname'])) if torrent['id'] and torrent['fname'] else None\n", "issue": "[APP SUBMITTED]: No JSON object could be decoded\n### INFO\n\nPython Version: **2.7.6 (default, Jun 22 2015, 18:00:18) [GCC 4.8.2]**\nOperating System: **Linux-3.19.0-56-generic-i686-with-Ubuntu-14.04-trusty**\nLocale: UTF-8\nBranch: **develop**\nCommit: PyMedusa/SickRage@3351698fd0d3b554f0dd6bbd8d0cbee0b60ce128\nLink to Log: https://gist.github.com/0f9bcafda8153bec981bf232c004d72e\n### ERROR\n\n```\nSEARCHQUEUE-MANUAL-311937 :: [TorrentDay] :: [3351698] Unknown exception while searching TorrentDay. Error: 'No JSON object could be decoded'\nTraceback (most recent call last):\n  File \"/home/home/SickRage/sickbeard/search.py\", line 547, in searchProviders\n    forced_search, downCurQuality, manual_search, manual_search_type)\n  File \"/home/home/SickRage/sickrage/providers/GenericProvider.py\", line 149, in find_search_results\n    items_list += self.search(search_string, ep_obj=episode)\n  File \"/home/home/SickRage/sickbeard/providers/torrentday.py\", line 123, in search\n    parsedJSON = self.get_url(self.urls['search'], post_data=post_data, returns='json')\n  File \"/home/home/SickRage/sickrage/providers/GenericProvider.py\", line 356, in get_url\n    return getURL(url, post_data, params, self.headers, timeout, self.session, **kwargs)\n  File \"/home/home/SickRage/sickbeard/helpers.py\", line 1472, in getURL\n    return resp if response_type == u'response' or response_type is None else resp.json() if response_type == u'json' else getattr(resp, response_type, resp)\n  File \"/home/home/SickRage/lib/requests/models.py\", line 808, in json\n    return complexjson.loads(self.text, **kwargs)\n  File \"/home/home/SickRage/lib/simplejson/__init__.py\", line 307, in loads\n    return _default_decoder.decode(s)\n  File \"/home/home/SickRage/lib/simplejson/decoder.py\", line 335, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n  File \"/home/home/SickRage/lib/simplejson/decoder.py\", line 353, in raw_decode\n    raise ValueError(\"No JSON object could be decoded\")\nValueError: No JSON object could be decoded\n```\n\n---\n\n_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators\n\n", "before_files": [{"content": "# coding=utf-8\n# Author: Mr_Orange <mr_orange@hotmail.it>\n#\n\n#\n# This file is part of SickRage.\n#\n# SickRage is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# SickRage is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with SickRage. If not, see <http://www.gnu.org/licenses/>.\n\nimport re\nfrom requests.compat import urljoin\nfrom requests.utils import add_dict_to_cookiejar, dict_from_cookiejar\n\nfrom sickbeard import logger, tvcache\n\nfrom sickrage.helper.common import convert_size, try_int\nfrom sickrage.providers.torrent.TorrentProvider import TorrentProvider\n\n\nclass TorrentDayProvider(TorrentProvider):  # pylint: disable=too-many-instance-attributes\n\n    def __init__(self):\n\n        # Provider Init\n        TorrentProvider.__init__(self, \"TorrentDay\")\n\n        # Credentials\n        self.username = None\n        self.password = None\n        self._uid = None\n        self._hash = None\n\n        # Torrent Stats\n        self.minseed = None\n        self.minleech = None\n        self.freeleech = False\n\n        # URLs\n        self.url = 'https://classic.torrentday.com'\n        self.urls = {\n            'login': urljoin(self.url, '/torrents/'),\n            'search': urljoin(self.url, '/V3/API/API.php'),\n            'download': urljoin(self.url, '/download.php/')\n        }\n\n        self.cookies = None\n        self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1},\n                           'RSS': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1, 'c14': 1}}\n\n        # Cache\n        self.cache = tvcache.TVCache(self, min_time=10)  # Only poll IPTorrents every 10 minutes max\n\n    def login(self):\n        if any(dict_from_cookiejar(self.session.cookies).values()):\n            return True\n\n        if self._uid and self._hash:\n            add_dict_to_cookiejar(self.session.cookies, self.cookies)\n        else:\n\n            login_params = {\n                'username': self.username,\n                'password': self.password,\n                'submit.x': 0,\n                'submit.y': 0\n            }\n\n            response = self.get_url(self.urls['login'], post_data=login_params, returns='text')\n            if not response:\n                logger.log(u\"Unable to connect to provider\", logger.WARNING)\n                return False\n\n            if re.search('You tried too often', response):\n                logger.log(u\"Too many login access attempts\", logger.WARNING)\n                return False\n\n            try:\n                if dict_from_cookiejar(self.session.cookies)['uid'] and dict_from_cookiejar(self.session.cookies)['pass']:\n                    self._uid = dict_from_cookiejar(self.session.cookies)['uid']\n                    self._hash = dict_from_cookiejar(self.session.cookies)['pass']\n                    self.cookies = {'uid': self._uid,\n                                    'pass': self._hash}\n                    return True\n            except Exception:\n                pass\n\n            logger.log(u\"Unable to obtain cookie\", logger.WARNING)\n            return False\n\n    def search(self, search_params, age=0, ep_obj=None):  # pylint: disable=too-many-locals\n        results = []\n        if not self.login():\n            return results\n\n        for mode in search_params:\n            items = []\n            logger.log(u\"Search Mode: {}\".format(mode), logger.DEBUG)\n            for search_string in search_params[mode]:\n\n                if mode != 'RSS':\n                    logger.log(u\"Search string: {}\".format(search_string.decode(\"utf-8\")),\n                               logger.DEBUG)\n\n                search_string = '+'.join(search_string.split())\n\n                post_data = dict({'/browse.php?': None, 'cata': 'yes', 'jxt': 8, 'jxw': 'b', 'search': search_string},\n                                 **self.categories[mode])\n\n                if self.freeleech:\n                    post_data.update({'free': 'on'})\n\n                parsedJSON = self.get_url(self.urls['search'], post_data=post_data, returns='json')\n                if not parsedJSON:\n                    logger.log(u\"No data returned from provider\", logger.DEBUG)\n                    continue\n\n                try:\n                    torrents = parsedJSON.get('Fs', [])[0].get('Cn', {}).get('torrents', [])\n                except Exception:\n                    logger.log(u\"Data returned from provider does not contain any torrents\", logger.DEBUG)\n                    continue\n\n                for torrent in torrents:\n\n                    title = re.sub(r\"\\[.*\\=.*\\].*\\[/.*\\]\", \"\", torrent['name']) if torrent['name'] else None\n                    download_url = urljoin(self.urls['download'], '{}/{}'.format(torrent['id'], torrent['fname'])) if torrent['id'] and torrent['fname'] else None\n\n                    if not all([title, download_url]):\n                        continue\n\n                    seeders = int(torrent['seed']) if torrent['seed'] else 1\n                    leechers = int(torrent['leech']) if torrent['leech'] else 0\n\n                    # Filter unseeded torrent\n                    if seeders < min(self.minseed, 1):\n                        if mode != 'RSS':\n                            logger.log(u\"Discarding torrent because it doesn't meet the minimum seeders: {0}. Seeders: {1})\".format(title, seeders), logger.DEBUG)\n                        continue\n\n                    torrent_size = torrent['size']\n                    size = convert_size(torrent_size) or -1\n\n                    item = {'title': title, 'link': download_url, 'size': size, 'seeders': seeders, 'leechers': leechers, 'pubdate': None, 'hash': None}\n\n                    if mode != 'RSS':\n                        logger.log(u\"Found result: {0} with {1} seeders and {2} leechers\".format\n                                   (title, seeders, leechers), logger.DEBUG)\n\n                    items.append(item)\n\n            # For each search mode sort all the items by seeders if available\n            items.sort(key=lambda d: try_int(d.get('seeders', 0)), reverse=True)\n            results += items\n\n        return results\n\n\nprovider = TorrentDayProvider()\n", "path": "sickbeard/providers/torrentday.py"}], "after_files": [{"content": "# coding=utf-8\n# Author: Mr_Orange <mr_orange@hotmail.it>\n#\n\n#\n# This file is part of SickRage.\n#\n# SickRage is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# SickRage is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with SickRage. If not, see <http://www.gnu.org/licenses/>.\n\nimport re\nfrom requests.compat import urljoin\nfrom requests.exceptions import RequestException\nfrom requests.utils import add_dict_to_cookiejar, dict_from_cookiejar\n\nfrom sickbeard import logger, tvcache\n\nfrom sickrage.helper.common import convert_size, try_int\nfrom sickrage.providers.torrent.TorrentProvider import TorrentProvider\n\n\nclass TorrentDayProvider(TorrentProvider):  # pylint: disable=too-many-instance-attributes\n\n    def __init__(self):\n\n        # Provider Init\n        TorrentProvider.__init__(self, \"TorrentDay\")\n\n        # Credentials\n        self.username = None\n        self.password = None\n        self._uid = None\n        self._hash = None\n\n        # Torrent Stats\n        self.minseed = None\n        self.minleech = None\n        self.freeleech = False\n\n        # URLs\n        self.url = 'https://classic.torrentday.com'\n        self.urls = {\n            'login': urljoin(self.url, '/torrents/'),\n            'search': urljoin(self.url, '/V3/API/API.php'),\n            'download': urljoin(self.url, '/download.php/')\n        }\n\n        self.cookies = None\n        self.categories = {'Season': {'c14': 1}, 'Episode': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1},\n                           'RSS': {'c2': 1, 'c26': 1, 'c7': 1, 'c24': 1, 'c14': 1}}\n\n        # Cache\n        self.cache = tvcache.TVCache(self, min_time=10)  # Only poll IPTorrents every 10 minutes max\n\n    def login(self):\n        if any(dict_from_cookiejar(self.session.cookies).values()):\n            return True\n\n        if self._uid and self._hash:\n            add_dict_to_cookiejar(self.session.cookies, self.cookies)\n        else:\n\n            login_params = {\n                'username': self.username,\n                'password': self.password,\n                'submit.x': 0,\n                'submit.y': 0\n            }\n\n            response = self.get_url(self.urls['login'], post_data=login_params, returns='text')\n            if not response:\n                logger.log(u\"Unable to connect to provider\", logger.WARNING)\n                return False\n\n            if re.search('You tried too often', response):\n                logger.log(u\"Too many login access attempts\", logger.WARNING)\n                return False\n\n            try:\n                if dict_from_cookiejar(self.session.cookies)['uid'] and dict_from_cookiejar(self.session.cookies)['pass']:\n                    self._uid = dict_from_cookiejar(self.session.cookies)['uid']\n                    self._hash = dict_from_cookiejar(self.session.cookies)['pass']\n                    self.cookies = {'uid': self._uid,\n                                    'pass': self._hash}\n                    return True\n            except Exception:\n                pass\n\n            logger.log(u\"Unable to obtain cookie\", logger.WARNING)\n            return False\n\n    def search(self, search_params, age=0, ep_obj=None):  # pylint: disable=too-many-locals\n        results = []\n        if not self.login():\n            return results\n\n        for mode in search_params:\n            items = []\n            logger.log(u\"Search Mode: {}\".format(mode), logger.DEBUG)\n            for search_string in search_params[mode]:\n\n                if mode != 'RSS':\n                    logger.log(u\"Search string: {}\".format(search_string.decode(\"utf-8\")),\n                               logger.DEBUG)\n\n                search_string = '+'.join(search_string.split())\n\n                post_data = dict({'/browse.php?': None, 'cata': 'yes', 'jxt': 8, 'jxw': 'b', 'search': search_string},\n                                 **self.categories[mode])\n\n                if self.freeleech:\n                    post_data.update({'free': 'on'})\n\n                try:\n                    response = self.get_url(self.urls['search'], post_data=post_data)\n                    response.raise_for_status()\n                except RequestException as msg:\n                    logger.log(u'Error while connecting to provider: {error}'.format(error=msg), logger.ERROR)\n                    continue\n\n                try:\n                    jdata = response.json()\n                except ValueError:  # also catches JSONDecodeError if simplejson is installed\n                    logger.log(u\"Data returned from provider is not json\", logger.ERROR)\n                    continue\n\n                torrents = jdata.get('Fs', [dict()])[0].get('Cn', {}).get('torrents', [])\n                if not torrents:\n                    logger.log(u\"Data returned from provider does not contain any torrents\", logger.DEBUG)\n                    continue\n\n                for torrent in torrents:\n                    title = re.sub(r\"\\[.*\\=.*\\].*\\[/.*\\]\", \"\", torrent['name']) if torrent['name'] else None\n                    download_url = urljoin(self.urls['download'], '{}/{}'.format(torrent['id'], torrent['fname'])) if torrent['id'] and torrent['fname'] else None\n\n                    if not all([title, download_url]):\n                        continue\n\n                    seeders = int(torrent['seed']) if torrent['seed'] else 1\n                    leechers = int(torrent['leech']) if torrent['leech'] else 0\n\n                    # Filter unseeded torrent\n                    if seeders < min(self.minseed, 1):\n                        if mode != 'RSS':\n                            logger.log(u\"Discarding torrent because it doesn't meet the minimum seeders: {0}. Seeders: {1})\".format(title, seeders), logger.DEBUG)\n                        continue\n\n                    torrent_size = torrent['size']\n                    size = convert_size(torrent_size) or -1\n\n                    item = {'title': title, 'link': download_url, 'size': size, 'seeders': seeders, 'leechers': leechers, 'pubdate': None, 'hash': None}\n\n                    if mode != 'RSS':\n                        logger.log(u\"Found result: {0} with {1} seeders and {2} leechers\".format\n                                   (title, seeders, leechers), logger.DEBUG)\n\n                    items.append(item)\n\n            # For each search mode sort all the items by seeders if available\n            items.sort(key=lambda d: try_int(d.get('seeders', 0)), reverse=True)\n            results += items\n\n        return results\n\n\nprovider = TorrentDayProvider()\n", "path": "sickbeard/providers/torrentday.py"}]}