# 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
    """
    # Units
    units = ["B", "KB", "MB", "GB", "TB", "PB"]

    items = []

    with BS4Parser(
        data, "html.parser"
    ) as html:  # Use html.parser, since html5parser has issues with this site.
        tables = html("table", width="750")  # Get the last table with a width of 750px.
        torrent_table = tables[-1] if tables else []
        torrent_rows = torrent_table("tr") if torrent_table else []

        # Continue only if at least one release is found
        if len(torrent_rows) < 2:
            logger.log(
                "Data returned from provider does not contain any torrents",
                logger.DEBUG,
            )
            return items

        # Skip column headers
        for row in torrent_rows[1:]:
            cells = row("td")
            if self.freeleech and not row.get("bgcolor"):
                continue

            try:
                title = cells[2].find("a")["title"]
                download_url = urljoin(self.url, cells[0].find("a")["href"])
                if not all([title, download_url]):
                    continue

                seeders = try_int(cells[8].get_text(strip=True))
                leechers = try_int(cells[9].get_text(strip=True))

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

                torrent_size = "{size} {unit}".format(
                    size=cells[6].contents[0], unit=cells[6].contents[1].get_text()
                )
                size = convert_size(torrent_size, units=units) or -1

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

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

    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
    """
    # Units
    units = ["B", "KB", "MB", "GB", "TB", "PB"]

    items = []

    with BS4Parser(
        data, "html.parser"
    ) as html:  # Use html.parser, since html5parser has issues with this site.
        tables = html("table", width="750")  # Get the last table with a width of 750px.
        torrent_table = tables[-1] if tables else []
        torrent_rows = torrent_table("tr") if torrent_table else []

        # Continue only if at least one release is found
        if len(torrent_rows) < 2:
            logger.log(
                "Data returned from provider does not contain any torrents",
                logger.DEBUG,
            )
            return items

        # Skip column headers
        for row in torrent_rows[1:]:
            cells = row("td")
            if len(cells) < 3:
                # We must have cells[2] because it containts the title
                continue

            if self.freeleech and not row.get("bgcolor"):
                continue

            try:
                title = cells[2].find("a")["title"]
                download_url = urljoin(self.url, cells[0].find("a")["href"])
                if not all([title, download_url]):
                    continue

                seeders = try_int(cells[8].get_text(strip=True))
                leechers = try_int(cells[9].get_text(strip=True))

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

                torrent_size = "{size} {unit}".format(
                    size=cells[6].contents[0], unit=cells[6].contents[1].get_text()
                )
                size = convert_size(torrent_size, units=units) or -1

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

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

    return items