# Buggy code
def _notify_emby(self, message, host=None, emby_apikey=None):
    """
    Notify Emby host via HTTP API.

    :return: True for no issue or False if there was an error
    """
    # fill in omitted parameters
    if not host:
        host = app.EMBY_HOST
    if not emby_apikey:
        emby_apikey = app.EMBY_APIKEY

    url = "http://{host}/emby/Notifications/Admin".format(host=host)
    data = json.dumps(
        {"Name": "Medusa", "Description": message, "ImageUrl": app.LOGO_URL}
    )
    try:
        resp = self.session.post(
            url=url,
            data=data,
            headers={
                "X-MediaBrowser-Token": emby_apikey,
                "Content-Type": "application/json",
            },
        )
        resp.raise_for_status()

        if resp.content:
            log.debug("EMBY: HTTP response: {0}", resp.content.replace("\n", ""))

        log.info("EMBY: Successfully sent a test notification.")
        return True

    except (HTTPError, RequestException) as error:
        log.warning(
            "EMBY: Warning: Unable to contact Emby at {url}: {error}",
            {"url": url, "error": ex(error)},
        )
        return False


# Traceback (TypeError)
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Setting permissions for /tv/The Real Housewives of Orange County/Season 14/The Real Housewives of Orange County - S14E11 - Hot Mess Express.mkv to 432 as parent directory has 504
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Transaction with 1 queries executed
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] 80117: Setter sets location to /tv/The Real Housewives of Orange County/Season 14/The Real Housewives of Orange County - S14E11 - Hot Mess Express.mkv
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Transaction with 1 queries executed
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Notification for NMJ scan update not enabled, skipping this notification
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Matched release /tv/The Real Housewives of Orange County/Season 14/The Real Housewives of Orange County - S14E11 - Hot Mess Express to a series in your database: The Real Housewives of Orange County
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Parsed /tv/The Real Housewives of Orange County/Season 14/The Real Housewives of Orange County - S14E11 - Hot Mess Express into title: The Real Housewives of Orange County, season: 14, episode: [11], episode_title: Hot Mess Express, type: episode, parsing_time: 0.09803581237792969, absolute_episode: [], quality: Unknown, total_time: 0.09842324256896973
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Matched release 6e38e81c1fe44b74949ffd2e14be50b8 to a series in your database: The Real Housewives of Orange County
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Unable to parse release_group: Unable to parse 6e38e81c1fe44b74949ffd2e14be50b8. No episode numbering info. Parser result: uuid: 6e38e81c1fe44b74949ffd2e14be50b8, type: episode, parsing_time: 0.0806131362915039, season: None, episode: [], absolute_episode: [], quality: Unknown, total_time: 0.08083868026733398
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] Found codec for The Real Housewives of Orange County Hot Mess Express
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] 80117: Formatting pattern: %SN - %Sx11 - %EN - %QN -> The Real Housewives of Orange County - 14x11 - Hot Mess Express - 1080p WEB-DL
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] POST URL: http://10.0.0.3:8096/emby/Library/Series/Updated?tvdbid=80117 [Status: 302]
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] User-Agent: Medusa/0.3.6 (Linux; 4.9.0-11-amd64; 4aefdd2c-0502-11ea-a99c-0242ac120011)
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] GET URL: http://10.0.0.3:8096/jellyfin/web/index.html [Status: 200]
2019-11-12 10:48:11 DEBUG    TORNADO :: [918cfe7] User-Agent: Medusa/0.3.6 (Linux; 4.9.0-11-amd64; 4aefdd2c-0502-11ea-a99c-0242ac120011)
2019-11-12 10:48:11 ERROR    TORNADO :: [918cfe7] API :: TypeError("a bytes-like object is required, not 'str'")
Traceback (most recent call last):
  File "/app/medusa/medusa/server/api/v1/core.py", line 165, in get
    out_dict = _call_dispatcher(args, kwargs)
  File "/app/medusa/medusa/server/api/v1/core.py", line 235, in call_dispatcher
    cur_out_dict = func(cur_args, cur_kwargs).run()  # call function and get response
  File "/app/medusa/medusa/server/api/v1/core.py", line 1336, in run
    proc_type=self.type
  File "/app/medusa/medusa/process_tv.py", line 65, in run
    return ProcessResult(path, process_method).process(force=force, **kwargs)
  File "/app/medusa/medusa/process_tv.py", line 188, in process
    ignore_subs=ignore_subs)
  File "/app/medusa/medusa/process_tv.py", line 378, in process_files
    self.process_media(path, self.video_files, force, is_priority, ignore_subs)
  File "/app/medusa/medusa/process_tv.py", line 599, in process_media
    self.result = processor.process()
  File "/app/medusa/medusa/post_processor.py", line 1281, in process
    notifiers.emby_notifier.update_library(ep_obj.series)
  File "/app/medusa/medusa/notifiers/emby.py", line 131, in update_library
    log.debug('EMBY: HTTP response: {0}', resp.content.replace('\n', ''))
TypeError: a bytes-like object is required, not 'str'

# Fixed code
def _notify_emby(self, message, host=None, emby_apikey=None):
    """
    Notify Emby host via HTTP API.

    :return: True for no issue or False if there was an error
    """
    # fill in omitted parameters
    if not host:
        host = app.EMBY_HOST
    if not emby_apikey:
        emby_apikey = app.EMBY_APIKEY

    url = "http://{host}/emby/Notifications/Admin".format(host=host)
    data = json.dumps(
        {"Name": "Medusa", "Description": message, "ImageUrl": app.LOGO_URL}
    )
    try:
        resp = self.session.post(
            url=url,
            data=data,
            headers={
                "X-MediaBrowser-Token": emby_apikey,
                "Content-Type": "application/json",
            },
        )
        resp.raise_for_status()

        if resp.text:
            log.debug("EMBY: HTTP response: {0}", resp.text.replace("\n", ""))

        log.info("EMBY: Successfully sent a test notification.")
        return True

    except (HTTPError, RequestException) as error:
        log.warning(
            "EMBY: Warning: Unable to contact Emby at {url}: {error}",
            {"url": url, "error": ex(error)},
        )
        return False