# Buggy code
def _show_data(self, show_obj):
    """
    Creates an elementTree XML structure for a MediaBrowser-style series.xml
    returns the resulting data object.

    show_obj: a Series instance to create the NFO for
    """
    my_show = self._get_show_data(show_obj)

    # If by any reason it couldn't get the shows indexer data let's not go throught the rest of this method
    # as that pretty useless.
    if not my_show:
        return False

    root_node = etree.Element("details")
    tv_node = etree.SubElement(root_node, "movie")
    tv_node.attrib["isExtra"] = "false"
    tv_node.attrib["isSet"] = "false"
    tv_node.attrib["isTV"] = "true"

    title = etree.SubElement(tv_node, "title")
    title.text = my_show["seriesname"]

    if getattr(my_show, "genre", None):
        genres = etree.SubElement(tv_node, "genres")
        for genre in my_show["genre"].split("|"):
            if genre and genre.strip():
                cur_genre = etree.SubElement(genres, "Genre")
                cur_genre.text = genre.strip()

    if getattr(my_show, "firstaired", None):
        first_aired = etree.SubElement(tv_node, "premiered")
        first_aired.text = my_show["firstaired"]
        try:
            year_text = text_type(
                datetime.datetime.strptime(my_show["firstaired"], dateFormat).year
            )
            if year_text:
                year = etree.SubElement(tv_node, "year")
                year.text = year_text
        except Exception:
            pass

    if getattr(my_show, "overview", None):
        plot = etree.SubElement(tv_node, "plot")
        plot.text = my_show["overview"]

    if getattr(my_show, "rating", None):
        try:
            rating = int(float(my_show["rating"]) * 10)
        except ValueError:
            rating = 0

        if rating:
            rating = etree.SubElement(tv_node, "rating")
            rating.text = text_type(rating)

    if getattr(my_show, "status", None):
        status = etree.SubElement(tv_node, "status")
        status.text = my_show["status"]

    if getattr(my_show, "contentrating", None):
        mpaa = etree.SubElement(tv_node, "mpaa")
        mpaa.text = my_show["contentrating"]

    if getattr(my_show, "imdb_id", None):
        imdb_id = etree.SubElement(tv_node, "id")
        imdb_id.attrib["moviedb"] = "imdb"
        imdb_id.text = my_show["imdb_id"]

    if getattr(my_show, "id", None):
        indexer_id = etree.SubElement(tv_node, "indexerid")
        indexer_id.text = my_show["id"]

    if getattr(my_show, "runtime", None):
        runtime = etree.SubElement(tv_node, "runtime")
        runtime.text = my_show["runtime"]

    if getattr(my_show, "_actors", None):
        cast = etree.SubElement(tv_node, "cast")
        for actor in my_show["_actors"]:
            if "name" in actor and actor["name"].strip():
                cur_actor = etree.SubElement(cast, "actor")
                cur_actor.text = actor["name"].strip()

    helpers.indent_xml(root_node)

    data = etree.ElementTree(root_node)

    return data


# Traceback (WindowsError)
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E05
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x13 - Instant Replay.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x13 - Instant Replay.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x13 - Instant Replay.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x13 - Instant Replay.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E06
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x19 - Dog Daze Afternoon.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x19 - Dog Daze Afternoon.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x19 - Dog Daze Afternoon.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x19 - Dog Daze Afternoon.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E07
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x23 - Grandpa and the Galactic Golddigger.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x23 - Grandpa and the Galactic Golddigger.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x23 - Grandpa and the Galactic Golddigger.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x23 - Grandpa and the Galactic Golddigger.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E08
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x33 - Fugitive Fleas.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x33 - Fugitive Fleas.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x33 - Fugitive Fleas.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x33 - Fugitive Fleas.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E09
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x27 - Elroy Meets Orbitty.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x27 - Elroy Meets Orbitty.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x27 - Elroy Meets Orbitty.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x27 - Elroy Meets Orbitty.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E10
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x17 - Judy Takes Off.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x17 - Judy Takes Off.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x17 - Judy Takes Off.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x17 - Judy Takes Off.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E11
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x24 - Boy George.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x24 - Boy George.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x24 - Boy George.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x24 - Boy George.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E12
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x12 - S'no Relative.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x12 - S'no Relative.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x12 - S'no Relative.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x12 - S'no Relative.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E13
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x07 - Rip-Off Rosie.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x07 - Rip-Off Rosie.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x07 - Rip-Off Rosie.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x07 - Rip-Off Rosie.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E14
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x26 - Space Bong.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x26 - Space Bong.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x26 - Space Bong.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x26 - Space Bong.jpg exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E15
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x32 - Family Fallout.xml exists: True
2018-04-30 19:05:43 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x32 - Family Fallout.jpg exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x32 - Family Fallout.xml exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x32 - Family Fallout.jpg exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E16
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x29 - Solar Snoops.xml exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x29 - Solar Snoops.jpg exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x29 - Solar Snoops.xml exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x29 - Solar Snoops.jpg exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E17
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x14 - Haunted Halloween.xml exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x14 - Haunted Halloween.jpg exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x14 - Haunted Halloween.xml exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Checking if \\Tower\Media\TV\The Jetsons\Season 02\metadata\The Jetsons - 2x14 - Haunted Halloween.jpg exists: True
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Retrieving/creating episode S02E18
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Episode location missing: \\Tower\Media\TV\The Jetsons\Season 02\The Jetsons - 2x41 - Elroy in Wonderland.mkv
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Matched release \\Tower\Media\TV\The Jetsons\Season 02\The Jetsons - 2x41 - Elroy in Wonderland to a series in your database: The Jetsons
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Parsed \\Tower\Media\TV\The Jetsons\Season 02\The Jetsons - 2x41 - Elroy in Wonderland into title: The Jetsons, season: 2, episode: [41], episode_title: Elroy in Wonderland, type: episode, parsing_time: 0.124000072479, total_time: 0.125, absolute_episode: [], quality: Unknown
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Found codec for The Jetsons A Jetson Christmas Carol
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] 76204: Formatting pattern: %SN - S%0SE18 - %EN -> The Jetsons - S02E18 - A Jetson Christmas Carol
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Metadata provider MediaBrowser creating episode metadata for The Jetsons - S02E18 - A Jetson Christmas Carol
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Episode location missing: \\Tower\Media\TV\The Jetsons\Season 02\The Jetsons - 2x41 - Elroy in Wonderland.mkv
2018-04-30 19:05:44 DEBUG    SHOWQUEUE-REFRESH :: [77b2091] Metadata directory missing, creating it at 
2018-04-30 19:05:44 ERROR    SHOWQUEUE-REFRESH :: [77b2091] 76204: Error while refreshing show The Jetsons. Error: 
Traceback (most recent call last):
  File "C:\Medusa\Medusa\medusa\show_queue.py", line 640, in run
    self.show.write_metadata()
  File "C:\Medusa\Medusa\medusa\tv\series.py", line 856, in write_metadata
    self.__write_episode_nfos()
  File "C:\Medusa\Medusa\medusa\tv\series.py", line 885, in __write_episode_nfos
    cur_ep.create_meta_files()
  File "C:\Medusa\Medusa\medusa\tv\episode.py", line 1110, in create_meta_files
    self.__create_nfo(metadata_provider)
  File "C:\Medusa\Medusa\medusa\tv\episode.py", line 1124, in __create_nfo
    result = metadata_provider.create_episode_metadata(self) or result
  File "C:\Medusa\Medusa\medusa\metadata\generic.py", line 254, in create_episode_metadata
    return self.write_ep_file(ep_obj)
  File "C:\Medusa\Medusa\medusa\metadata\generic.py", line 469, in write_ep_file
    os.makedirs(nfo_file_dir)
  File "C:\Medusa\Medusa\medusa\init\filesystem.py", line 113, in patched_output
    return handle_output(f(*args, **kwargs))
  File "C:\Medusa\Python\lib\os.py", line 157, in makedirs
    mkdir(name, mode)
  File "C:\Medusa\Medusa\medusa\init\filesystem.py", line 113, in patched_output
    return handle_output(f(*args, **kwargs))
