# Buggy code
def update_show_indexer_metadata(self, show_obj):
    if self.show_metadata and show_obj and self._has_show_metadata(show_obj):
        logger.log(
            "Metadata provider "
            + self.name
            + " updating show indexer info metadata file for "
            + show_obj.name,
            logger.DEBUG,
        )

        nfo_file_path = self.get_show_file_path(show_obj)
        assert isinstance(nfo_file_path, text_type)

        try:
            with io.open(nfo_file_path, "rb") as xmlFileObj:
                showXML = etree.ElementTree(file=xmlFileObj)

            indexerid = showXML.find("id")

            root = showXML.getroot()
            if indexerid is not None:
                indexerid.text = str(show_obj.indexerid)
            else:
                etree.SubElement(root, "id").text = str(show_obj.indexerid)

            # Make it purdy
            helpers.indentXML(root)

            showXML.write(nfo_file_path, encoding="UTF-8")
            helpers.chmodAsParent(nfo_file_path)

            return True
        except IOError as e:
            logger.log(
                "Unable to write file to "
                + nfo_file_path
                + " - are you sure the folder is writable? "
                + ex(e),
                logger.ERROR,
            )


# Traceback (ParseError)
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Writing NFOs for all episodes
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E01
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E01.Where.Paradise.Is.Home.PROPER.720p.HDTV.x264-KILLERS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E01.Where.Paradise.Is.Home.PROPER.720p.HDTV.x264-KILLERS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E01.Where.Paradise.Is.Home.PROPER.720p.HDTV.x264-KILLERS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E01.Where.Paradise.Is.Home.PROPER.720p.HDTV.x264-KILLERS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E02
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E02.Dont.Discuss.Your.Life.Before.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E02.Dont.Discuss.Your.Life.Before.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E02.Dont.Discuss.Your.Life.Before.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E02.Dont.Discuss.Your.Life.Before.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E03
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E03.Our.Town.Our.Law.720p.HDTV.x264-DIMENSION.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E03.Our.Town.Our.Law.720p.HDTV.x264-DIMENSION-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E03.Our.Town.Our.Law.720p.HDTV.x264-DIMENSION.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E03.Our.Town.Our.Law.720p.HDTV.x264-DIMENSION-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E04
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E04.One.of.Our.Senior.Realtors.Has.Chosen.to.Retire.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E04.One.of.Our.Senior.Realtors.Has.Chosen.to.Retire.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E04.One.of.Our.Senior.Realtors.Has.Chosen.to.Retire.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E04.One.of.Our.Senior.Realtors.Has.Chosen.to.Retire.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E05
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E05.The.Truth.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E05.The.Truth.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E05.The.Truth.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E05.The.Truth.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E06
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E06.Choices.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E06.Choices.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E06.Choices.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E06.Choices.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E07
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E07.Betrayal.1080p.HDTV.x264-DIMENSION.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E07.Betrayal.1080p.HDTV.x264-DIMENSION-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E07.Betrayal.1080p.HDTV.x264-DIMENSION.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E07.Betrayal.1080p.HDTV.x264-DIMENSION-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E08
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E08.The.Friendliest.Place.on.Earth.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E08.The.Friendliest.Place.on.Earth.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E08.The.Friendliest.Place.on.Earth.1080p.WEB-DL.h264-KiNGS.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E08.The.Friendliest.Place.on.Earth.1080p.WEB-DL.h264-KiNGS-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E09
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E09.A.Reckoning.720p.HDTV.x264-DIMENSION.nfo exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E09.A.Reckoning.720p.HDTV.x264-DIMENSION-thumb.jpg exists: True
2016-09-10 04:37:01 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E09.A.Reckoning.720p.HDTV.x264-DIMENSION.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E09.A.Reckoning.720p.HDTV.x264-DIMENSION-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S01E10
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E10.Cycle.720p.HDTV.x264-DIMENSION.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E10.Cycle.720p.HDTV.x264-DIMENSION-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E10.Cycle.720p.HDTV.x264-DIMENSION.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 01/Wayward.Pines.S01E10.Cycle.720p.HDTV.x264-DIMENSION-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E02
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E02.Blood.Harvest.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E02.Blood.Harvest.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E02.Blood.Harvest.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E02.Blood.Harvest.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E03
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E03.Once.Upon.a.Time.in.Wayward.Pines.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E03.Once.Upon.a.Time.in.Wayward.Pines.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E03.Once.Upon.a.Time.in.Wayward.Pines.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E03.Once.Upon.a.Time.in.Wayward.Pines.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E04
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E04.Exit.Strategy.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E04.Exit.Strategy.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E04.Exit.Strategy.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E04.Exit.Strategy.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E05
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E05.Sound.the.Alarm.1080p.HDTV.x264-BRISK.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E05.Sound.the.Alarm.1080p.HDTV.x264-BRISK-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E05.Sound.the.Alarm.1080p.HDTV.x264-BRISK.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E05.Sound.the.Alarm.1080p.HDTV.x264-BRISK-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E06
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E06.City.Upon.a.Hill.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E06.City.Upon.a.Hill.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E06.City.Upon.a.Hill.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E06.City.Upon.a.Hill.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E07
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E07.Time.Will.Tell.1080p.WEB-DL.h264-ViSUM.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E07.Time.Will.Tell.1080p.WEB-DL.h264-ViSUM-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E07.Time.Will.Tell.1080p.WEB-DL.h264-ViSUM.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E07.Time.Will.Tell.1080p.WEB-DL.h264-ViSUM-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E08
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E08.Pass.Judgment.1080p.WEB-DL.h264-ViSUM.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E08.Pass.Judgment.1080p.WEB-DL.h264-ViSUM-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E08.Pass.Judgment.1080p.WEB-DL.h264-ViSUM.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E08.Pass.Judgment.1080p.WEB-DL.h264-ViSUM-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E09
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E09.Walcott.Prep.1080p.WEB-DL.h264-ViSUM.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E09.Walcott.Prep.1080p.WEB-DL.h264-ViSUM-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E09.Walcott.Prep.1080p.WEB-DL.h264-ViSUM.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E09.Walcott.Prep.1080p.WEB-DL.h264-ViSUM-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Retrieving/creating episode S02E10
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E10.Bedtime.Story.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E10.Bedtime.Story.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E10.Bedtime.Story.720p.HDTV.x264-AVS.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/Season 02/Wayward.Pines.S02E10.Bedtime.Story.720p.HDTV.x264-AVS-thumb.jpg exists: True
2016-09-10 04:37:02 INFO     SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Updating NFOs for show with new indexer info
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Checking if /media/extssd/Shows/Wayward Pines/tvshow.nfo exists: True
2016-09-10 04:37:02 DEBUG    SHOWQUEUE-REFRESH :: [c6c6e84] Metadata provider KODI 12+ updating show indexer info metadata file for Wayward Pines
2016-09-10 04:37:02 ERROR    SHOWQUEUE-REFRESH :: [c6c6e84] 269750: Error while refreshing show Wayward Pines. Error: unclosed token: line 104, column 12
Traceback (most recent call last):
  File "/home/home/SickRage/sickbeard/show_queue.py", line 581, in run
    self.show.update_metadata()
  File "/home/home/SickRage/sickbeard/tv.py", line 547, in update_metadata
    self.__update_show_nfo()
  File "/home/home/SickRage/sickbeard/tv.py", line 555, in __update_show_nfo
    result = cur_provider.update_show_indexer_metadata(self) or result
  File "/home/home/SickRage/sickbeard/metadata/generic.py", line 273, in update_show_indexer_metadata
    showXML = etree.ElementTree(file=xmlFileObj)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 611, in __init__
    self.parse(file)
  File "<string>", line 38, in parse
