# Buggy code
def retrieveShowMetadata(self, folder):
    """
    Used only when mass adding Existing Shows, using previously generated Show metadata to reduce the need to query TVDB.
    """

    empty_return = (None, None, None)

    assert isinstance(folder, text_type)

    metadata_path = ek(os.path.join, folder, self._show_metadata_filename)

    if not ek(os.path.isdir, folder) or not ek(os.path.isfile, metadata_path):
        logger.log(
            "Can't load the metadata file from " + metadata_path + ", it doesn't exist",
            logger.DEBUG,
        )
        return empty_return

    logger.log("Loading show info from metadata file in " + folder, logger.DEBUG)

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

        if showXML.findtext("title") is None or (
            showXML.findtext("tvdbid") is None and showXML.findtext("id") is None
        ):
            logger.log(
                "Invalid info in tvshow.nfo (missing name or id): %s %s %s"
                % (
                    showXML.findtext("title"),
                    showXML.findtext("tvdbid"),
                    showXML.findtext("id"),
                )
            )
            return empty_return

        name = showXML.findtext("title")

        if showXML.findtext("tvdbid"):
            indexer_id = int(showXML.findtext("tvdbid"))
        elif showXML.findtext("id"):
            indexer_id = int(showXML.findtext("id"))
        else:
            logger.log(
                "Empty <id> or <tvdbid> field in NFO, unable to find a ID",
                logger.WARNING,
            )
            return empty_return

        if indexer_id is None:
            logger.log(
                "Invalid Indexer ID (" + str(indexer_id) + "), not using metadata file",
                logger.WARNING,
            )
            return empty_return

        indexer = None
        if showXML.find("episodeguide/url"):
            epg_url = showXML.findtext("episodeguide/url").lower()
            if str(indexer_id) in epg_url:
                if "thetvdb.com" in epg_url:
                    indexer = 1
                elif "tvrage" in epg_url:
                    logger.log(
                        "Invalid Indexer ID ("
                        + str(indexer_id)
                        + "), not using metadata file because it has TVRage info",
                        logger.WARNING,
                    )
                    return empty_return

    except Exception as e:
        logger.log(
            "There was an error parsing your existing metadata file: '"
            + metadata_path
            + "' error: "
            + ex(e),
            logger.WARNING,
        )
        return empty_return

    return indexer_id, name, indexer


# 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 retrieveShowMetadata(self, folder):
    """
    Used only when mass adding Existing Shows, using previously generated Show metadata to reduce the need to query TVDB.
    """

    empty_return = (None, None, None)

    assert isinstance(folder, text_type)

    metadata_path = ek(os.path.join, folder, self._show_metadata_filename)

    if not ek(os.path.isdir, folder) or not ek(os.path.isfile, metadata_path):
        logger.log(
            "Can't load the metadata file from " + metadata_path + ", it doesn't exist",
            logger.DEBUG,
        )
        return empty_return

    logger.log("Loading show info from metadata file in " + folder, logger.DEBUG)

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

        if showXML.findtext("title") is None or (
            showXML.findtext("tvdbid") is None and showXML.findtext("id") is None
        ):
            logger.log(
                "Invalid info in tvshow.nfo (missing name or id): %s %s %s"
                % (
                    showXML.findtext("title"),
                    showXML.findtext("tvdbid"),
                    showXML.findtext("id"),
                )
            )
            return empty_return

        name = showXML.findtext("title")

        if showXML.findtext("tvdbid"):
            indexer_id = int(showXML.findtext("tvdbid"))
        elif showXML.findtext("id"):
            indexer_id = int(showXML.findtext("id"))
        else:
            logger.log(
                "Empty <id> or <tvdbid> field in NFO, unable to find a ID",
                logger.WARNING,
            )
            return empty_return

        if indexer_id is None:
            logger.log(
                "Invalid Indexer ID (" + str(indexer_id) + "), not using metadata file",
                logger.WARNING,
            )
            return empty_return

        indexer = None
        if showXML.find("episodeguide/url"):
            epg_url = showXML.findtext("episodeguide/url").lower()
            if str(indexer_id) in epg_url:
                if "thetvdb.com" in epg_url:
                    indexer = 1
                elif "tvrage" in epg_url:
                    logger.log(
                        "Invalid Indexer ID ("
                        + str(indexer_id)
                        + "), not using metadata file because it has TVRage info",
                        logger.WARNING,
                    )
                    return empty_return

    except Exception as e:
        logger.log(
            "There was an error parsing your existing metadata file: '"
            + metadata_path
            + "' error: "
            + ex(e),
            logger.WARNING,
        )
        return empty_return

    return indexer_id, name, indexer