WindowsError: [Error 3] The system cannot find the path specified: u''

# Fixed code
def _show_data(self, show_obj):
    """
    Creates an elementTree XML structure for a MediaBrowser-style series.xml
    returns the resulting data object.

    show_obj: a Series instance to create the NFO for
    """
    my_show = self._get_show_data(show_obj)

    # If by any reason it couldn't get the shows indexer data let's not go throught the rest of this method
    # as that pretty useless.
    if not my_show:
        return False

    root_node = etree.Element("details")
    tv_node = etree.SubElement(root_node, "movie")
    tv_node.attrib["isExtra"] = "false"
    tv_node.attrib["isSet"] = "false"
    tv_node.attrib["isTV"] = "true"

    title = etree.SubElement(tv_node, "title")
    title.text = my_show["seriesname"]

    if getattr(my_show, "genre", None):
        genres = etree.SubElement(tv_node, "genres")
        for genre in my_show["genre"].split("|"):
            if genre and genre.strip():
                cur_genre = etree.SubElement(genres, "Genre")
                cur_genre.text = genre.strip()

    if getattr(my_show, "firstaired", None):
        first_aired = etree.SubElement(tv_node, "premiered")
        first_aired.text = my_show["firstaired"]
        try:
            year_text = str(
                datetime.datetime.strptime(my_show["firstaired"], dateFormat).year
            )
            if year_text:
                year = etree.SubElement(tv_node, "year")
                year.text = year_text
        except Exception:
            pass

    if getattr(my_show, "overview", None):
        plot = etree.SubElement(tv_node, "plot")
        plot.text = my_show["overview"]

    if getattr(my_show, "rating", None):
        try:
            rating = int(float(my_show["rating"]) * 10)
        except ValueError:
            rating = 0

        if rating:
            rating = etree.SubElement(tv_node, "rating")
            rating.text = str(rating)

    if getattr(my_show, "status", None):
        status = etree.SubElement(tv_node, "status")
        status.text = my_show["status"]

    if getattr(my_show, "contentrating", None):
        mpaa = etree.SubElement(tv_node, "mpaa")
        mpaa.text = my_show["contentrating"]

    if getattr(my_show, "imdb_id", None):
        imdb_id = etree.SubElement(tv_node, "id")
        imdb_id.attrib["moviedb"] = "imdb"
        imdb_id.text = my_show["imdb_id"]

    if getattr(my_show, "id", None):
        indexer_id = etree.SubElement(tv_node, "indexerid")
        indexer_id.text = str(my_show["id"])

    if getattr(my_show, "runtime", None):
        runtime = etree.SubElement(tv_node, "runtime")
        runtime.text = str(my_show["runtime"])

    if getattr(my_show, "_actors", None):
        cast = etree.SubElement(tv_node, "cast")
        for actor in my_show["_actors"]:
            if "name" in actor and actor["name"].strip():
                cur_actor = etree.SubElement(cast, "actor")
                cur_actor.text = actor["name"].strip()

    helpers.indent_xml(root_node)

    data = etree.ElementTree(root_node)

    return data