ParseError: unclosed token: line 104, column 12

# Fixed code
def update_show_indexer_metadata(self, show_obj):
    if self.show_metadata and show_obj and self._has_show_metadata(show_obj):
        logger.log(
            "Metadata provider "
            + self.name
            + " updating show indexer info metadata file for "
            + show_obj.name,
            logger.DEBUG,
        )

        nfo_file_path = self.get_show_file_path(show_obj)
        assert isinstance(nfo_file_path, text_type)

        try:
            with io.open(nfo_file_path, "rb", encoding="utf8") as xmlFileObj:
                showXML = etree.ElementTree(file=xmlFileObj)

            indexerid = showXML.find("id")

            root = showXML.getroot()
            if indexerid is not None:
                indexerid.text = str(show_obj.indexerid)
            else:
                etree.SubElement(root, "id").text = str(show_obj.indexerid)

            # Make it purdy
            helpers.indentXML(root)

            showXML.write(nfo_file_path, encoding="UTF-8")
            helpers.chmodAsParent(nfo_file_path)

            return True
        except etree.ParseError as error:
            logger.log(
                "Received an invalid XML for {show}, try again later. Error: {error_msg}".format(
                    show=show_obj.name, error_msg=error
                ),
                logger.WARNING,
            )
        except IOError as e:
            logger.log(
                "Unable to write file to "
                + nfo_file_path
                + " - are you sure the folder is writable? "
                + ex(e),
                logger.ERROR,
            )