We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
HeBits provider failed to find HD torrents
When using 'html5lib' HeBits provider failed to find HD torrents (720p) for me.
Switching to with BS4Parser(data, 'html.parser') as html: fix the issue for me.

Please consider to switch to html.parser or fixing html5lib search.



--- 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/html/hebits.py`
Content:
```
1 # coding=utf-8
2 
3 """Provider code for HeBits."""
4 
5 from __future__ import unicode_literals
6 
7 import logging
8 import re
9 
10 from medusa import tv
11 from medusa.bs4_parser import BS4Parser
12 from medusa.helper.common import (
13     convert_size,
14     try_int,
15 )
16 from medusa.logger.adapters.style import BraceAdapter
17 from medusa.providers.torrent.torrent_provider import TorrentProvider
18 
19 from requests.compat import urljoin
20 from requests.utils import dict_from_cookiejar
21 
22 log = BraceAdapter(logging.getLogger(__name__))
23 log.logger.addHandler(logging.NullHandler())
24 
25 
26 class HeBitsProvider(TorrentProvider):
27     """HeBits Torrent provider."""
28 
29     def __init__(self):
30         """Initialize the class."""
31         super(HeBitsProvider, self).__init__('HeBits')
32 
33         # Credentials
34         self.username = None
35         self.password = None
36 
37         # URLs
38         self.url = 'https://hebits.net'
39         self.urls = {
40             'login': urljoin(self.url, 'takeloginAjax.php'),
41             'search': urljoin(self.url, 'browse.php'),
42         }
43 
44         # Proper Strings
45         self.proper_strings = ['PROPER', 'REPACK', 'REAL', 'RERIP']
46 
47         # Miscellaneous Options
48         self.freeleech = False
49 
50         # Torrent Stats
51         self.minseed = None
52         self.minleech = None
53 
54         # Cache
55         self.cache = tv.Cache(self)
56 
57     def search(self, search_strings, age=0, ep_obj=None, **kwargs):
58         """
59         Search a provider and parse the results.
60 
61         :param search_strings: A dict with mode (key) and the search value (value)
62         :param age: Not used
63         :param ep_obj: Not used
64         :returns: A list of search results (structure)
65         """
66         results = []
67         if not self.login():
68             return results
69 
70         # Search Params
71         # Israeli SD , English SD , Israeli HD , English HD
72         # 7          , 24         , 37         , 1
73         search_params = {
74             'c1': '1',
75             'c24': '1',
76             'c37': '1',
77             'c7': '1',
78             'search': '',
79             'cata': '0',
80         }
81         if self.freeleech:
82             search_params['free'] = 'on'
83 
84         for mode in search_strings:
85             log.debug('Search mode: {0}', mode)
86 
87             for search_string in search_strings[mode]:
88 
89                 if mode != 'RSS':
90                     search_params['search'] = search_string
91                     log.debug('Search string: {search}',
92                               {'search': search_string})
93 
94                 response = self.session.get(self.urls['search'], params=search_params)
95                 if not response or not response.text:
96                     log.debug('No data returned from provider')
97                     continue
98 
99                 results += self.parse(response.text, mode)
100 
101         return results
102 
103     def parse(self, data, mode):
104         """
105         Parse search results for items.
106 
107         :param data: The raw response from a search
108         :param mode: The current mode used to search, e.g. RSS
109 
110         :return: A list of items found
111         """
112         items = []
113 
114         with BS4Parser(data, 'html5lib') as html:
115             torrent_table = html.find('div', class_='browse')
116             torrent_rows = torrent_table('div', class_=re.compile('^line')) if torrent_table else []
117 
118             # Continue only if at least one release is found
119             if len(torrent_rows) < 1:
120                 log.debug('Data returned from provider does not contain any torrents')
121                 return items
122 
123             for row in torrent_rows:
124                 try:
125                     heb_eng_title = row.find('div', class_='bTitle').find(href=re.compile('details\.php')).find('b').get_text()
126                     if '/' in heb_eng_title:
127                         title = heb_eng_title.split('/')[1].strip()
128                     elif '\\' in heb_eng_title:
129                         title = heb_eng_title.split('\\')[1].strip()
130                     else:
131                         continue
132 
133                     download_id = row.find('div', class_='bTitle').find(href=re.compile('download\.php'))['href']
134 
135                     if not all([title, download_id]):
136                         continue
137 
138                     download_url = urljoin(self.url, download_id)
139 
140                     seeders = try_int(row.find('div', class_='bUping').get_text(strip=True))
141                     leechers = try_int(row.find('div', class_='bDowning').get_text(strip=True))
142 
143                     # Filter unseeded torrent
144                     if seeders < min(self.minseed, 1):
145                         if mode != 'RSS':
146                             log.debug("Discarding torrent because it doesn't meet the"
147                                       " minimum seeders: {0}. Seeders: {1}",
148                                       title, seeders)
149                         continue
150 
151                     torrent_size = row.find('div', class_='bSize').get_text(strip=True)
152                     size = convert_size(torrent_size[5:], sep='') or -1
153 
154                     pubdate_raw = row.find('div', class_=re.compile('bHow')).find_all('span')[1].next_sibling.strip()
155                     pubdate = self.parse_pubdate(pubdate_raw)
156 
157                     item = {
158                         'title': title,
159                         'link': download_url,
160                         'size': size,
161                         'seeders': seeders,
162                         'leechers': leechers,
163                         'pubdate': pubdate,
164                     }
165                     if mode != 'RSS':
166                         log.debug('Found result: {0} with {1} seeders and {2} leechers',
167                                   title, seeders, leechers)
168 
169                     items.append(item)
170                 except (AttributeError, TypeError, KeyError, ValueError, IndexError):
171                     log.exception('Failed parsing provider.')
172 
173         return items
174 
175     def login(self):
176         """Login method used for logging in before doing search and torrent downloads."""
177         cookies = dict_from_cookiejar(self.session.cookies)
178         if any(cookies.values()) and cookies.get('uid'):
179             return True
180 
181         login_params = {
182             'username': self.username,
183             'password': self.password,
184         }
185 
186         response = self.session.post(self.urls['login'], data=login_params)
187 
188         if not response or not response.text:
189             log.warning('Unable to connect to provider')
190             return False
191 
192         if response.text == 'OK':
193             return True
194         elif response.text == 'Banned':
195             log.warning('User {0} is banned from HeBits', self.username)
196             return False
197         elif response.text == 'MaxAttempts':
198             log.warning('Max number of login attempts exceeded - your IP is blocked')
199             return False
200         else:
201             log.warning('Invalid username or password. Check your settings')
202             return False
203 
204 
205 provider = HeBitsProvider()
206
```
--- 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/html/hebits.py b/medusa/providers/torrent/html/hebits.py
--- a/medusa/providers/torrent/html/hebits.py
+++ b/medusa/providers/torrent/html/hebits.py
@@ -111,7 +111,7 @@
         """
         items = []
 
-        with BS4Parser(data, 'html5lib') as html:
+        with BS4Parser(data, 'html.parser') as html:
             torrent_table = html.find('div', class_='browse')
             torrent_rows = torrent_table('div', class_=re.compile('^line')) if torrent_table else []

{"golden_diff": "diff --git a/medusa/providers/torrent/html/hebits.py b/medusa/providers/torrent/html/hebits.py\n--- a/medusa/providers/torrent/html/hebits.py\n+++ b/medusa/providers/torrent/html/hebits.py\n@@ -111,7 +111,7 @@\n         \"\"\"\n         items = []\n \n-        with BS4Parser(data, 'html5lib') as html:\n+        with BS4Parser(data, 'html.parser') as html:\n             torrent_table = html.find('div', class_='browse')\n             torrent_rows = torrent_table('div', class_=re.compile('^line')) if torrent_table else []\n", "issue": "HeBits provider failed to find HD torrents\nWhen using 'html5lib' HeBits provider failed to find HD torrents (720p) for me.\r\nSwitching to with BS4Parser(data, 'html.parser') as html: fix the issue for me.\r\n\r\nPlease consider to switch to html.parser or fixing html5lib search.\r\n\r\n\n", "before_files": [{"content": "# coding=utf-8\n\n\"\"\"Provider code for HeBits.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport logging\nimport re\n\nfrom medusa import tv\nfrom medusa.bs4_parser import BS4Parser\nfrom medusa.helper.common import (\n    convert_size,\n    try_int,\n)\nfrom medusa.logger.adapters.style import BraceAdapter\nfrom medusa.providers.torrent.torrent_provider import TorrentProvider\n\nfrom requests.compat import urljoin\nfrom requests.utils import dict_from_cookiejar\n\nlog = BraceAdapter(logging.getLogger(__name__))\nlog.logger.addHandler(logging.NullHandler())\n\n\nclass HeBitsProvider(TorrentProvider):\n    \"\"\"HeBits Torrent provider.\"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the class.\"\"\"\n        super(HeBitsProvider, self).__init__('HeBits')\n\n        # Credentials\n        self.username = None\n        self.password = None\n\n        # URLs\n        self.url = 'https://hebits.net'\n        self.urls = {\n            'login': urljoin(self.url, 'takeloginAjax.php'),\n            'search': urljoin(self.url, 'browse.php'),\n        }\n\n        # Proper Strings\n        self.proper_strings = ['PROPER', 'REPACK', 'REAL', 'RERIP']\n\n        # Miscellaneous Options\n        self.freeleech = False\n\n        # Torrent Stats\n        self.minseed = None\n        self.minleech = None\n\n        # Cache\n        self.cache = tv.Cache(self)\n\n    def search(self, search_strings, age=0, ep_obj=None, **kwargs):\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        # Israeli SD , English SD , Israeli HD , English HD\n        # 7          , 24         , 37         , 1\n        search_params = {\n            'c1': '1',\n            'c24': '1',\n            'c37': '1',\n            'c7': '1',\n            'search': '',\n            'cata': '0',\n        }\n        if self.freeleech:\n            search_params['free'] = 'on'\n\n        for mode in search_strings:\n            log.debug('Search mode: {0}', mode)\n\n            for search_string in search_strings[mode]:\n\n                if mode != 'RSS':\n                    search_params['search'] = search_string\n                    log.debug('Search string: {search}',\n                              {'search': search_string})\n\n                response = self.session.get(self.urls['search'], params=search_params)\n                if not response or not response.text:\n                    log.debug('No data returned from provider')\n                    continue\n\n                results += self.parse(response.text, 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        with BS4Parser(data, 'html5lib') as html:\n            torrent_table = html.find('div', class_='browse')\n            torrent_rows = torrent_table('div', class_=re.compile('^line')) if torrent_table else []\n\n            # Continue only if at least one release is found\n            if len(torrent_rows) < 1:\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                    heb_eng_title = row.find('div', class_='bTitle').find(href=re.compile('details\\.php')).find('b').get_text()\n                    if '/' in heb_eng_title:\n                        title = heb_eng_title.split('/')[1].strip()\n                    elif '\\\\' in heb_eng_title:\n                        title = heb_eng_title.split('\\\\')[1].strip()\n                    else:\n                        continue\n\n                    download_id = row.find('div', class_='bTitle').find(href=re.compile('download\\.php'))['href']\n\n                    if not all([title, download_id]):\n                        continue\n\n                    download_url = urljoin(self.url, download_id)\n\n                    seeders = try_int(row.find('div', class_='bUping').get_text(strip=True))\n                    leechers = try_int(row.find('div', class_='bDowning').get_text(strip=True))\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.find('div', class_='bSize').get_text(strip=True)\n                    size = convert_size(torrent_size[5:], sep='') or -1\n\n                    pubdate_raw = row.find('div', class_=re.compile('bHow')).find_all('span')[1].next_sibling.strip()\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.exception('Failed parsing provider.')\n\n        return items\n\n    def login(self):\n        \"\"\"Login method used for logging in before doing search and torrent downloads.\"\"\"\n        cookies = dict_from_cookiejar(self.session.cookies)\n        if any(cookies.values()) and cookies.get('uid'):\n            return True\n\n        login_params = {\n            'username': self.username,\n            'password': self.password,\n        }\n\n        response = self.session.post(self.urls['login'], data=login_params)\n\n        if not response or not response.text:\n            log.warning('Unable to connect to provider')\n            return False\n\n        if response.text == 'OK':\n            return True\n        elif response.text == 'Banned':\n            log.warning('User {0} is banned from HeBits', self.username)\n            return False\n        elif response.text == 'MaxAttempts':\n            log.warning('Max number of login attempts exceeded - your IP is blocked')\n            return False\n        else:\n            log.warning('Invalid username or password. Check your settings')\n            return False\n\n\nprovider = HeBitsProvider()\n", "path": "medusa/providers/torrent/html/hebits.py"}], "after_files": [{"content": "# coding=utf-8\n\n\"\"\"Provider code for HeBits.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport logging\nimport re\n\nfrom medusa import tv\nfrom medusa.bs4_parser import BS4Parser\nfrom medusa.helper.common import (\n    convert_size,\n    try_int,\n)\nfrom medusa.logger.adapters.style import BraceAdapter\nfrom medusa.providers.torrent.torrent_provider import TorrentProvider\n\nfrom requests.compat import urljoin\nfrom requests.utils import dict_from_cookiejar\n\nlog = BraceAdapter(logging.getLogger(__name__))\nlog.logger.addHandler(logging.NullHandler())\n\n\nclass HeBitsProvider(TorrentProvider):\n    \"\"\"HeBits Torrent provider.\"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the class.\"\"\"\n        super(HeBitsProvider, self).__init__('HeBits')\n\n        # Credentials\n        self.username = None\n        self.password = None\n\n        # URLs\n        self.url = 'https://hebits.net'\n        self.urls = {\n            'login': urljoin(self.url, 'takeloginAjax.php'),\n            'search': urljoin(self.url, 'browse.php'),\n        }\n\n        # Proper Strings\n        self.proper_strings = ['PROPER', 'REPACK', 'REAL', 'RERIP']\n\n        # Miscellaneous Options\n        self.freeleech = False\n\n        # Torrent Stats\n        self.minseed = None\n        self.minleech = None\n\n        # Cache\n        self.cache = tv.Cache(self)\n\n    def search(self, search_strings, age=0, ep_obj=None, **kwargs):\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        # Israeli SD , English SD , Israeli HD , English HD\n        # 7          , 24         , 37         , 1\n        search_params = {\n            'c1': '1',\n            'c24': '1',\n            'c37': '1',\n            'c7': '1',\n            'search': '',\n            'cata': '0',\n        }\n        if self.freeleech:\n            search_params['free'] = 'on'\n\n        for mode in search_strings:\n            log.debug('Search mode: {0}', mode)\n\n            for search_string in search_strings[mode]:\n\n                if mode != 'RSS':\n                    search_params['search'] = search_string\n                    log.debug('Search string: {search}',\n                              {'search': search_string})\n\n                response = self.session.get(self.urls['search'], params=search_params)\n                if not response or not response.text:\n                    log.debug('No data returned from provider')\n                    continue\n\n                results += self.parse(response.text, 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        with BS4Parser(data, 'html.parser') as html:\n            torrent_table = html.find('div', class_='browse')\n            torrent_rows = torrent_table('div', class_=re.compile('^line')) if torrent_table else []\n\n            # Continue only if at least one release is found\n            if len(torrent_rows) < 1:\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                    heb_eng_title = row.find('div', class_='bTitle').find(href=re.compile('details\\.php')).find('b').get_text()\n                    if '/' in heb_eng_title:\n                        title = heb_eng_title.split('/')[1].strip()\n                    elif '\\\\' in heb_eng_title:\n                        title = heb_eng_title.split('\\\\')[1].strip()\n                    else:\n                        continue\n\n                    download_id = row.find('div', class_='bTitle').find(href=re.compile('download\\.php'))['href']\n\n                    if not all([title, download_id]):\n                        continue\n\n                    download_url = urljoin(self.url, download_id)\n\n                    seeders = try_int(row.find('div', class_='bUping').get_text(strip=True))\n                    leechers = try_int(row.find('div', class_='bDowning').get_text(strip=True))\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.find('div', class_='bSize').get_text(strip=True)\n                    size = convert_size(torrent_size[5:], sep='') or -1\n\n                    pubdate_raw = row.find('div', class_=re.compile('bHow')).find_all('span')[1].next_sibling.strip()\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.exception('Failed parsing provider.')\n\n        return items\n\n    def login(self):\n        \"\"\"Login method used for logging in before doing search and torrent downloads.\"\"\"\n        cookies = dict_from_cookiejar(self.session.cookies)\n        if any(cookies.values()) and cookies.get('uid'):\n            return True\n\n        login_params = {\n            'username': self.username,\n            'password': self.password,\n        }\n\n        response = self.session.post(self.urls['login'], data=login_params)\n\n        if not response or not response.text:\n            log.warning('Unable to connect to provider')\n            return False\n\n        if response.text == 'OK':\n            return True\n        elif response.text == 'Banned':\n            log.warning('User {0} is banned from HeBits', self.username)\n            return False\n        elif response.text == 'MaxAttempts':\n            log.warning('Max number of login attempts exceeded - your IP is blocked')\n            return False\n        else:\n            log.warning('Invalid username or password. Check your settings')\n            return False\n\n\nprovider = HeBitsProvider()\n", "path": "medusa/providers/torrent/html/hebits.py"}]}