# Buggy code
def download_nzb_for_post(self, result):
    """
    Download the nzb content, prior to sending it to the nzb download client.

    :param result: Nzb SearchResult object.
    :return: The content of the nzb file if successful else None.
    """
    if not self.login():
        return False

    # For now to separate the url and the post data, where splitting it with a pipe.
    url, data = result.url.split("|")

    data = {
        data.split("=")[1]: "on",
        "action": "nzb",
    }

    log.info(
        "Downloading {result} from {provider} at {url} and data {data}",
        {"result": result.name, "provider": self.name, "url": result.url, "data": data},
    )

    verify = False if self.public else None

    response = self.session.post(
        url,
        data=data,
        headers=self.session.headers,
        verify=verify,
        hooks={},
        allow_redirects=True,
    )
    if not response or not response.content:
        log.warning("Failed to download the NZB from BinSearch")
        return None

    # Validate that the result has the content of a valid nzb.
    if not BinSearchProvider.nzb_check_segment.search(response.content):
        log.warning("Result returned from BinSearch was not a valid NZB")
        return None

    return response.content


# Traceback (TypeError)
2019-02-10 19:30:39 INFO     SNATCHQUEUE-SNATCH-526 :: [18bd87d] Beginning to snatch release: The.Office.(US).S03.1080p.WEB-DL.AAC2.0.AVC-TrollHD
2019-02-10 19:30:39 INFO     SNATCHQUEUE-SNATCH-526 :: [18bd87d] Downloading The.Office.(US).S03.1080p.WEB-DL.AAC2.0.AVC-TrollHD with size: 44.60 GB from BinSearch, through a SearchType.MANUAL_SEARCH search
2019-02-10 19:30:39 INFO     SNATCHQUEUE-SNATCH-526 :: [18bd87d] Downloading The.Office.(US).S03.1080p.WEB-DL.AAC2.0.AVC-TrollHD from BinSearch at https://www.binsearch.info/fcgi/nzb.fcgi?adv_age=&xminsize=20&max=250&q=The+Office+S03&server=1|nzb_id=147576780 and data {'147576780': 'on', 'action': 'nzb'}
2019-02-10 19:30:40 DEBUG    SNATCHQUEUE-SNATCH-526 :: [18bd87d] POST URL: https://www.binsearch.info/fcgi/nzb.fcgi?adv_age=&xminsize=20&max=250&q=The+Office+S03&server=1 [Status: 200]
2019-02-10 19:30:40 DEBUG    SNATCHQUEUE-SNATCH-526 :: [18bd87d] User-Agent: Medusa/0.2.14 (Linux; 4.9.35-v7+; e68764e0-2d57-11e9-b77f-b827eb6b4d4c)
2019-02-10 19:30:40 DEBUG    SNATCHQUEUE-SNATCH-526 :: [18bd87d] With post data: 147576780=on&action=nzb
2019-02-10 19:30:40 ERROR    SNATCHQUEUE-SNATCH-526 :: [18bd87d] Snatch failed! For result: The.Office.(US).S03.1080p.WEB-DL.AAC2.0.AVC-TrollHD
Traceback (most recent call last):
  File "/home/pi/Medusa/medusa/search/queue.py", line 503, in run
    self.success = snatch_episode(result)
  File "/home/pi/Medusa/medusa/search/core.py", line 132, in snatch_episode
    nzb_data = result.provider.download_nzb_for_post(result)
  File "/home/pi/Medusa/medusa/providers/nzb/binsearch.py", line 275, in download_nzb_for_post
    if not BinSearchProvider.nzb_check_segment.search(response.content):
TypeError: cannot use a string pattern on a bytes-like object

# Fixed code
def download_nzb_for_post(self, result):
    """
    Download the nzb content, prior to sending it to the nzb download client.

    :param result: Nzb SearchResult object.
    :return: The content of the nzb file if successful else None.
    """
    if not self.login():
        return False

    # For now to separate the url and the post data, where splitting it with a pipe.
    url, data = result.url.split("|")

    data = {
        data.split("=")[1]: "on",
        "action": "nzb",
    }

    log.info(
        "Downloading {result} from {provider} at {url} and data {data}",
        {"result": result.name, "provider": self.name, "url": result.url, "data": data},
    )

    verify = False if self.public else None

    response = self.session.post(
        url,
        data=data,
        headers=self.session.headers,
        verify=verify,
        hooks={},
        allow_redirects=True,
    )
    if not response or not response.content:
        log.warning("Failed to download the NZB from BinSearch")
        return None

    # Validate that the result has the content of a valid nzb.
    if not BinSearchProvider.nzb_check_segment.search(response.text):
        log.warning("Result returned from BinSearch was not a valid NZB")
        return None

    return response.content