# Buggy code
def parse(self, data, mode):
    """
    Parse search results for items.

    :param data: The raw response from a search
    :param mode: The current mode used to search, e.g. RSS

    :return: A list of items found
    """
    items = []

    def process_column_header(th):
        return th.span.get_text() if th.span else th.get_text()

    with BS4Parser(data, "html5lib") as html:
        torrent_table = html.find("table", class_="table2")

        if not torrent_table:
            log.debug(
                "Data returned from provider does not contain any {0}torrents",
                "confirmed " if self.confirmed else "",
            )
            return items

        torrent_rows = torrent_table.find_all("tr")
        labels = [process_column_header(label) for label in torrent_rows[0]]

        # Skip the first row, since it isn't a valid result
        for row in torrent_rows[1:]:
            cells = row.find_all("td")

            try:
                title_cell = cells[labels.index("Torrent Name")]

                verified = title_cell.find("img", title="Verified torrent")
                if self.confirmed and not verified:
                    continue

                title_anchors = title_cell.find_all("a")
                if not title_anchors or len(title_anchors) < 2:
                    continue

                title_url = title_anchors[0].get("href")
                title = title_anchors[1].get_text(strip=True)
                regex_result = id_regex.search(title_anchors[1].get("href"))

                alt_title = regex_result.group(1)
                if len(title) < len(alt_title):
                    title = alt_title.replace("-", " ")

                torrent_id = regex_result.group(2)
                info_hash = hash_regex.search(title_url).group(2)
                if not all([title, torrent_id, info_hash]):
                    continue

                with suppress(RequestsConnectionError, Timeout):
                    # Suppress the timeout since we are not interested in actually getting the results
                    self.session.get(
                        self.urls["update"],
                        timeout=0.1,
                        params={"torrent_id": torrent_id, "infohash": info_hash},
                    )

                # Remove comma as thousands separator from larger number like 2,000 seeders = 2000
                seeders = try_int(
                    cells[labels.index("Seed")].get_text(strip=True).replace(",", ""), 1
                )
                leechers = try_int(
                    cells[labels.index("Leech")].get_text(strip=True).replace(",", "")
                )

                if seeders < min(self.minseed, 1):
                    if mode != "RSS":
                        log.debug(
                            "Discarding torrent because it doesn't meet the"
                            " minimum seeders: {0}. Seeders: {1}",
                            title,
                            seeders,
                        )
                    continue

                size = (
                    convert_size(cells[labels.index("Size")].get_text(strip=True)) or -1
                )
                download_url = "magnet:?xt=urn:btih:{hash}&dn={title}{trackers}".format(
                    hash=info_hash, title=title, trackers=self._custom_trackers
                )

                item = {
                    "title": title,
                    "link": download_url,
                    "size": size,
                    "seeders": seeders,
                    "leechers": leechers,
                    "pubdate": None,
                }
                if mode != "RSS":
                    log.debug(
                        "Found result: {0} with {1} seeders and {2} leechers",
                        title,
                        seeders,
                        leechers,
                    )

                items.append(item)
            except (AttributeError, TypeError, KeyError, ValueError, IndexError):
                log.error(
                    "Failed parsing provider. Traceback: {0!r}", traceback.format_exc()
                )

    return items


