We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
No results found on torrentday
### Expected behaviour:
When using the torrentday as a source with discover, results should display

### Actual behaviour:
Always returns "No results from torrentday"

### Steps to reproduce:
Setup to search as per config

#### Config:
https://pastebin.com/6xWSD9i2
  
#### Log:
https://pastebin.com/uqa0bDea

### Additional information:
torrentday appearts to have updated their browse/search page https://www.torrentday.com/browse.php

--- 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/sites/torrentday.py`
Content:
```
1 from __future__ import unicode_literals, division, absolute_import
2 from builtins import *  # noqa pylint: disable=unused-import, redefined-builtin
3 from future.moves.urllib.parse import quote
4 
5 import re
6 import logging
7 
8 from requests.exceptions import RequestException
9 
10 from flexget import plugin
11 from flexget.config_schema import one_or_more
12 from flexget.entry import Entry
13 from flexget.event import event
14 from flexget.plugin import PluginError
15 from flexget.plugins.internal.urlrewriting import UrlRewritingError
16 from flexget.utils import requests
17 from flexget.utils.soup import get_soup
18 from flexget.utils.search import torrent_availability, normalize_unicode
19 from flexget.utils.tools import parse_filesize
20 
21 log = logging.getLogger('torrentday')
22 
23 CATEGORIES = {
24     'all': 0,
25     # Movies
26     'mov480p': 25,
27     'movHD': 11,
28     'movBD': 5,
29     'movDVD': 3,
30     'movMP4': 21,
31     'movNonEnglish': 22,
32     'movPACKS': 13,
33     'movSDx264': 44,
34     'movX265': 48,
35     'movXVID': 1,
36 
37     # TV
38     'tv480p': 24,
39     'tvBRD': 32,
40     'tvDVD': 31,
41     'tvDVDrip': 33,
42     'tvMOBILE': 46,
43     'tvPACKS': 14,
44     'tvSDx264': 26,
45     'tvHDx264': 7,
46     'tvX265': 34,
47     'tvXVID': 2
48 }
49 
50 
51 class UrlRewriteTorrentday(object):
52     """
53         Torrentday urlrewriter and search plugin.
54 
55         torrentday:
56           uid: xxxxxxxxxxxxx  (required)    NOT YOUR LOGIN. find this in your browser's cookies
57           passkey: xxxxxxxxx  (required)    NOT YOUR PASSWORD. see previous
58           cfduid: xxxxxxxxxx  (required)    AGAIN IN THE COOKIES
59           rss_key: xxxxxxxxx  (required)    get this from your profile page
60           category: xxxxxxxx
61 
62           Category can be one of 
63             ID from browsing site OR 'name'
64             movies:
65               mov480p, movHD, movBD, movDVD,
66               movMP4, movNonEnglish, movPACKS,
67               movSDx264, movX265, movXVID
68             tv:
69               tv480p, tvBRD, tvDVD, tvDVDrip,
70               tvMOBILE, tvPACKS, tvSDx264, 
71               tvHDx264, tvX265, tvXVID
72     """
73 
74     schema = {
75         'type': 'object',
76         'properties': {
77             'rss_key': {'type': 'string'},
78             'uid': {'type': 'string'},
79             'passkey': {'type': 'string'},
80             'cfduid': {'type': 'string'},
81             'category': {
82                 'oneOf': [
83                     {'type': 'integer'},
84                     {'type': 'string', 'enum': list(CATEGORIES)},
85                 ]
86             },
87         },
88         'required': ['rss_key', 'uid', 'passkey', 'cfduid'],
89         'additionalProperties': False
90     }
91 
92     # urlrewriter API
93     def url_rewritable(self, task, entry):
94         url = entry['url']
95         if url.find('.torrent'):
96             return False
97         if url.startswith('https://www.torrentday.com'):
98             return True
99         return False
100 
101     # urlrewriter API
102     def url_rewrite(self, task, entry):
103         if 'url' not in entry:
104             log.error('Didn\'t actually get a URL...')
105         else:
106             log.debug('Got the URL: %s', entry['url'])
107         if entry['url'].startswith('https://www.torrentday.com/browse'):
108             # use search
109             results = self.search(task, entry)
110             if not results:
111                 raise UrlRewritingError('No search results found')
112             entry['url'] = results[0]['url']
113 
114     @plugin.internet(log)
115     def search(self, task, entry, config=None):
116         """
117         Search for name from torrentday.
118         """
119 
120         categories = config.get('category', 'all')
121         # Make sure categories is a list
122         if not isinstance(categories, list):
123             categories = [categories]
124         # If there are any text categories, turn them into their id number
125         categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories]
126         params = { 'cata': 'yes', 'c%s' % ','.join(str(c) for c in categories): 1, 'clear-new': 1}
127         entries = set()
128         for search_string in entry.get('search_strings', [entry['title']]):
129 
130             url = 'https://www.torrentday.com/browse.php'
131             params['search'] = normalize_unicode(search_string).replace(':', '')
132             cookies = { 'uid': config['uid'], 'pass': config['passkey'], '__cfduid': config['cfduid'] }
133 
134             try:
135                 page = requests.get(url, params=params, cookies=cookies).content
136             except RequestException as e:
137                 raise PluginError('Could not connect to torrentday: %s' % e)
138 
139             soup = get_soup(page)
140 
141             for tr in soup.find_all('tr', { 'class': 'browse' }):
142                 entry = Entry()
143                 # find the torrent names
144                 title = tr.find('a', { 'class': 'torrentName' })
145                 entry['title'] = title.contents[0]
146                 log.debug('title: %s', title.contents[0])
147 
148                 # find download link
149                 torrent_url = tr.find('td', { 'class': 'dlLinksInfo' })
150                 torrent_url = torrent_url.find('a').get('href')
151 
152                 # construct download URL
153                 torrent_url = ( 'https://www.torrentday.com/' + torrent_url + '?torrent_pass=' + config['rss_key'] )
154                 log.debug('RSS-ified download link: %s', torrent_url)
155                 entry['url'] = torrent_url
156 
157                 # us tr object for seeders/leechers
158                 seeders, leechers = tr.find_all('td', { 'class': ['seedersInfo', 'leechersInfo']})
159                 entry['torrent_seeds'] = int(seeders.contents[0].replace(',', ''))
160                 entry['torrent_leeches'] = int(leechers.contents[0].replace(',', ''))
161                 entry['search_sort'] = torrent_availability(entry['torrent_seeds'], entry['torrent_leeches'])
162 
163                 # use tr object for size
164                 size = tr.find('td', text=re.compile('([\.\d]+) ([TGMKk]?)B')).contents[0]
165                 size = re.search('([\.\d]+) ([TGMKk]?)B', str(size))
166 
167                 entry['content_size'] = parse_filesize(size.group(0))
168 
169                 entries.add(entry)
170 
171         return sorted(entries, reverse=True, key=lambda x: x.get('search_sort'))
172 
173 
174 @event('plugin.register')
175 def register_plugin():
176     plugin.register(UrlRewriteTorrentday, 'torrentday', interfaces=['urlrewriter', 'search'], api_ver=2)
177
```
--- 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/flexget/plugins/sites/torrentday.py b/flexget/plugins/sites/torrentday.py
--- a/flexget/plugins/sites/torrentday.py
+++ b/flexget/plugins/sites/torrentday.py
@@ -123,30 +123,40 @@
             categories = [categories]
         # If there are any text categories, turn them into their id number
         categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories]
-        params = { 'cata': 'yes', 'c%s' % ','.join(str(c) for c in categories): 1, 'clear-new': 1}
+        params = { 'cata': 'yes', 'c{}'.format(','.join(str(c) for c in categories)): 1, 'clear-new': 1}
         entries = set()
         for search_string in entry.get('search_strings', [entry['title']]):
 
-            url = 'https://www.torrentday.com/browse.php'
-            params['search'] = normalize_unicode(search_string).replace(':', '')
+            url = 'https://www.torrentday.com/t'
+            params['q'] = normalize_unicode(search_string).replace(':', '')
             cookies = { 'uid': config['uid'], 'pass': config['passkey'], '__cfduid': config['cfduid'] }
 
             try:
                 page = requests.get(url, params=params, cookies=cookies).content
             except RequestException as e:
-                raise PluginError('Could not connect to torrentday: %s' % e)
+                raise PluginError('Could not connect to torrentday: {}'.format(e))
 
             soup = get_soup(page)
-
-            for tr in soup.find_all('tr', { 'class': 'browse' }):
+            # the first row is the header so skip it
+            for tr in soup.find_all('tr')[1:]:
                 entry = Entry()
                 # find the torrent names
-                title = tr.find('a', { 'class': 'torrentName' })
+                td = tr.find('td', { 'class': 'torrentNameInfo' })
+                if not td:
+                    log.warning('Could not find entry torrentNameInfo for %s.', search_string)
+                    continue
+                title = td.find('a')
+                if not title:
+                    log.warning('Could not determine title for %s.', search_string)
+                    continue
                 entry['title'] = title.contents[0]
                 log.debug('title: %s', title.contents[0])
 
                 # find download link
-                torrent_url = tr.find('td', { 'class': 'dlLinksInfo' })
+                torrent_url = tr.find('td', { 'class': 'ac' })
+                if not torrent_url:
+                    log.warning('Could not determine download link for %s.', search_string)
+                    continue
                 torrent_url = torrent_url.find('a').get('href')
 
                 # construct download URL
@@ -155,7 +165,8 @@
                 entry['url'] = torrent_url
 
                 # us tr object for seeders/leechers
-                seeders, leechers = tr.find_all('td', { 'class': ['seedersInfo', 'leechersInfo']})
+                seeders = tr.find_all('td', { 'class': 'ac seedersInfo'})
+                leechers = tr.find_all('td', { 'class': 'ac leechersInfo'})
                 entry['torrent_seeds'] = int(seeders.contents[0].replace(',', ''))
                 entry['torrent_leeches'] = int(leechers.contents[0].replace(',', ''))
                 entry['search_sort'] = torrent_availability(entry['torrent_seeds'], entry['torrent_leeches'])

{"golden_diff": "diff --git a/flexget/plugins/sites/torrentday.py b/flexget/plugins/sites/torrentday.py\n--- a/flexget/plugins/sites/torrentday.py\n+++ b/flexget/plugins/sites/torrentday.py\n@@ -123,30 +123,40 @@\n             categories = [categories]\n         # If there are any text categories, turn them into their id number\n         categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories]\n-        params = { 'cata': 'yes', 'c%s' % ','.join(str(c) for c in categories): 1, 'clear-new': 1}\n+        params = { 'cata': 'yes', 'c{}'.format(','.join(str(c) for c in categories)): 1, 'clear-new': 1}\n         entries = set()\n         for search_string in entry.get('search_strings', [entry['title']]):\n \n-            url = 'https://www.torrentday.com/browse.php'\n-            params['search'] = normalize_unicode(search_string).replace(':', '')\n+            url = 'https://www.torrentday.com/t'\n+            params['q'] = normalize_unicode(search_string).replace(':', '')\n             cookies = { 'uid': config['uid'], 'pass': config['passkey'], '__cfduid': config['cfduid'] }\n \n             try:\n                 page = requests.get(url, params=params, cookies=cookies).content\n             except RequestException as e:\n-                raise PluginError('Could not connect to torrentday: %s' % e)\n+                raise PluginError('Could not connect to torrentday: {}'.format(e))\n \n             soup = get_soup(page)\n-\n-            for tr in soup.find_all('tr', { 'class': 'browse' }):\n+            # the first row is the header so skip it\n+            for tr in soup.find_all('tr')[1:]:\n                 entry = Entry()\n                 # find the torrent names\n-                title = tr.find('a', { 'class': 'torrentName' })\n+                td = tr.find('td', { 'class': 'torrentNameInfo' })\n+                if not td:\n+                    log.warning('Could not find entry torrentNameInfo for %s.', search_string)\n+                    continue\n+                title = td.find('a')\n+                if not title:\n+                    log.warning('Could not determine title for %s.', search_string)\n+                    continue\n                 entry['title'] = title.contents[0]\n                 log.debug('title: %s', title.contents[0])\n \n                 # find download link\n-                torrent_url = tr.find('td', { 'class': 'dlLinksInfo' })\n+                torrent_url = tr.find('td', { 'class': 'ac' })\n+                if not torrent_url:\n+                    log.warning('Could not determine download link for %s.', search_string)\n+                    continue\n                 torrent_url = torrent_url.find('a').get('href')\n \n                 # construct download URL\n@@ -155,7 +165,8 @@\n                 entry['url'] = torrent_url\n \n                 # us tr object for seeders/leechers\n-                seeders, leechers = tr.find_all('td', { 'class': ['seedersInfo', 'leechersInfo']})\n+                seeders = tr.find_all('td', { 'class': 'ac seedersInfo'})\n+                leechers = tr.find_all('td', { 'class': 'ac leechersInfo'})\n                 entry['torrent_seeds'] = int(seeders.contents[0].replace(',', ''))\n                 entry['torrent_leeches'] = int(leechers.contents[0].replace(',', ''))\n                 entry['search_sort'] = torrent_availability(entry['torrent_seeds'], entry['torrent_leeches'])\n", "issue": "No results found on torrentday\n### Expected behaviour:\r\nWhen using the torrentday as a source with discover, results should display\r\n\r\n### Actual behaviour:\r\nAlways returns \"No results from torrentday\"\r\n\r\n### Steps to reproduce:\r\nSetup to search as per config\r\n\r\n#### Config:\r\nhttps://pastebin.com/6xWSD9i2\r\n  \r\n#### Log:\r\nhttps://pastebin.com/uqa0bDea\r\n\r\n### Additional information:\r\ntorrentday appearts to have updated their browse/search page https://www.torrentday.com/browse.php\n", "before_files": [{"content": "from __future__ import unicode_literals, division, absolute_import\nfrom builtins import *  # noqa pylint: disable=unused-import, redefined-builtin\nfrom future.moves.urllib.parse import quote\n\nimport re\nimport logging\n\nfrom requests.exceptions import RequestException\n\nfrom flexget import plugin\nfrom flexget.config_schema import one_or_more\nfrom flexget.entry import Entry\nfrom flexget.event import event\nfrom flexget.plugin import PluginError\nfrom flexget.plugins.internal.urlrewriting import UrlRewritingError\nfrom flexget.utils import requests\nfrom flexget.utils.soup import get_soup\nfrom flexget.utils.search import torrent_availability, normalize_unicode\nfrom flexget.utils.tools import parse_filesize\n\nlog = logging.getLogger('torrentday')\n\nCATEGORIES = {\n    'all': 0,\n    # Movies\n    'mov480p': 25,\n    'movHD': 11,\n    'movBD': 5,\n    'movDVD': 3,\n    'movMP4': 21,\n    'movNonEnglish': 22,\n    'movPACKS': 13,\n    'movSDx264': 44,\n    'movX265': 48,\n    'movXVID': 1,\n\n    # TV\n    'tv480p': 24,\n    'tvBRD': 32,\n    'tvDVD': 31,\n    'tvDVDrip': 33,\n    'tvMOBILE': 46,\n    'tvPACKS': 14,\n    'tvSDx264': 26,\n    'tvHDx264': 7,\n    'tvX265': 34,\n    'tvXVID': 2\n}\n\n\nclass UrlRewriteTorrentday(object):\n    \"\"\"\n        Torrentday urlrewriter and search plugin.\n\n        torrentday:\n          uid: xxxxxxxxxxxxx  (required)    NOT YOUR LOGIN. find this in your browser's cookies\n          passkey: xxxxxxxxx  (required)    NOT YOUR PASSWORD. see previous\n          cfduid: xxxxxxxxxx  (required)    AGAIN IN THE COOKIES\n          rss_key: xxxxxxxxx  (required)    get this from your profile page\n          category: xxxxxxxx\n\n          Category can be one of \n            ID from browsing site OR 'name'\n            movies:\n              mov480p, movHD, movBD, movDVD,\n              movMP4, movNonEnglish, movPACKS,\n              movSDx264, movX265, movXVID\n            tv:\n              tv480p, tvBRD, tvDVD, tvDVDrip,\n              tvMOBILE, tvPACKS, tvSDx264, \n              tvHDx264, tvX265, tvXVID\n    \"\"\"\n\n    schema = {\n        'type': 'object',\n        'properties': {\n            'rss_key': {'type': 'string'},\n            'uid': {'type': 'string'},\n            'passkey': {'type': 'string'},\n            'cfduid': {'type': 'string'},\n            'category': {\n                'oneOf': [\n                    {'type': 'integer'},\n                    {'type': 'string', 'enum': list(CATEGORIES)},\n                ]\n            },\n        },\n        'required': ['rss_key', 'uid', 'passkey', 'cfduid'],\n        'additionalProperties': False\n    }\n\n    # urlrewriter API\n    def url_rewritable(self, task, entry):\n        url = entry['url']\n        if url.find('.torrent'):\n            return False\n        if url.startswith('https://www.torrentday.com'):\n            return True\n        return False\n\n    # urlrewriter API\n    def url_rewrite(self, task, entry):\n        if 'url' not in entry:\n            log.error('Didn\\'t actually get a URL...')\n        else:\n            log.debug('Got the URL: %s', entry['url'])\n        if entry['url'].startswith('https://www.torrentday.com/browse'):\n            # use search\n            results = self.search(task, entry)\n            if not results:\n                raise UrlRewritingError('No search results found')\n            entry['url'] = results[0]['url']\n\n    @plugin.internet(log)\n    def search(self, task, entry, config=None):\n        \"\"\"\n        Search for name from torrentday.\n        \"\"\"\n\n        categories = config.get('category', 'all')\n        # Make sure categories is a list\n        if not isinstance(categories, list):\n            categories = [categories]\n        # If there are any text categories, turn them into their id number\n        categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories]\n        params = { 'cata': 'yes', 'c%s' % ','.join(str(c) for c in categories): 1, 'clear-new': 1}\n        entries = set()\n        for search_string in entry.get('search_strings', [entry['title']]):\n\n            url = 'https://www.torrentday.com/browse.php'\n            params['search'] = normalize_unicode(search_string).replace(':', '')\n            cookies = { 'uid': config['uid'], 'pass': config['passkey'], '__cfduid': config['cfduid'] }\n\n            try:\n                page = requests.get(url, params=params, cookies=cookies).content\n            except RequestException as e:\n                raise PluginError('Could not connect to torrentday: %s' % e)\n\n            soup = get_soup(page)\n\n            for tr in soup.find_all('tr', { 'class': 'browse' }):\n                entry = Entry()\n                # find the torrent names\n                title = tr.find('a', { 'class': 'torrentName' })\n                entry['title'] = title.contents[0]\n                log.debug('title: %s', title.contents[0])\n\n                # find download link\n                torrent_url = tr.find('td', { 'class': 'dlLinksInfo' })\n                torrent_url = torrent_url.find('a').get('href')\n\n                # construct download URL\n                torrent_url = ( 'https://www.torrentday.com/' + torrent_url + '?torrent_pass=' + config['rss_key'] )\n                log.debug('RSS-ified download link: %s', torrent_url)\n                entry['url'] = torrent_url\n\n                # us tr object for seeders/leechers\n                seeders, leechers = tr.find_all('td', { 'class': ['seedersInfo', 'leechersInfo']})\n                entry['torrent_seeds'] = int(seeders.contents[0].replace(',', ''))\n                entry['torrent_leeches'] = int(leechers.contents[0].replace(',', ''))\n                entry['search_sort'] = torrent_availability(entry['torrent_seeds'], entry['torrent_leeches'])\n\n                # use tr object for size\n                size = tr.find('td', text=re.compile('([\\.\\d]+) ([TGMKk]?)B')).contents[0]\n                size = re.search('([\\.\\d]+) ([TGMKk]?)B', str(size))\n\n                entry['content_size'] = parse_filesize(size.group(0))\n\n                entries.add(entry)\n\n        return sorted(entries, reverse=True, key=lambda x: x.get('search_sort'))\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(UrlRewriteTorrentday, 'torrentday', interfaces=['urlrewriter', 'search'], api_ver=2)\n", "path": "flexget/plugins/sites/torrentday.py"}], "after_files": [{"content": "from __future__ import unicode_literals, division, absolute_import\nfrom builtins import *  # noqa pylint: disable=unused-import, redefined-builtin\nfrom future.moves.urllib.parse import quote\n\nimport re\nimport logging\n\nfrom requests.exceptions import RequestException\n\nfrom flexget import plugin\nfrom flexget.config_schema import one_or_more\nfrom flexget.entry import Entry\nfrom flexget.event import event\nfrom flexget.plugin import PluginError\nfrom flexget.plugins.internal.urlrewriting import UrlRewritingError\nfrom flexget.utils import requests\nfrom flexget.utils.soup import get_soup\nfrom flexget.utils.search import torrent_availability, normalize_unicode\nfrom flexget.utils.tools import parse_filesize\n\nlog = logging.getLogger('torrentday')\n\nCATEGORIES = {\n    'all': 0,\n    # Movies\n    'mov480p': 25,\n    'movHD': 11,\n    'movBD': 5,\n    'movDVD': 3,\n    'movMP4': 21,\n    'movNonEnglish': 22,\n    'movPACKS': 13,\n    'movSDx264': 44,\n    'movX265': 48,\n    'movXVID': 1,\n\n    # TV\n    'tv480p': 24,\n    'tvBRD': 32,\n    'tvDVD': 31,\n    'tvDVDrip': 33,\n    'tvMOBILE': 46,\n    'tvPACKS': 14,\n    'tvSDx264': 26,\n    'tvHDx264': 7,\n    'tvX265': 34,\n    'tvXVID': 2\n}\n\n\nclass UrlRewriteTorrentday(object):\n    \"\"\"\n        Torrentday urlrewriter and search plugin.\n\n        torrentday:\n          uid: xxxxxxxxxxxxx  (required)    NOT YOUR LOGIN. find this in your browser's cookies\n          passkey: xxxxxxxxx  (required)    NOT YOUR PASSWORD. see previous\n          cfduid: xxxxxxxxxx  (required)    AGAIN IN THE COOKIES\n          rss_key: xxxxxxxxx  (required)    get this from your profile page\n          category: xxxxxxxx\n\n          Category can be one of \n            ID from browsing site OR 'name'\n            movies:\n              mov480p, movHD, movBD, movDVD,\n              movMP4, movNonEnglish, movPACKS,\n              movSDx264, movX265, movXVID\n            tv:\n              tv480p, tvBRD, tvDVD, tvDVDrip,\n              tvMOBILE, tvPACKS, tvSDx264, \n              tvHDx264, tvX265, tvXVID\n    \"\"\"\n\n    schema = {\n        'type': 'object',\n        'properties': {\n            'rss_key': {'type': 'string'},\n            'uid': {'type': 'string'},\n            'passkey': {'type': 'string'},\n            'cfduid': {'type': 'string'},\n            'category': {\n                'oneOf': [\n                    {'type': 'integer'},\n                    {'type': 'string', 'enum': list(CATEGORIES)},\n                ]\n            },\n        },\n        'required': ['rss_key', 'uid', 'passkey', 'cfduid'],\n        'additionalProperties': False\n    }\n\n    # urlrewriter API\n    def url_rewritable(self, task, entry):\n        url = entry['url']\n        if url.find('.torrent'):\n            return False\n        if url.startswith('https://www.torrentday.com'):\n            return True\n        return False\n\n    # urlrewriter API\n    def url_rewrite(self, task, entry):\n        if 'url' not in entry:\n            log.error('Didn\\'t actually get a URL...')\n        else:\n            log.debug('Got the URL: %s', entry['url'])\n        if entry['url'].startswith('https://www.torrentday.com/browse'):\n            # use search\n            results = self.search(task, entry)\n            if not results:\n                raise UrlRewritingError('No search results found')\n            entry['url'] = results[0]['url']\n\n    @plugin.internet(log)\n    def search(self, task, entry, config=None):\n        \"\"\"\n        Search for name from torrentday.\n        \"\"\"\n\n        categories = config.get('category', 'all')\n        # Make sure categories is a list\n        if not isinstance(categories, list):\n            categories = [categories]\n        # If there are any text categories, turn them into their id number\n        categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories]\n        params = { 'cata': 'yes', 'c{}'.format(','.join(str(c) for c in categories)): 1, 'clear-new': 1}\n        entries = set()\n        for search_string in entry.get('search_strings', [entry['title']]):\n\n            url = 'https://www.torrentday.com/t'\n            params['q'] = normalize_unicode(search_string).replace(':', '')\n            cookies = { 'uid': config['uid'], 'pass': config['passkey'], '__cfduid': config['cfduid'] }\n\n            try:\n                page = requests.get(url, params=params, cookies=cookies).content\n            except RequestException as e:\n                raise PluginError('Could not connect to torrentday: {}'.format(e))\n\n            soup = get_soup(page)\n            # the first row is the header so skip it\n            for tr in soup.find_all('tr')[1:]:\n                entry = Entry()\n                # find the torrent names\n                td = tr.find('td', { 'class': 'torrentNameInfo' })\n                if not td:\n                    log.warning('Could not find entry torrentNameInfo for %s.', search_string)\n                    continue\n                title = td.find('a')\n                if not title:\n                    log.warning('Could not determine title for %s.', search_string)\n                    continue\n                entry['title'] = title.contents[0]\n                log.debug('title: %s', title.contents[0])\n\n                # find download link\n                torrent_url = tr.find('td', { 'class': 'ac' })\n                if not torrent_url:\n                    log.warning('Could not determine download link for %s.', search_string)\n                    continue\n                torrent_url = torrent_url.find('a').get('href')\n\n                # construct download URL\n                torrent_url = ( 'https://www.torrentday.com/' + torrent_url + '?torrent_pass=' + config['rss_key'] )\n                log.debug('RSS-ified download link: %s', torrent_url)\n                entry['url'] = torrent_url\n\n                # us tr object for seeders/leechers\n                seeders = tr.find_all('td', { 'class': 'ac seedersInfo'})\n                leechers = tr.find_all('td', { 'class': 'ac leechersInfo'})\n                entry['torrent_seeds'] = int(seeders.contents[0].replace(',', ''))\n                entry['torrent_leeches'] = int(leechers.contents[0].replace(',', ''))\n                entry['search_sort'] = torrent_availability(entry['torrent_seeds'], entry['torrent_leeches'])\n\n                # use tr object for size\n                size = tr.find('td', text=re.compile('([\\.\\d]+) ([TGMKk]?)B')).contents[0]\n                size = re.search('([\\.\\d]+) ([TGMKk]?)B', str(size))\n\n                entry['content_size'] = parse_filesize(size.group(0))\n\n                entries.add(entry)\n\n        return sorted(entries, reverse=True, key=lambda x: x.get('search_sort'))\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(UrlRewriteTorrentday, 'torrentday', interfaces=['urlrewriter', 'search'], api_ver=2)\n", "path": "flexget/plugins/sites/torrentday.py"}]}