We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Unexpected crash in plugin discover: NoneType object has no attribute 'text'
### Expected behaviour:
List of new episodes are sent to remote deluge daemon
### Actual behaviour:
Unexpected crash has occurred. 
BUG: Unhandled error in plugin discover: 'NoneType' object has no attribute 'text'

### Steps to reproduce:
I can reproduce it using my config, but I'm unable to figure out how to gather more detailed information (aside from setting flexget's log to debug).

This issue didn't start occurring until I updated flexget to the latest version. Since then, I've tried the latest version as well as the development version. I've even tried different versions of Python. At the time of this writing, I'm using:

flexget 2.9.7.dev
python 2.7.9

I'm pretty new at flexget, but I think the issue with related with this search string:
https://iptorrents.com/t?4=&5=&22=&q=Teen+Wolf+S06E08&qf=


#### Config:
http://pastebin.com/6sLVmUSe

#### Log:
http://pastebin.com/AY1pqZuP

### Additional information:

- Flexget Version: 2.9.7.dev
- Python Version: 2.7.9
- Installation method:  https://flexget.com/GitHubInstall
- OS and version: running docker container phusion/baseimage
- Link to crash log: http://pastebin.com/cweVDm9S

<!---
Please verify that the following data is present before submitting your issue:

- Paste or link to a paste service (http://pastebin.com/ for example) of relevant config (preferably full config including templates if present. Remember to redact any personal information! Please make sure the paste does not expire, if possible.
- Paste or link to a paste service of debug level logs of relevant task/s. Use `flexget -L debug execute --tasks <Task_name>`
- Flexget version (Use `flexget -V` to get it).
- Full Python version (`2.7.11` for example). Run `python -V` to get it.
- Installation method (pip, git install, etc.)
- OS and version
- Attach crash log if available
--->


--- 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/iptorrents.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_plus
4 
5 import re
6 import logging
7 
8 from flexget import plugin
9 from flexget.config_schema import one_or_more
10 from flexget.entry import Entry
11 from flexget.event import event
12 from flexget.plugins.internal.urlrewriting import UrlRewritingError
13 from flexget.utils import requests
14 from flexget.utils.soup import get_soup
15 from flexget.utils.search import torrent_availability, normalize_unicode
16 from flexget.utils.tools import parse_filesize
17 
18 log = logging.getLogger('iptorrents')
19 
20 CATEGORIES = {
21 
22     # Movies
23     'Movie-all': 72,
24     'Movie-3D': 87,
25     'Movie-480p': 77,
26     'Movie-BD-R': 89,
27     'Movie-BD-Rip': 90,
28     'Movie-DVD-R': 6,
29     'Movie-HD-Bluray': 48,
30     'Movie-Kids': 54,
31     'Movie-MP4': 62,
32     'Movie-Non-English': 38,
33     'Movie-Packs': 68,
34     'Movie-XviD': 17,
35 
36     # TV
37     'TV-all': 73,
38     'TV-Sports': 55,
39     'TV-480p': 78,
40     'TV-MP4': 66,
41     'TV-Non-English': 82,
42     'TV-Packs': 65,
43     'TV-Packs-Non-English': 83,
44     'TV-SD-x264': 79,
45     'TV-x264': 5,
46     'TV-XVID': 4,
47     'TV-Web-DL': 22
48 }
49 
50 BASE_URL = 'https://iptorrents.com'
51 
52 
53 class UrlRewriteIPTorrents(object):
54     """
55         IpTorrents urlrewriter and search plugin.
56 
57         iptorrents:
58           rss_key: xxxxxxxxx  (required)
59           uid: xxxxxxxx  (required)
60           password: xxxxxxxx  (required)
61           category: HD
62 
63           Category is any combination of: all, Movie-3D, Movie-480p, Movie-3D,
64                 Movie-480p, Movie-BD-R, Movie-BD-Rip, Movie-DVD-R,
65                 Movie-HD-Bluray, Movie-Kids, Movie-MP4,
66                 Movie-Non-English, Movie-Packs, Movie-XviD,
67 
68                 TV-all, TV-Sports, TV-480p, TV-MP4, TV-Non-English, TV-Packs,
69                 TV-Packs-Non-English, TV-SD-x264, TV-x264, TV-XVID, TV-Web-DL
70     """
71 
72     schema = {
73         'type': 'object',
74         'properties': {
75             'rss_key': {'type': 'string'},
76             'uid': {'oneOf': [
77                 {'type': 'integer'},
78                 {'type': 'string'}
79             ]},
80             'password': {'type': 'string'},
81             'category': one_or_more({
82                 'oneOf': [
83                     {'type': 'integer'},
84                     {'type': 'string', 'enum': list(CATEGORIES)},
85                 ]}),
86         },
87         'required': ['rss_key', 'uid', 'password'],
88         'additionalProperties': False
89     }
90 
91     # urlrewriter API
92     def url_rewritable(self, task, entry):
93         url = entry['url']
94         if url.startswith(BASE_URL + '/download.php/'):
95             return False
96         if url.startswith(BASE_URL + '/'):
97             return True
98         return False
99 
100     # urlrewriter API
101     def url_rewrite(self, task, entry):
102         if 'url' not in entry:
103             log.error("Didn't actually get a URL...")
104         else:
105             log.debug("Got the URL: %s" % entry['url'])
106         if entry['url'].startswith(BASE_URL + '/t?'):
107             # use search
108             results = self.search(task, entry)
109             if not results:
110                 raise UrlRewritingError("No search results found")
111             # TODO: Search doesn't enforce close match to title, be more picky
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 iptorrents
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 
125         # If there are any text categories, turn them into their id number
126         categories = [c if isinstance(c, int) else CATEGORIES[c]
127                       for c in categories]
128         filter_url = '&'.join((str(c) + '=') for c in categories)
129 
130         entries = set()
131 
132         for search_string in entry.get('search_strings', [entry['title']]):
133             query = normalize_unicode(search_string)
134             query = quote_plus(query.encode('utf8'))
135 
136             url = "{base_url}/t?{filter}&q={query}&qf=".format(base_url=BASE_URL, filter=filter_url, query=query)
137             log.debug('searching with url: %s' % url)
138             req = requests.get(url, cookies={'uid': str(config['uid']), 'pass': config['password']})
139 
140             if '/u/' + str(config.get('uid')) not in req.content:
141                 raise plugin.PluginError("Invalid cookies (user not logged in)...")
142 
143             soup = get_soup(req.content, parser="html.parser")
144             torrents = soup.find('table', {'id': 'torrents'})
145 
146             for torrent in torrents.findAll('a', href=re.compile('\.torrent$')):
147                 entry = Entry()
148                 entry['url'] = "{base}{link}?torrent_pass={key}".format(
149                     base=BASE_URL, link=torrent['href'], key=config.get('rss_key'))
150                 entry['title'] = torrent.findPrevious("a", attrs={'class': 't_title'}).text
151 
152                 seeders = torrent.findNext('td', {'class': 'ac t_seeders'}).text
153                 leechers = torrent.findNext('td', {'class': 'ac t_leechers'}).text
154                 entry['torrent_seeds'] = int(seeders)
155                 entry['torrent_leeches'] = int(leechers)
156                 entry['search_sort'] = torrent_availability(entry['torrent_seeds'],
157                                                             entry['torrent_leeches'])
158 
159                 size = torrent.findNext(text=re.compile('^([\.\d]+) ([GMK]?)B$'))
160                 size = re.search('^([\.\d]+) ([GMK]?)B$', size)
161 
162                 entry['content_size'] = parse_filesize(size.group(0))
163 
164                 entries.add(entry)
165 
166         return entries
167 
168 
169 @event('plugin.register')
170 def register_plugin():
171     plugin.register(UrlRewriteIPTorrents, 'iptorrents', interfaces=['urlrewriter', 'search'], api_ver=2)
172
```
--- 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/iptorrents.py b/flexget/plugins/sites/iptorrents.py
--- a/flexget/plugins/sites/iptorrents.py
+++ b/flexget/plugins/sites/iptorrents.py
@@ -137,7 +137,7 @@
             log.debug('searching with url: %s' % url)
             req = requests.get(url, cookies={'uid': str(config['uid']), 'pass': config['password']})
 
-            if '/u/' + str(config.get('uid')) not in req.content:
+            if '/u/' + str(config['uid']) not in req.text:
                 raise plugin.PluginError("Invalid cookies (user not logged in)...")
 
             soup = get_soup(req.content, parser="html.parser")
@@ -147,7 +147,7 @@
                 entry = Entry()
                 entry['url'] = "{base}{link}?torrent_pass={key}".format(
                     base=BASE_URL, link=torrent['href'], key=config.get('rss_key'))
-                entry['title'] = torrent.findPrevious("a", attrs={'class': 't_title'}).text
+                entry['title'] = torrent.findPrevious('a', attrs={'class': 'b'}).text
 
                 seeders = torrent.findNext('td', {'class': 'ac t_seeders'}).text
                 leechers = torrent.findNext('td', {'class': 'ac t_leechers'}).text

{"golden_diff": "diff --git a/flexget/plugins/sites/iptorrents.py b/flexget/plugins/sites/iptorrents.py\n--- a/flexget/plugins/sites/iptorrents.py\n+++ b/flexget/plugins/sites/iptorrents.py\n@@ -137,7 +137,7 @@\n             log.debug('searching with url: %s' % url)\n             req = requests.get(url, cookies={'uid': str(config['uid']), 'pass': config['password']})\n \n-            if '/u/' + str(config.get('uid')) not in req.content:\n+            if '/u/' + str(config['uid']) not in req.text:\n                 raise plugin.PluginError(\"Invalid cookies (user not logged in)...\")\n \n             soup = get_soup(req.content, parser=\"html.parser\")\n@@ -147,7 +147,7 @@\n                 entry = Entry()\n                 entry['url'] = \"{base}{link}?torrent_pass={key}\".format(\n                     base=BASE_URL, link=torrent['href'], key=config.get('rss_key'))\n-                entry['title'] = torrent.findPrevious(\"a\", attrs={'class': 't_title'}).text\n+                entry['title'] = torrent.findPrevious('a', attrs={'class': 'b'}).text\n \n                 seeders = torrent.findNext('td', {'class': 'ac t_seeders'}).text\n                 leechers = torrent.findNext('td', {'class': 'ac t_leechers'}).text\n", "issue": "Unexpected crash in plugin discover: NoneType object has no attribute 'text'\n### Expected behaviour:\r\nList of new episodes are sent to remote deluge daemon\r\n### Actual behaviour:\r\nUnexpected crash has occurred. \r\nBUG: Unhandled error in plugin discover: 'NoneType' object has no attribute 'text'\r\n\r\n### Steps to reproduce:\r\nI can reproduce it using my config, but I'm unable to figure out how to gather more detailed information (aside from setting flexget's log to debug).\r\n\r\nThis issue didn't start occurring until I updated flexget to the latest version. Since then, I've tried the latest version as well as the development version. I've even tried different versions of Python. At the time of this writing, I'm using:\r\n\r\nflexget 2.9.7.dev\r\npython 2.7.9\r\n\r\nI'm pretty new at flexget, but I think the issue with related with this search string:\r\nhttps://iptorrents.com/t?4=&5=&22=&q=Teen+Wolf+S06E08&qf=\r\n\r\n\r\n#### Config:\r\nhttp://pastebin.com/6sLVmUSe\r\n\r\n#### Log:\r\nhttp://pastebin.com/AY1pqZuP\r\n\r\n### Additional information:\r\n\r\n- Flexget Version: 2.9.7.dev\r\n- Python Version: 2.7.9\r\n- Installation method:  https://flexget.com/GitHubInstall\r\n- OS and version: running docker container phusion/baseimage\r\n- Link to crash log: http://pastebin.com/cweVDm9S\r\n\r\n<!---\r\nPlease verify that the following data is present before submitting your issue:\r\n\r\n- Paste or link to a paste service (http://pastebin.com/ for example) of relevant config (preferably full config including templates if present. Remember to redact any personal information! Please make sure the paste does not expire, if possible.\r\n- Paste or link to a paste service of debug level logs of relevant task/s. Use `flexget -L debug execute --tasks <Task_name>`\r\n- Flexget version (Use `flexget -V` to get it).\r\n- Full Python version (`2.7.11` for example). Run `python -V` to get it.\r\n- Installation method (pip, git install, etc.)\r\n- OS and version\r\n- Attach crash log if available\r\n--->\r\n\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_plus\n\nimport re\nimport logging\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.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('iptorrents')\n\nCATEGORIES = {\n\n    # Movies\n    'Movie-all': 72,\n    'Movie-3D': 87,\n    'Movie-480p': 77,\n    'Movie-BD-R': 89,\n    'Movie-BD-Rip': 90,\n    'Movie-DVD-R': 6,\n    'Movie-HD-Bluray': 48,\n    'Movie-Kids': 54,\n    'Movie-MP4': 62,\n    'Movie-Non-English': 38,\n    'Movie-Packs': 68,\n    'Movie-XviD': 17,\n\n    # TV\n    'TV-all': 73,\n    'TV-Sports': 55,\n    'TV-480p': 78,\n    'TV-MP4': 66,\n    'TV-Non-English': 82,\n    'TV-Packs': 65,\n    'TV-Packs-Non-English': 83,\n    'TV-SD-x264': 79,\n    'TV-x264': 5,\n    'TV-XVID': 4,\n    'TV-Web-DL': 22\n}\n\nBASE_URL = 'https://iptorrents.com'\n\n\nclass UrlRewriteIPTorrents(object):\n    \"\"\"\n        IpTorrents urlrewriter and search plugin.\n\n        iptorrents:\n          rss_key: xxxxxxxxx  (required)\n          uid: xxxxxxxx  (required)\n          password: xxxxxxxx  (required)\n          category: HD\n\n          Category is any combination of: all, Movie-3D, Movie-480p, Movie-3D,\n                Movie-480p, Movie-BD-R, Movie-BD-Rip, Movie-DVD-R,\n                Movie-HD-Bluray, Movie-Kids, Movie-MP4,\n                Movie-Non-English, Movie-Packs, Movie-XviD,\n\n                TV-all, TV-Sports, TV-480p, TV-MP4, TV-Non-English, TV-Packs,\n                TV-Packs-Non-English, TV-SD-x264, TV-x264, TV-XVID, TV-Web-DL\n    \"\"\"\n\n    schema = {\n        'type': 'object',\n        'properties': {\n            'rss_key': {'type': 'string'},\n            'uid': {'oneOf': [\n                {'type': 'integer'},\n                {'type': 'string'}\n            ]},\n            'password': {'type': 'string'},\n            'category': one_or_more({\n                'oneOf': [\n                    {'type': 'integer'},\n                    {'type': 'string', 'enum': list(CATEGORIES)},\n                ]}),\n        },\n        'required': ['rss_key', 'uid', 'password'],\n        'additionalProperties': False\n    }\n\n    # urlrewriter API\n    def url_rewritable(self, task, entry):\n        url = entry['url']\n        if url.startswith(BASE_URL + '/download.php/'):\n            return False\n        if url.startswith(BASE_URL + '/'):\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(BASE_URL + '/t?'):\n            # use search\n            results = self.search(task, entry)\n            if not results:\n                raise UrlRewritingError(\"No search results found\")\n            # TODO: Search doesn't enforce close match to title, be more picky\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 iptorrents\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\n        # If there are any text categories, turn them into their id number\n        categories = [c if isinstance(c, int) else CATEGORIES[c]\n                      for c in categories]\n        filter_url = '&'.join((str(c) + '=') for c in categories)\n\n        entries = set()\n\n        for search_string in entry.get('search_strings', [entry['title']]):\n            query = normalize_unicode(search_string)\n            query = quote_plus(query.encode('utf8'))\n\n            url = \"{base_url}/t?{filter}&q={query}&qf=\".format(base_url=BASE_URL, filter=filter_url, query=query)\n            log.debug('searching with url: %s' % url)\n            req = requests.get(url, cookies={'uid': str(config['uid']), 'pass': config['password']})\n\n            if '/u/' + str(config.get('uid')) not in req.content:\n                raise plugin.PluginError(\"Invalid cookies (user not logged in)...\")\n\n            soup = get_soup(req.content, parser=\"html.parser\")\n            torrents = soup.find('table', {'id': 'torrents'})\n\n            for torrent in torrents.findAll('a', href=re.compile('\\.torrent$')):\n                entry = Entry()\n                entry['url'] = \"{base}{link}?torrent_pass={key}\".format(\n                    base=BASE_URL, link=torrent['href'], key=config.get('rss_key'))\n                entry['title'] = torrent.findPrevious(\"a\", attrs={'class': 't_title'}).text\n\n                seeders = torrent.findNext('td', {'class': 'ac t_seeders'}).text\n                leechers = torrent.findNext('td', {'class': 'ac t_leechers'}).text\n                entry['torrent_seeds'] = int(seeders)\n                entry['torrent_leeches'] = int(leechers)\n                entry['search_sort'] = torrent_availability(entry['torrent_seeds'],\n                                                            entry['torrent_leeches'])\n\n                size = torrent.findNext(text=re.compile('^([\\.\\d]+) ([GMK]?)B$'))\n                size = re.search('^([\\.\\d]+) ([GMK]?)B$', size)\n\n                entry['content_size'] = parse_filesize(size.group(0))\n\n                entries.add(entry)\n\n        return entries\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(UrlRewriteIPTorrents, 'iptorrents', interfaces=['urlrewriter', 'search'], api_ver=2)\n", "path": "flexget/plugins/sites/iptorrents.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_plus\n\nimport re\nimport logging\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.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('iptorrents')\n\nCATEGORIES = {\n\n    # Movies\n    'Movie-all': 72,\n    'Movie-3D': 87,\n    'Movie-480p': 77,\n    'Movie-BD-R': 89,\n    'Movie-BD-Rip': 90,\n    'Movie-DVD-R': 6,\n    'Movie-HD-Bluray': 48,\n    'Movie-Kids': 54,\n    'Movie-MP4': 62,\n    'Movie-Non-English': 38,\n    'Movie-Packs': 68,\n    'Movie-XviD': 17,\n\n    # TV\n    'TV-all': 73,\n    'TV-Sports': 55,\n    'TV-480p': 78,\n    'TV-MP4': 66,\n    'TV-Non-English': 82,\n    'TV-Packs': 65,\n    'TV-Packs-Non-English': 83,\n    'TV-SD-x264': 79,\n    'TV-x264': 5,\n    'TV-XVID': 4,\n    'TV-Web-DL': 22\n}\n\nBASE_URL = 'https://iptorrents.com'\n\n\nclass UrlRewriteIPTorrents(object):\n    \"\"\"\n        IpTorrents urlrewriter and search plugin.\n\n        iptorrents:\n          rss_key: xxxxxxxxx  (required)\n          uid: xxxxxxxx  (required)\n          password: xxxxxxxx  (required)\n          category: HD\n\n          Category is any combination of: all, Movie-3D, Movie-480p, Movie-3D,\n                Movie-480p, Movie-BD-R, Movie-BD-Rip, Movie-DVD-R,\n                Movie-HD-Bluray, Movie-Kids, Movie-MP4,\n                Movie-Non-English, Movie-Packs, Movie-XviD,\n\n                TV-all, TV-Sports, TV-480p, TV-MP4, TV-Non-English, TV-Packs,\n                TV-Packs-Non-English, TV-SD-x264, TV-x264, TV-XVID, TV-Web-DL\n    \"\"\"\n\n    schema = {\n        'type': 'object',\n        'properties': {\n            'rss_key': {'type': 'string'},\n            'uid': {'oneOf': [\n                {'type': 'integer'},\n                {'type': 'string'}\n            ]},\n            'password': {'type': 'string'},\n            'category': one_or_more({\n                'oneOf': [\n                    {'type': 'integer'},\n                    {'type': 'string', 'enum': list(CATEGORIES)},\n                ]}),\n        },\n        'required': ['rss_key', 'uid', 'password'],\n        'additionalProperties': False\n    }\n\n    # urlrewriter API\n    def url_rewritable(self, task, entry):\n        url = entry['url']\n        if url.startswith(BASE_URL + '/download.php/'):\n            return False\n        if url.startswith(BASE_URL + '/'):\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(BASE_URL + '/t?'):\n            # use search\n            results = self.search(task, entry)\n            if not results:\n                raise UrlRewritingError(\"No search results found\")\n            # TODO: Search doesn't enforce close match to title, be more picky\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 iptorrents\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\n        # If there are any text categories, turn them into their id number\n        categories = [c if isinstance(c, int) else CATEGORIES[c]\n                      for c in categories]\n        filter_url = '&'.join((str(c) + '=') for c in categories)\n\n        entries = set()\n\n        for search_string in entry.get('search_strings', [entry['title']]):\n            query = normalize_unicode(search_string)\n            query = quote_plus(query.encode('utf8'))\n\n            url = \"{base_url}/t?{filter}&q={query}&qf=\".format(base_url=BASE_URL, filter=filter_url, query=query)\n            log.debug('searching with url: %s' % url)\n            req = requests.get(url, cookies={'uid': str(config['uid']), 'pass': config['password']})\n\n            if '/u/' + str(config['uid']) not in req.text:\n                raise plugin.PluginError(\"Invalid cookies (user not logged in)...\")\n\n            soup = get_soup(req.content, parser=\"html.parser\")\n            torrents = soup.find('table', {'id': 'torrents'})\n\n            for torrent in torrents.findAll('a', href=re.compile('\\.torrent$')):\n                entry = Entry()\n                entry['url'] = \"{base}{link}?torrent_pass={key}\".format(\n                    base=BASE_URL, link=torrent['href'], key=config.get('rss_key'))\n                entry['title'] = torrent.findPrevious('a', attrs={'class': 'b'}).text\n\n                seeders = torrent.findNext('td', {'class': 'ac t_seeders'}).text\n                leechers = torrent.findNext('td', {'class': 'ac t_leechers'}).text\n                entry['torrent_seeds'] = int(seeders)\n                entry['torrent_leeches'] = int(leechers)\n                entry['search_sort'] = torrent_availability(entry['torrent_seeds'],\n                                                            entry['torrent_leeches'])\n\n                size = torrent.findNext(text=re.compile('^([\\.\\d]+) ([GMK]?)B$'))\n                size = re.search('^([\\.\\d]+) ([GMK]?)B$', size)\n\n                entry['content_size'] = parse_filesize(size.group(0))\n\n                entries.add(entry)\n\n        return entries\n\n\n@event('plugin.register')\ndef register_plugin():\n    plugin.register(UrlRewriteIPTorrents, 'iptorrents', interfaces=['urlrewriter', 'search'], api_ver=2)\n", "path": "flexget/plugins/sites/iptorrents.py"}]}