# Traceback (IndexError)
2016-11-26 00:56:40 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [DOGnzb] :: [617ad17] Creating UNIQUE URL index for dognzb
2016-11-26 00:56:42 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [DOGnzb] :: [617ad17] GET URL: https://api.dognzb.cr/api?apikey=**********&t=caps [Status: 200]
2016-11-26 00:56:44 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [DOGnzb] :: [617ad17] Search mode: Episode
2016-11-26 00:56:44 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [DOGnzb] :: [617ad17] Search show using search string: indexer_id: {u'tvdbid': 279271}
2016-11-26 00:56:45 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [DOGnzb] :: [617ad17] GET URL: https://api.dognzb.cr/api?apikey=**********&tvdbid=279271&season=2&maxage=3000&cat=5000%2C5020%2C5030%2C5040%2C5045%2C5050%2C5060%2C5080&limit=100&t=tvsearch&offset=0&ep=10 [Status: 200]
2016-11-26 00:56:45 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [DOGnzb] :: [617ad17] Search mode: Episode
2016-11-26 00:56:45 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [DOGnzb] :: [617ad17] Search show using search string: Cordon S02E10
2016-11-26 00:56:45 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [DOGnzb] :: [617ad17] GET URL: https://api.dognzb.cr/api?apikey=**********&maxage=3000&cat=5000%2C5020%2C5030%2C5040%2C5045%2C5050%2C5060%2C5080&q=Cordon+S02E10&limit=100&t=search&offset=0 [Status: 200]
2016-11-26 00:56:45 INFO     SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] Performing episode search for Cordon
2016-11-26 00:56:45 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] Creating UNIQUE URL index for pretome
2016-11-26 00:56:46 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] POST URL: https://pretome.info/takelogin.php [Status: 302]
2016-11-26 00:56:46 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] With post data: username=**********&password=**********&login_pin=**********
2016-11-26 00:56:47 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] GET URL: https://pretome.info/index.php [Status: 200]
2016-11-26 00:56:47 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] Search mode: Episode
2016-11-26 00:56:47 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] Search string: Cordon S02E10
2016-11-26 00:56:48 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] GET URL: https://pretome.info/browse.php?search=Cordon+S02E10&cat%5B%5D=7&st=1 [Status: 200]
2016-11-26 00:56:49 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Pretome] :: [617ad17] Data returned from provider does not contain any torrents
2016-11-26 00:56:49 INFO     SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Performing episode search for Cordon
2016-11-26 00:56:49 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Creating UNIQUE URL index for t411
2016-11-26 00:56:49 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] POST URL: https://api.t411.li/auth [Status: 200]
2016-11-26 00:56:49 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] With post data: username=**********&password=**********
2016-11-26 00:56:49 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Search mode: Episode
2016-11-26 00:56:49 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Search string: Cordon S02E10
2016-11-26 00:56:49 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] GET URL: https://api.t411.li/torrents/search/Cordon%20S02E10*?cid=433&limit=100 [Status: 200]
2016-11-26 00:56:49 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Data returned from provider does not contain any torrents
2016-11-26 00:56:50 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] GET URL: https://api.t411.li/torrents/search/Cordon%20S02E10*?cid=637&limit=100 [Status: 200]
2016-11-26 00:56:50 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Data returned from provider does not contain any torrents
2016-11-26 00:56:50 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] GET URL: https://api.t411.li/torrents/search/Cordon%20S02E10*?cid=455&limit=100 [Status: 200]
2016-11-26 00:56:50 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Data returned from provider does not contain any torrents
2016-11-26 00:56:50 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] GET URL: https://api.t411.li/torrents/search/Cordon%20S02E10*?cid=639&limit=100 [Status: 200]
2016-11-26 00:56:50 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Data returned from provider does not contain any torrents
2016-11-26 00:56:50 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Fallback season pack search initiate
2016-11-26 00:56:50 INFO     SEARCHQUEUE-BACKLOG-279271 :: [T411] :: [617ad17] Performing season pack search for Cordon
2016-11-26 00:56:50 INFO     SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] Performing episode search for Cordon
2016-11-26 00:56:50 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] Creating UNIQUE URL index for transmitthenet
2016-11-26 00:56:51 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] POST URL: https://transmithe.net/login.php [Status: 302]
2016-11-26 00:56:51 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] With post data: username=**********&login=Login&password=**********&keeplogged=on
2016-11-26 00:56:51 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] GET URL: https://transmithe.net/index.php [Status: 200]
2016-11-26 00:56:51 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] Search mode: Episode
2016-11-26 00:56:51 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] Search string: Cordon S02E10
2016-11-26 00:56:51 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] GET URL: https://transmithe.net/torrents.php?filter_freeleech=0&searchtext=Cordon+S02E10&order_by=seeders&order_way=desc [Status: 200]
2016-11-26 00:56:53 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TransmitTheNet] :: [617ad17] Data returned from provider does not contain any torrents
2016-11-26 00:56:53 INFO     SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] Performing episode search for Cordon
2016-11-26 00:56:53 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] Creating UNIQUE URL index for usenet_crawler
2016-11-26 00:56:53 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] GET URL: https://www.usenet-crawler.com/api?apikey=**********&t=caps [Status: 200]
2016-11-26 00:56:56 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] Search mode: Episode
2016-11-26 00:56:56 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] Search show using search string: indexer_id: {u'tvdbid': 279271}
2016-11-26 00:56:56 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] GET URL: https://www.usenet-crawler.com/api?apikey=**********&tvdbid=279271&season=2&maxage=3000&cat=5000%2C5080%2C5020%2C5040%2C5050%2C5030%2C5060&limit=100&t=tvsearch&offset=0&ep=10 [Status: 200]
2016-11-26 00:56:56 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] Search mode: Episode
2016-11-26 00:56:56 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] Search show using search string: Cordon S02E10
2016-11-26 00:56:56 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Usenet-Crawler] :: [617ad17] GET URL: https://www.usenet-crawler.com/api?apikey=**********&maxage=3000&cat=5000%2C5080%2C5020%2C5040%2C5050%2C5030%2C5060&q=Cordon+S02E10&limit=100&t=search&offset=0 [Status: 200]
2016-11-26 00:56:56 INFO     SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] Performing episode search for Cordon
2016-11-26 00:56:56 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] Creating UNIQUE URL index for speedcd
2016-11-26 00:56:59 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] POST URL: https://speed.cd/takeElogin.php [Status: 302]
2016-11-26 00:56:59 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] With post data: username=**********&password=**********
2016-11-26 00:57:00 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] GET URL: https://speed.cd/ [Status: 200]
2016-11-26 00:57:00 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] Search mode: Episode
2016-11-26 00:57:00 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] Search string: Cordon S02E10
2016-11-26 00:57:05 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] GET URL: https://speed.cd/browse.php?c55=1&c52=1&search=Cordon+S02E10&c41=1&c50=1&c2=1&c30=1&c49=1 [Status: 200]
2016-11-26 00:57:06 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [Speedcd] :: [617ad17] Data returned from provider does not contain any torrents
2016-11-26 00:57:07 INFO     SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] Performing episode search for Cordon
2016-11-26 00:57:07 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] Creating UNIQUE URL index for torrentleech
2016-11-26 00:57:07 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] POST URL: https://torrentleech.org/user/account/login/ [Status: 302]
2016-11-26 00:57:07 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] With post data: username=**********&remember_me=on&login=submit&password=**********
2016-11-26 00:57:07 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] GET URL: https://torrentleech.org/ [Status: 200]
2016-11-26 00:57:07 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] Search mode: Episode
2016-11-26 00:57:07 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] Search string: Cordon S02E10
2016-11-26 00:57:08 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] GET URL: https://torrentleech.org/torrents/browse?query=Cordon+S02E10&categories=2%2C7%2C35%2C26%2C32 [Status: 200]
2016-11-26 00:57:08 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [TorrentLeech] :: [617ad17] Data returned from provider does not contain any torrents
2016-11-26 00:57:08 INFO     SEARCHQUEUE-BACKLOG-279271 :: [LimeTorrents] :: [617ad17] Performing episode search for Cordon
2016-11-26 00:57:08 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [LimeTorrents] :: [617ad17] Creating UNIQUE URL index for limetorrents
2016-11-26 00:57:08 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [LimeTorrents] :: [617ad17] Search mode: Episode
2016-11-26 00:57:08 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [LimeTorrents] :: [617ad17] Search string: Cordon S02E10
2016-11-26 00:57:09 DEBUG    SEARCHQUEUE-BACKLOG-279271 :: [LimeTorrents] :: [617ad17] GET URL: https://www.limetorrents.cc/search/tv/Cordon%20S02E10/ [Status: 200]
2016-11-26 00:57:09 ERROR    SEARCHQUEUE-BACKLOG-279271 :: [LimeTorrents] :: [617ad17] Unknown exception while searching LimeTorrents. Error: 'list index out of range'
Traceback (most recent call last):
  File "/home/home/SickRage/**********/search/core.py", line 560, in searchProviders
    down_cur_quality, manual_search, manual_search_type)
  File "/home/home/SickRage/**********/providers/generic_provider.py", line 193, in find_search_results
    items_list += self.search(search_string, ep_obj=episode)
  File "/home/home/SickRage/**********/providers/torrent/html/limetorrents.py", line 98, in search
    results += self.parse(response.text, mode)
  File "/home/home/SickRage/**********/providers/torrent/html/limetorrents.py", line 121, in parse
    torrent_table = torrent_table[0 if mode == 'RSS' else 1]
