# Buggy code
def _ep_data(self, ep_obj):
    """
    Creates an elementTree XML structure for a WDTV style episode.xml
    and returns the resulting data object.

    ep_obj: a Series instance to create the NFO for
    """

    eps_to_write = [ep_obj] + ep_obj.related_episodes

    my_show = self._get_show_data(ep_obj.series)
    if not my_show:
        return None

    root_node = etree.Element("details")

    # write an WDTV XML containing info for all matching episodes
    for ep_to_write in eps_to_write:
        try:
            my_ep = my_show[ep_to_write.season][ep_to_write.episode]
        except (IndexerEpisodeNotFound, IndexerSeasonNotFound):
            log.info(
                "Unable to find episode {number} on {indexer}... has it been removed? Should I delete from db?",
                {
                    "number": ep_num(ep_to_write.season, ep_to_write.episode),
                    "indexer": indexerApi(ep_obj.series.indexer).name,
                },
            )
            return None

        if ep_obj.season == 0 and not getattr(my_ep, "firstaired", None):
            my_ep["firstaired"] = text_type(datetime.date.fromordinal(1))

        if not (
            getattr(my_ep, "episodename", None) and getattr(my_ep, "firstaired", None)
        ):
            return None

        if len(eps_to_write) > 1:
            episode = etree.SubElement(root_node, "details")
        else:
            episode = root_node

        # TODO: get right EpisodeID
        episode_id = etree.SubElement(episode, "id")
        episode_id.text = text_type(ep_to_write.indexerid)

        title = etree.SubElement(episode, "title")
        title.text = ep_obj.pretty_name()

        if getattr(my_show, "seriesname", None):
            series_name = etree.SubElement(episode, "series_name")
            series_name.text = my_show["seriesname"]

        if ep_to_write.name:
            episode_name = etree.SubElement(episode, "episode_name")
            episode_name.text = ep_to_write.name

        season_number = etree.SubElement(episode, "season_number")
        season_number.text = text_type(ep_to_write.season)

        episode_num = etree.SubElement(episode, "episode_number")
        episode_num.text = text_type(ep_to_write.episode)

        first_aired = etree.SubElement(episode, "firstaired")

        if ep_to_write.airdate != datetime.date.fromordinal(1):
            first_aired.text = text_type(ep_to_write.airdate)

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

        if ep_to_write.season != 0 and getattr(my_show, "runtime", None):
            runtime = etree.SubElement(episode, "runtime")
            runtime.text = my_show["runtime"]

        if getattr(my_show, "genre", None):
            genre = etree.SubElement(episode, "genre")
            genre.text = " / ".join(
                [x.strip() for x in my_show["genre"].split("|") if x.strip()]
            )

        if getattr(my_ep, "director", None):
            director = etree.SubElement(episode, "director")
            director.text = my_ep["director"]

        if getattr(my_show, "_actors", None):
            for actor in my_show["_actors"]:
                if not ("name" in actor and actor["name"].strip()):
                    continue

                cur_actor = etree.SubElement(episode, "actor")

                cur_actor_name = etree.SubElement(cur_actor, "name")
                cur_actor_name.text = actor["name"]

                if "role" in actor and actor["role"].strip():
                    cur_actor_role = etree.SubElement(cur_actor, "role")
                    cur_actor_role.text = actor["role"].strip()

        if ep_to_write.description:
            overview = etree.SubElement(episode, "overview")
            overview.text = ep_to_write.description

        # Make it purdy
        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 _ep_data(self, ep_obj):
    """
    Creates an elementTree XML structure for a WDTV style episode.xml
    and returns the resulting data object.

    ep_obj: a Series instance to create the NFO for
    """

    eps_to_write = [ep_obj] + ep_obj.related_episodes

    my_show = self._get_show_data(ep_obj.series)
    if not my_show:
        return None

    root_node = etree.Element("details")

    # write an WDTV XML containing info for all matching episodes
    for ep_to_write in eps_to_write:
        try:
            my_ep = my_show[ep_to_write.season][ep_to_write.episode]
        except (IndexerEpisodeNotFound, IndexerSeasonNotFound):
            log.info(
                "Unable to find episode {number} on {indexer}... has it been removed? Should I delete from db?",
                {
                    "number": ep_num(ep_to_write.season, ep_to_write.episode),
                    "indexer": indexerApi(ep_obj.series.indexer).name,
                },
            )
            return None

        if ep_obj.season == 0 and not getattr(my_ep, "firstaired", None):
            my_ep["firstaired"] = str(datetime.date.fromordinal(1))

        if not (
            getattr(my_ep, "episodename", None) and getattr(my_ep, "firstaired", None)
        ):
            return None

        if len(eps_to_write) > 1:
            episode = etree.SubElement(root_node, "details")
        else:
            episode = root_node

        # TODO: get right EpisodeID
        episode_id = etree.SubElement(episode, "id")
        episode_id.text = str(ep_to_write.indexerid)

        title = etree.SubElement(episode, "title")
        title.text = ep_obj.pretty_name()

        if getattr(my_show, "seriesname", None):
            series_name = etree.SubElement(episode, "series_name")
            series_name.text = my_show["seriesname"]

        if ep_to_write.name:
            episode_name = etree.SubElement(episode, "episode_name")
            episode_name.text = ep_to_write.name

        season_number = etree.SubElement(episode, "season_number")
        season_number.text = str(ep_to_write.season)

        episode_num = etree.SubElement(episode, "episode_number")
        episode_num.text = str(ep_to_write.episode)

        first_aired = etree.SubElement(episode, "firstaired")

        if ep_to_write.airdate != datetime.date.fromordinal(1):
            first_aired.text = str(ep_to_write.airdate)

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

        if ep_to_write.season != 0 and getattr(my_show, "runtime", None):
            runtime = etree.SubElement(episode, "runtime")
            runtime.text = str(my_show["runtime"])

        if getattr(my_show, "genre", None):
            genre = etree.SubElement(episode, "genre")
            genre.text = " / ".join(
                [x.strip() for x in my_show["genre"].split("|") if x.strip()]
            )

        if getattr(my_ep, "director", None):
            director = etree.SubElement(episode, "director")
            director.text = my_ep["director"]

        if getattr(my_show, "_actors", None):
            for actor in my_show["_actors"]:
                if not ("name" in actor and actor["name"].strip()):
                    continue

                cur_actor = etree.SubElement(episode, "actor")

                cur_actor_name = etree.SubElement(cur_actor, "name")
                cur_actor_name.text = actor["name"]

                if "role" in actor and actor["role"].strip():
                    cur_actor_role = etree.SubElement(cur_actor, "role")
                    cur_actor_role.text = actor["role"].strip()

        if ep_to_write.description:
            overview = etree.SubElement(episode, "overview")
            overview.text = ep_to_write.description

        # Make it purdy
        helpers.indent_xml(root_node)
        data = etree.ElementTree(root_node)

    return data