IndexError: list index out of range

# Fixed code
def parse(self, data, mode):
    """
    Parse search results for items.

    :param data: The raw response from a search
    :param mode: The current mode used to search, e.g. RSS

    :return: A list of items found
    """
    items = []

    def process_column_header(th):
        return th.span.get_text() if th.span else th.get_text()

    with BS4Parser(data, "html5lib") as html:
        torrent_table = html.find("table", class_="table2")

        if not torrent_table:
            log.debug(
                "Data returned from provider does not contain any {0}torrents",
                "confirmed " if self.confirmed else "",
            )
            return items

        torrent_rows = torrent_table.find_all("tr")
        labels = [process_column_header(label) for label in torrent_rows[0]]

        # Skip the first row, since it isn't a valid result
        for row in torrent_rows[1:]:
            cells = row.find_all("td")

            try:
                title_cell = cells[labels.index("Torrent Name")]

                verified = title_cell.find("img", title="Verified torrent")
                if self.confirmed and not verified:
                    continue

                title_anchors = title_cell.find_all("a")
                if not title_anchors or len(title_anchors) < 2:
                    continue

                title_url = title_anchors[0].get("href")
                title = title_anchors[1].get_text(strip=True)
                regex_result = id_regex.search(title_anchors[1].get("href"))

                alt_title = regex_result.group(1)
                if len(title) < len(alt_title):
                    title = alt_title.replace("-", " ")

                torrent_id = regex_result.group(2)
                info_hash = hash_regex.search(title_url).group(2)
                if not all([title, torrent_id, info_hash]):
                    continue

                with suppress(RequestsConnectionError, Timeout):
                    # Suppress the timeout since we are not interested in actually getting the results
                    self.session.get(
                        self.urls["update"],
                        timeout=0.1,
                        params={"torrent_id": torrent_id, "infohash": info_hash},
                    )

                # Remove comma as thousands separator from larger number like 2,000 seeders = 2000
                seeders = try_int(
                    cells[labels.index("Seed")].get_text(strip=True).replace(",", ""), 1
                )
                leechers = try_int(
                    cells[labels.index("Leech")].get_text(strip=True).replace(",", "")
                )

                # Handle all date formats in the site
                # Example: "7 days ago - in TV shows" or "16 minutes ago"
                pubdate_raw = cells[1].get_text()
                pubdate_raw = (
                    pubdate_raw.split("ago")[0]
                    .split("+")[0]
                    .split("-")[0]
                    .replace("Last", "1")
                )
                pubdate = (
                    str(
                        datetime.datetime.now()
                        - datetime.timedelta(seconds=parse(pubdate_raw))
                    )
                    if pubdate_raw
                    else None
                )

                if seeders < min(self.minseed, 1):
                    if mode != "RSS":
                        log.debug(
                            "Discarding torrent because it doesn't meet the"
                            " minimum seeders: {0}. Seeders: {1}",
                            title,
                            seeders,
                        )
                    continue

                size = (
                    convert_size(cells[labels.index("Size")].get_text(strip=True)) or -1
                )
                download_url = "magnet:?xt=urn:btih:{hash}&dn={title}{trackers}".format(
                    hash=info_hash, title=title, trackers=self._custom_trackers
                )

                item = {
                    "title": title,
                    "link": download_url,
                    "size": size,
                    "seeders": seeders,
                    "leechers": leechers,
                    "pubdate": pubdate,
                }
                if mode != "RSS":
                    log.debug(
                        "Found result: {0} with {1} seeders and {2} leechers",
                        title,
                        seeders,
                        leechers,
                    )

                items.append(item)
            except (AttributeError, TypeError, KeyError, ValueError, IndexError):
                log.error(
                    "Failed parsing provider. Traceback: {0!r}", traceback.format_exc()
                )

    return items