# Buggy code
def get_scene_exceptions_by_name(show_name):
    """Look for a series_id, season and indexer for a given series scene exception."""
    # TODO: Rewrite to use exceptions_cache since there is no need to hit db.
    # TODO: Make the query more linient. For example. `Jojo's Bizarre Adventure Stardust Crusaders` will not match
    # while `Jojo's Bizarre Adventure - Stardust Crusaders` is available.
    # Try the obvious case first
    cache_db_con = db.DBConnection("cache.db")
    scene_exceptions = cache_db_con.select(
        b"SELECT indexer, indexer_id, season "
        b"FROM scene_exceptions "
        b"WHERE show_name = ? ORDER BY season ASC",
        [show_name],
    )
    if scene_exceptions:
        # FIXME: Need to add additional layer indexer.
        return [
            (
                int(exception[b"indexer_id"]),
                int(exception[b"season"]),
                int(exception[b"indexer"]),
            )
            for exception in scene_exceptions
        ]

    result = []
    scene_exceptions = cache_db_con.select(
        b"SELECT show_name, indexer, indexer_id, season FROM scene_exceptions"
    )

    for exception in scene_exceptions:
        indexer = int(exception[b"indexer"])
        indexer_id = int(exception[b"indexer_id"])
        season = int(exception[b"season"])
        exception_name = exception[b"show_name"]

        sanitized_name = helpers.sanitize_scene_name(exception_name)
        show_names = (
            exception_name.lower(),
            sanitized_name.lower().replace(".", " "),
        )

        if show_name.lower() in show_names:
            logger.debug(
                "Scene exception lookup got indexer ID {cur_indexer}, using that",
                cur_indexer=indexer_id,
            )
            result.append((indexer_id, season, indexer))

    return result or [(None, None, None)]


# Traceback (AttributeError)
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: seasons/71863-4-4.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/seasons/71863-4-4.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: seasons/71863-2-6.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/seasons/71863-2-6.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: seasons/71863-1-4.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/seasons/71863-1-4.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: seasons/71863-3-3.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/seasons/71863-3-3.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: seasons/71863-0-3.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/seasons/71863-0-3.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: seasons/71863-5.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/seasons/71863-5.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: seasons/5af1ccc389490.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/seasons/5af1ccc389490.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] GET URL: https://api.thetvdb.com/series/71863/images/query?keyType=series [Status: 200]
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] User-Agent: Medusa/0.2.8 (Linux; 4.9.0-8-amd64; da8d052e-a50f-11e8-a855-0242ac120004)
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: graphical/71863-g2.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/graphical/71863-g2.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: graphical/71863-g.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/graphical/71863-g.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: graphical/71863-g4.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/graphical/71863-g4.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: graphical/71863-g5.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Adding base url for image: _cache/graphical/71863-g5.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] No banners found for 71863
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Found 8 fanarts at 1280x720 (1) resolution for series 71863
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Found 6 fanarts at 1920x1080 (2) resolution for series 71863
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Found 14 total fanarts for series 71863
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Fanart threshold set to 4.3522651571 votes
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Weighted fanart results for series 71863:
     Score     Rating  Votes      Resolution	URL
     4.004      7.500      2       1920x1080	https://www.thetvdb.com/banners/fanart/original/71863-14.jpg
     3.944      6.300      6       1920x1080	https://www.thetvdb.com/banners/fanart/original/71863-6.jpg
     3.703      5.500      4       1920x1080	https://www.thetvdb.com/banners/fanart/original/71863-7.jpg
     3.689      5.500      2       1920x1080	https://www.thetvdb.com/banners/fanart/original/71863-9.jpg
     3.610      5.000      2       1920x1080	https://www.thetvdb.com/banners/fanart/original/71863-10.jpg
     3.610      5.000      2       1920x1080	https://www.thetvdb.com/banners/fanart/original/71863-3.jpg
     3.396      6.200      5        1280x720	https://www.thetvdb.com/banners/fanart/original/71863-4.jpg
     3.396      6.200      5        1280x720	https://www.thetvdb.com/banners/fanart/original/71863-2.jpg
     3.360      6.300      3        1280x720	https://www.thetvdb.com/banners/fanart/original/71863-5.jpg
     3.189      5.500      2        1280x720	https://www.thetvdb.com/banners/fanart/original/71863-13.jpg
     3.189      5.500      2        1280x720	https://www.thetvdb.com/banners/fanart/original/71863-8.jpg
     3.189      5.500      2        1280x720	https://www.thetvdb.com/banners/fanart/original/71863-12.jpg
     3.161      0.000      0        1280x720	https://www.thetvdb.com/banners/fanart/original/71863-1.jpg
     3.031      4.500      2        1280x720	https://www.thetvdb.com/banners/fanart/original/71863-11.jpg
2018-08-21 22:50:32 INFO     SHOWQUEUE-UPDATE :: [f5973b2] Selected fanart for series 71863 (score=4.00367406064, score_bay=6.00734812129, rating=7.5, votes=2, res=1920x1080): https://www.thetvdb.com/banners/fanart/original/71863-14.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Full info for best fanart for series 71863: {u'rating': 7.5, u'_thumbnailpath': u'https://www.thetvdb.com/banners/_cache/fanart/original/71863-14.jpg', u'language': 7, u'score_weighted': 4.003674060643535, u'bannertype2': u'1920x1080', u'bannertype': u'fanart', u'score_rated': 6.007348121287069, u'ratingcount': 2, u'res_index': 2, u'_bannerpath': u'https://www.thetvdb.com/banners/fanart/original/71863-14.jpg', u'resolution': u'1920x1080', u'sub_key': u'graphical'}
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Found 11 posters at 680x1000 (1) resolution for series 71863
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Found 11 total posters for series 71863
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Poster threshold set to 5.28179556748 votes
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Weighted poster results for series 71863:
     Score     Rating  Votes      Resolution	URL
     4.086      8.300      4        680x1000	https://www.thetvdb.com/banners/posters/71863-7.jpg
     3.952     10.000      1        680x1000	https://www.thetvdb.com/banners/posters/5afc634715823.jpg
     3.882      7.100      7        680x1000	https://www.thetvdb.com/banners/posters/71863-4.jpg
     3.837      7.300      3        680x1000	https://www.thetvdb.com/banners/posters/71863-6.jpg
     3.655      6.300      4        680x1000	https://www.thetvdb.com/banners/posters/71863-2.jpg
     3.628      6.200      6        680x1000	https://www.thetvdb.com/banners/posters/71863-3.jpg
     3.547      5.500      2        680x1000	https://www.thetvdb.com/banners/posters/71863-1.jpg
     3.547      5.500      2        680x1000	https://www.thetvdb.com/banners/posters/71863-10.jpg
     3.478      5.000      2        680x1000	https://www.thetvdb.com/banners/posters/71863-9.jpg
     3.409      4.500      2        680x1000	https://www.thetvdb.com/banners/posters/71863-8.jpg
     3.047      3.800      5        680x1000	https://www.thetvdb.com/banners/posters/71863-5.jpg
2018-08-21 22:50:32 INFO     SHOWQUEUE-UPDATE :: [f5973b2] Selected poster for series 71863 (score=4.08612427077, score_bay=7.17224854155, rating=8.3, votes=4, res=680x1000): https://www.thetvdb.com/banners/posters/71863-7.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Full info for best poster for series 71863: {u'rating': 8.3, u'_thumbnailpath': u'https://www.thetvdb.com/banners/_cache/posters/71863-7.jpg', u'language': 7, u'score_weighted': 4.086124270774178, u'bannertype2': u'680x1000', u'bannertype': u'poster', u'score_rated': 7.172248541548356, u'ratingcount': 4, u'res_index': 1, u'_bannerpath': u'https://www.thetvdb.com/banners/posters/71863-7.jpg', u'resolution': u'680x1000', u'sub_key': u''}
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Getting actors for 71863
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] GET URL: https://api.thetvdb.com/series/71863/actors [Status: 200]
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] User-Agent: Medusa/0.2.8 (Linux; 4.9.0-8-amd64; da8d052e-a50f-11e8-a855-0242ac120004)
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Fetching image from https://www.thetvdb.com/banners/graphical/71863-g5.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] GET URL: https://www.thetvdb.com/banners/graphical/71863-g5.jpg [Status: 200]
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] User-Agent: Medusa/0.2.8 (Linux; 4.9.0-8-amd64; da8d052e-a50f-11e8-a855-0242ac120004)
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Searching for poster for series indexerid: 71863
indexer: 1
name: Lupin III
location: /anime/Lupin III
network: NTV (JP)
airs: Wednesday 01:29
status: Continuing
start_year: 1971
genre: Action|Adventure|Animation|Comedy|Crime
classification: Scripted
runtime: 25
quality: 6
scene: False
sports: False
anime: True
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Fetching image from https://www.thetvdb.com/banners/posters/71863-7.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] GET URL: https://www.thetvdb.com/banners/posters/71863-7.jpg [Status: 200]
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] User-Agent: Medusa/0.2.8 (Linux; 4.9.0-8-amd64; da8d052e-a50f-11e8-a855-0242ac120004)
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Searching for banner_thumb for series indexerid: 71863
indexer: 1
name: Lupin III
location: /anime/Lupin III
network: NTV (JP)
airs: Wednesday 01:29
status: Continuing
start_year: 1971
genre: Action|Adventure|Animation|Comedy|Crime
classification: Scripted
runtime: 25
quality: 6
scene: False
sports: False
anime: True
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Fetching image from https://www.thetvdb.com/banners/_cache/graphical/71863-g5.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] GET URL: https://www.thetvdb.com/banners/_cache/graphical/71863-g5.jpg [Status: 200]
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] User-Agent: Medusa/0.2.8 (Linux; 4.9.0-8-amd64; da8d052e-a50f-11e8-a855-0242ac120004)
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Searching for poster_thumb for series indexerid: 71863
indexer: 1
name: Lupin III
location: /anime/Lupin III
network: NTV (JP)
airs: Wednesday 01:29
status: Continuing
start_year: 1971
genre: Action|Adventure|Animation|Comedy|Crime
classification: Scripted
runtime: 25
quality: 6
scene: False
sports: False
anime: True
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Fetching image from https://www.thetvdb.com/banners/_cache/posters/71863-7.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] GET URL: https://www.thetvdb.com/banners/_cache/posters/71863-7.jpg [Status: 200]
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] User-Agent: Medusa/0.2.8 (Linux; 4.9.0-8-amd64; da8d052e-a50f-11e8-a855-0242ac120004)
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Searching for fanart for series indexerid: 71863
indexer: 1
name: Lupin III
location: /anime/Lupin III
network: NTV (JP)
airs: Wednesday 01:29
status: Continuing
start_year: 1971
genre: Action|Adventure|Animation|Comedy|Crime
classification: Scripted
runtime: 25
quality: 6
scene: False
sports: False
anime: True
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] Fetching image from https://www.thetvdb.com/banners/fanart/original/71863-14.jpg
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] GET URL: https://www.thetvdb.com/banners/fanart/original/71863-14.jpg [Status: 200]
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] User-Agent: Medusa/0.2.8 (Linux; 4.9.0-8-amd64; da8d052e-a50f-11e8-a855-0242ac120004)
2018-08-21 22:50:32 INFO     SHOWQUEUE-UPDATE :: [f5973b2] Cache check completed
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] 71863: Finished update of Lupin III
2018-08-21 22:50:32 DEBUG    SHOWQUEUE-UPDATE :: [f5973b2] 71863: Queueing show refresh for Lupin III
2018-08-21 22:50:35 INFO     SHOWQUEUE-REFRESH :: [f5973b2] 71863: Performing refresh on Lupin III
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] 71863: Loading all episodes from the show directory: /anime/Lupin III
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] 71863: Found files: [u'/anime/Lupin III/Season 02/S02E101.mkv', u'/anime/Lupin III/Season 02/S02E046.mkv', u'/anime/Lupin III/Season 02/S02E077.mkv', u'/anime/Lupin III/Season 02/S02E90.mkv', u'/anime/Lupin III/Season 02/S02E029.mkv', u'/anime/Lupin III/Season 02/S02E106.mkv', u'/anime/Lupin III/Season 02/S02E065.mkv', u'/anime/Lupin III/Season 02/S02E155.mkv', u'/anime/Lupin III/Season 02/S02E042.mkv', u'/anime/Lupin III/Season 02/S02E028.mkv', u'/anime/Lupin III/Season 02/S02E032.mkv', u'/anime/Lupin III/Season 02/S02E001.mkv', u'/anime/Lupin III/Season 02/S02E057.mkv', u'/anime/Lupin III/Season 02/S02E037.mkv', u'/anime/Lupin III/Season 02/S02E054.mkv', u'/anime/Lupin III/Season 02/S02E002.mkv', u'/anime/Lupin III/Season 02/S02E112.mkv', u'/anime/Lupin III/Season 02/S02E84.mkv', u'/anime/Lupin III/Season 02/S02E034.mkv', u'/anime/Lupin III/Season 02/S02E121.mkv', u'/anime/Lupin III/Season 02/S02E145.mkv', u'/anime/Lupin III/Season 02/S02E004.mkv', u'/anime/Lupin III/Season 02/S02E026.mkv', u'/anime/Lupin III/Season 02/S02E143.mkv', u'/anime/Lupin III/Season 02/S02E036.mkv', u'/anime/Lupin III/Season 02/S02E154.mkv', u'/anime/Lupin III/Season 02/S02E063.mkv', u'/anime/Lupin III/Season 02/S02E88.mkv', u'/anime/Lupin III/Season 02/S02E048.mkv', u'/anime/Lupin III/Season 02/S02E80.mkv', u'/anime/Lupin III/Season 02/S02E049.mkv', u'/anime/Lupin III/Season 02/S02E041.mkv', u'/anime/Lupin III/Season 02/S02E043.mkv', u'/anime/Lupin III/Season 02/S02E060.mkv', u'/anime/Lupin III/Season 02/S02E019.mkv', u'/anime/Lupin III/Season 02/S02E81.mkv', u'/anime/Lupin III/Season 02/S02E100.mkv', u'/anime/Lupin III/Season 02/S02E146.mkv', u'/anime/Lupin III/Season 02/S02E008.mkv', u'/anime/Lupin III/Season 02/S02E118.mkv', u'/anime/Lupin III/Season 02/S02E039.mkv', u'/anime/Lupin III/Season 02/S02E127.mkv', u'/anime/Lupin III/Season 02/S02E069.mkv', u'/anime/Lupin III/Season 02/S02E122.mkv', u'/anime/Lupin III/Season 02/S02E067.mkv', u'/anime/Lupin III/Season 02/S02E85.mkv', u'/anime/Lupin III/Season 02/S02E066.mkv', u'/anime/Lupin III/Season 02/S02E022.mkv', u'/anime/Lupin III/Season 02/S02E113.mkv', u'/anime/Lupin III/Season 02/S02E97.mkv', u'/anime/Lupin III/Season 02/S02E83.mkv', u'/anime/Lupin III/Season 02/S02E131.mkv', u'/anime/Lupin III/Season 02/S02E013.mkv', u'/anime/Lupin III/Season 02/S02E047.mkv', u'/anime/Lupin III/Season 02/S02E052.mkv', u'/anime/Lupin III/Season 02/S02E117.mkv', u'/anime/Lupin III/Season 02/S02E015.mkv', u'/anime/Lupin III/Season 02/S02E82.mkv', u'/anime/Lupin III/Season 02/S02E058.mkv', u'/anime/Lupin III/Season 02/S02E110.mkv', u'/anime/Lupin III/Season 02/S02E068.mkv', u'/anime/Lupin III/Season 02/S02E152.mkv', u'/anime/Lupin III/Season 02/S02E035.mkv', u'/anime/Lupin III/Season 02/S02E135.mkv', u'/anime/Lupin III/Season 02/S02E006.mkv', u'/anime/Lupin III/Season 02/S02E132.mkv', u'/anime/Lupin III/Season 02/S02E014.mkv', u'/anime/Lupin III/Season 02/S02E126.mkv', u'/anime/Lupin III/Season 02/S02E120.mkv', u'/anime/Lupin III/Season 02/S02E064.mkv', u'/anime/Lupin III/Season 02/S02E89.mkv', u'/anime/Lupin III/Season 02/S02E027.mkv', u'/anime/Lupin III/Season 02/S02E021.mkv', u'/anime/Lupin III/Season 02/S02E003.mkv', u'/anime/Lupin III/Season 02/S02E137.mkv', u'/anime/Lupin III/Season 02/S02E062.mkv', u'/anime/Lupin III/Season 02/S02E105.mkv', u'/anime/Lupin III/Season 02/S02E031.mkv', u'/anime/Lupin III/Season 02/S02E115.mkv', u'/anime/Lupin III/Season 02/S02E045.mkv', u'/anime/Lupin III/Season 02/S02E153.mkv', u'/anime/Lupin III/Season 02/S02E151.mkv', u'/anime/Lupin III/Season 02/S02E108.mkv', u'/anime/Lupin III/Season 02/S02E073.mkv', u'/anime/Lupin III/Season 02/S02E93.mkv', u'/anime/Lupin III/Season 02/S02E053.mkv', u'/anime/Lupin III/Season 02/S02E129.mkv', u'/anime/Lupin III/Season 02/S02E020.mkv', u'/anime/Lupin III/Season 02/S02E134.mkv', u'/anime/Lupin III/Season 02/S02E012.mkv', u'/anime/Lupin III/Season 02/S02E061.mkv', u'/anime/Lupin III/Season 02/S02E144.mkv', u'/anime/Lupin III/Season 02/S02E007.mkv', u'/anime/Lupin III/Season 02/S02E018.mkv', u'/anime/Lupin III/Season 02/S02E139.mkv', u'/anime/Lupin III/Season 02/S02E079.mkv', u'/anime/Lupin III/Season 02/S02E010.mkv', u'/anime/Lupin III/Season 02/S02E150.mkv', u'/anime/Lupin III/Season 02/S02E130.mkv', u'/anime/Lupin III/Season 02/S02E125.mkv', u'/anime/Lupin III/Season 02/S02E102.mkv', u'/anime/Lupin III/Season 02/S02E104.mkv', u'/anime/Lupin III/Season 02/S02E056.mkv', u'/anime/Lupin III/Season 02/S02E96.mkv', u'/anime/Lupin III/Season 02/S02E023.mkv', u'/anime/Lupin III/Season 02/S02E87.mkv', u'/anime/Lupin III/Season 02/S02E114.mkv', u'/anime/Lupin III/Season 02/S02E147.mkv', u'/anime/Lupin III/Season 02/S02E136.mkv', u'/anime/Lupin III/Season 02/S02E011.mkv', u'/anime/Lupin III/Season 02/S02E040.mkv', u'/anime/Lupin III/Season 02/S02E107.mkv', u'/anime/Lupin III/Season 02/S02E98.mkv', u'/anime/Lupin III/Season 02/S02E070.mkv', u'/anime/Lupin III/Season 02/S02E050.mkv', u'/anime/Lupin III/Season 02/S02E128.mkv', u'/anime/Lupin III/Season 02/S02E92.mkv', u'/anime/Lupin III/Season 02/S02E94.mkv', u'/anime/Lupin III/Season 02/S02E038.mkv', u'/anime/Lupin III/Season 02/S02E138.mkv', u'/anime/Lupin III/Season 02/S02E076.mkv', u'/anime/Lupin III/Season 02/S02E071.mkv', u'/anime/Lupin III/Season 02/S02E055.mkv', u'/anime/Lupin III/Season 02/S02E033.mkv', u'/anime/Lupin III/Season 02/S02E119.mkv', u'/anime/Lupin III/Season 02/S02E017.mkv', u'/anime/Lupin III/Season 02/S02E005.mkv', u'/anime/Lupin III/Season 02/S02E075.mkv', u'/anime/Lupin III/Season 02/S02E86.mkv', u'/anime/Lupin III/Season 02/S02E009.mkv', u'/anime/Lupin III/Season 02/S02E025.mkv', u'/anime/Lupin III/Season 02/S02E116.mkv', u'/anime/Lupin III/Season 02/S02E142.mkv', u'/anime/Lupin III/Season 02/S02E044.mkv', u'/anime/Lupin III/Season 02/S02E078.mkv', u'/anime/Lupin III/Season 02/S02E91.mkv', u'/anime/Lupin III/Season 02/S02E072.mkv', u'/anime/Lupin III/Season 02/S02E123.mkv', u'/anime/Lupin III/Season 02/S02E111.mkv', u'/anime/Lupin III/Season 02/S02E95.mkv', u'/anime/Lupin III/Season 02/S02E030.mkv', u'/anime/Lupin III/Season 02/S02E059.mkv', u'/anime/Lupin III/Season 02/S02E024.mkv', u'/anime/Lupin III/Season 02/S02E140.mkv', u'/anime/Lupin III/Season 02/S02E103.mkv', u'/anime/Lupin III/Season 02/S02E149.mkv', u'/anime/Lupin III/Season 02/S02E133.mkv', u'/anime/Lupin III/Season 02/S02E109.mkv', u'/anime/Lupin III/Season 02/S02E99.mkv', u'/anime/Lupin III/Season 02/S02E124.mkv', u'/anime/Lupin III/Season 02/S02E074.mkv', u'/anime/Lupin III/Season 02/S02E148.mkv', u'/anime/Lupin III/Season 02/S02E141.mkv', u'/anime/Lupin III/Season 02/S02E051.mkv', u'/anime/Lupin III/Season 02/S02E016.mkv', u'/anime/Lupin III/Season 01/S01E02 - The Man They Call a Magician [neo1024][720p][BD5CD9B8].mkv', u'/anime/Lupin III/Season 01/S01E01 - Lupin is Burning.mkv', u'/anime/Lupin III/Season 01/S01E13 - Beware of the Time Machine!.mkv', u'/anime/Lupin III/Season 01/S01E05 - Introducing Goemon the 13th.mkv', u'/anime/Lupin III/Season 01/S01E22 - The First Move Wins Computer Operation.mkv', u'/anime/Lupin III/Season 01/S01E08 - Everyone Meets Again, the Trump Plan.mkv', u"/anime/Lupin III/Season 01/S01E15 - Let's Catch Lupin and Go to Europe.mkv", u'/anime/Lupin III/Season 01/S01E21 - Rescue the Tomboy!.mkv', u'/anime/Lupin III/Season 01/S01E06 - Danger of a Rainy Afternoon.mkv', u'/anime/Lupin III/Season 01/S01E10 - Target the Counterfeit Money Maker.mkv', u'/anime/Lupin III/Season 01/S01E03 - Farewell My Beloved Witch.mkv', u'/anime/Lupin III/Season 01/S01E19 - Which of the Third Generation Will Win.mkv', u'/anime/Lupin III/Season 01/S01E04 - One Chance for a Prison Break.mkv', u'/anime/Lupin III/Season 01/S01E07 - A Wolf is a Wolf.mkv', u'/anime/Lupin III/Season 01/S01E20 - Catch the Phony Lupin!.mkv', u'/anime/Lupin III/Season 01/S01E16 - Operation Jewel Snatch.mkv', u"/anime/Lupin III/Season 01/S01E14 - The Emerald's Secret.mkv", u'/anime/Lupin III/Season 01/S01E17 - Lupin Caught in a Trap.mkv', u'/anime/Lupin III/Season 01/S01E11 - When the Seventh Bridge Falls.mkv', u'/anime/Lupin III/Season 01/S01E09 - An Assassin Sings the Blues.mkv', u"/anime/Lupin III/Season 01/S01E12 - Who's the Last One to Laugh.mkv", u'/anime/Lupin III/Season 01/S01E23 - The Great Gold Showdown!.mkv', u'/anime/Lupin III/Season 01/S01E18 - Keep an Eye on the Beauty Contest.mkv', u'/anime/Lupin III/Season 03/S03E25 - We Are not Angels.mkv', u'/anime/Lupin III/Season 03/S03E34 - Manhattan Crisis.mkv', u'/anime/Lupin III/Season 03/S03E09 - The Copy-Man Comes Expensive.mkv', u'/anime/Lupin III/Season 03/S03E35 - Target Was Gone Beyond the Snow Field.mkv', u'/anime/Lupin III/Season 03/S03E21 - Farewell, Golden Legend.mkv', u"/anime/Lupin III/Season 03/S03E04 - Telepathy Is Love's Signal.mkv", u'/anime/Lupin III/Season 03/S03E28 - The Alaska Star Is a Ticket to Hell.mkv', u'/anime/Lupin III/Season 03/S03E01 - The Gold Is Beckoning Lupin.mkv', u'/anime/Lupin III/Season 03/S03E43 - Farewell, Cinderella.mkv', u'/anime/Lupin III/Season 03/S03E11 - The Ruby Sheds Bloody Tears.mkv', u'/anime/Lupin III/Season 03/S03E23 - The Strategy of Beirut Mobile Bank Robbery.mkv', u'/anime/Lupin III/Season 03/S03E41 - A Night under Martial Law.mkv', u'/anime/Lupin III/Season 03/S03E13 - Play a Joke on the Variation.mkv', u'/anime/Lupin III/Season 03/S03E16 - The Golden Apple has Poison.mkv', u'/anime/Lupin III/Season 03/S03E36 - The Eagle Alights on the Glory.mkv', u'/anime/Lupin III/Season 03/S03E44 - Our Papa Is a Thief.mkv', u'/anime/Lupin III/Season 03/S03E40 - In a Panic over the Treasure.mkv', u'/anime/Lupin III/Season 03/S03E05 - Goemon Daydream.mkv', u'/anime/Lupin III/Season 03/S03E22 - The Fire Is Not Suitable for a Diamond.mkv', u'/anime/Lupin III/Season 03/S03E20 - Cross His Name Off the List.mkv', u'/anime/Lupin III/Season 03/S03E18 - Show Time Is Death Feeling.mkv', u'/anime/Lupin III/Season 03/S03E02 - Expose the Great Trap.mkv', u'/anime/Lupin III/Season 03/S03E33 - A Boy Genius Plays a Dangerous Game [neo1024][C0FE8926]-OUT.mkv', u"/anime/Lupin III/Season 03/S03E29 - Let's Go to the Honey-Moon.mkv", u'/anime/Lupin III/Season 03/S03E19 - An Act of Betrayal.mkv', u'/anime/Lupin III/Season 03/S03E46 - Worn-Out Wings.mkv', u'/anime/Lupin III/Season 03/S03E39 - Give the Gold to the Rival.mkv', u'/anime/Lupin III/Season 03/S03E31 - Reversal, Reversal and Again Reversal.mkv', u'/anime/Lupin III/Season 03/S03E32 - 10 million Dollar Key.mkv', u'/anime/Lupin III/Season 03/S03E24 - Pray for the Repose of Your Soul.mkv', u'/anime/Lupin III/Season 03/S03E37 - Pops Boils over with Rage.mkv', u"/anime/Lupin III/Season 03/S03E14 - Let's Play the Abduction.mkv", u'/anime/Lupin III/Season 03/S03E17 - Are You Really Getting Married.mkv', u'/anime/Lupin III/Season 03/S03E38 - Letiethia Loved Me.mkv', u'/anime/Lupin III/Season 03/S03E06 - Lupin has Come with a Tank.mkv', u"/anime/Lupin III/Season 03/S03E03 - Good Afternoon, Hell's Angel.mkv", u"/anime/Lupin III/Season 03/S03E08 - Virgin Mary's Getaway Strategy.mkv", u'/anime/Lupin III/Season 03/S03E30 - The Name of the Cocktail Is Revenge.mkv', u'/anime/Lupin III/Season 03/S03E42 - Plunder the Pyramid of Insurance.mkv', u'/anime/Lupin III/Season 03/S03E26 - The Ghost of New York.mkv', u'/anime/Lupin III/Season 03/S03E12 - The Prisoner of a Valtan Palace.mkv', u'/anime/Lupin III/Season 03/S03E47 - A Famous Picture.mkv', u"/anime/Lupin III/Season 03/S03E48 - Tears Stood in Hades' Eyes.mkv", u'/anime/Lupin III/Season 03/S03E27 - Code Name Is Alaska Star.mkv', u'/anime/Lupin III/Season 03/S03E07 - The Man Is Called the Death Garb.mkv', u'/anime/Lupin III/Season 03/S03E49 - Pops Was Adopted into the Family.mkv', u'/anime/Lupin III/Season 03/S03E10 - Lay a Plot with the Treasure.mkv', u'/anime/Lupin III/Season 03/S03E50 - Kill the Atomic Submarine Ivanov.mkv', u'/anime/Lupin III/Season 03/S03E15 - The Killer Comes Along Quietly.mkv', u'/anime/Lupin III/Season 03/S03E45 - A Toast to the Con-Game.mkv', u'/anime/Lupin III/Season 00/Stolen Lupin.mkv', u'/anime/Lupin III/Season 00/Sweet Lost Night.mkv', u'/anime/Lupin III/Season 00/Dead or Alive.mkv', u'/anime/Lupin III/Season 00/Elusiveness of the Fog.mkv', u'/anime/Lupin III/Season 00/S00E27.mkv', u"/anime/Lupin III/Season 00/Steal Napoleon's Dictionary (Pt. 2).mkv", u'/anime/Lupin III/Season 00/S00E35.mkv', u'/anime/Lupin III/Season 00/Mystery of the Hemingway Papers.mkv', u'/anime/Lupin III/Season 00/Missed By a Dollar.mkv', u'/anime/Lupin III/Season 00/Lupin III - Family All-Stars [English Subtitles].mkv', u"/anime/Lupin III/Season 00/The Pursuit of Harimao's Treasure.mkv", u'/anime/Lupin III/Season 00/Lupin III Pilot Film 1 - TV.mkv', u'/anime/Lupin III/Season 00/Lupin III vs Detective Conan.mkv', u'/anime/Lupin III/Season 00/Green vs Red.mkv', u'/anime/Lupin III/Season 00/Die! Nostradamus.mkv', u"/anime/Lupin III/Season 00/Steal Napoleon's Dictionary (Pt. 1).mkv", u'/anime/Lupin III/Season 00/Lupin III - Legend of the Gold of Babylon [Akai][DVD][10bit][AF6D323D].mkv', u'/anime/Lupin III/Season 00/Lupin VIII  - Pilot Episode [English Subtitles].mkv', u'/anime/Lupin III/Season 00/Lupin III Pilot Film 2 -.mkv', u'/anime/Lupin III/Season 00/Return of Pycal.avi', u'/anime/Lupin III/Season 00/The Last Job.mkv', u'/anime/Lupin III/Season 00/Monkey Majik.mp4', u'/anime/Lupin III/Season 00/Lupin III Pilot Film 1 - TV [480p][neo1024][03AE79BB].mkv', u'/anime/Lupin III/Season 00/Operation Return the Treasure.mkv', u"/anime/Lupin III/Season 00/Da Capo of Love - Fujiko's Unlucky Days.mkv", u'/anime/Lupin III/Season 00/Dragon of Doom.mkv', u'/anime/Lupin III/Season 00/[Shiniori-Raws] Lupin III Master File Special 2012 (BD 1280x720 x264 AAC).mp4', u'/anime/Lupin III/Season 00/Island of Assassins.mkv', u'/anime/Lupin III/Season 00/Voyage to Danger.mkv', u'/anime/Lupin III/Season 00/The Secret of Mamo.mkv', u'/anime/Lupin III/Season 00/Episode 0 - The First Contact.mkv', u'/anime/Lupin III/Season 00/Etermal Mermaid [Blood Seal].mkv', u'/anime/Lupin III/Season 00/From Russia With Love.mkv', u'/anime/Lupin III/Season 00/Plot of the Fuma Clan.mkv', u'/anime/Lupin III/Season 00/Goodbye Lady Liberty.mkv', u'/anime/Lupin III/Season 00/The Secret of Twilight Gemini.mkv', u'/anime/Lupin III/Season 00/Memories of the Flame - Honou no Kioku.mkv', u'/anime/Lupin III/Season 00/Castle of Calgiostro.mkv', u'/anime/Lupin III/Season 00/Secret Files.avi', u'/anime/Lupin III/Season 00/Greatest Capers.mkv', u'/anime/Lupin III/Season 00/Lupin III Pilot Film 2 - Cinematic [480p][neo1024][C9B6C04F].mkv', u'/anime/Lupin III/Season 00/Seven Days Rhapsody.mkv']
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] 71863: Creating episode from: /anime/Lupin III/Season 02/S02E101.mkv
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] 71863: Creating episode object from /anime/Lupin III/Season 02/S02E101.mkv
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] Using cached parse result for /anime/Lupin III/Season 02/S02E101.mkv
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] 71863: /anime/Lupin III/Season 02/S02E101.mkv parsed to Lupin III S02E101
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] 71863: Setter sets location to /anime/Lupin III/Season 02/S02E101.mkv
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] Lupin III: Not changing current status 'Downloaded' or quality 'SDTV' based on file: /anime/Lupin III/Season 02/S02E101.mkv
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] Transaction with 1 queries executed
2018-08-21 22:50:35 DEBUG    SHOWQUEUE-REFRESH :: [f5973b2] Scene numbering enabled series Lupin III is anime
2018-08-21 22:50:35 ERROR    SHOWQUEUE-REFRESH :: [f5973b2] 71863: Error while refreshing show Lupin III. Error: 'NoneType' object has no attribute 'lower'
Traceback (most recent call last):
  File "/app/medusa/medusa/show_queue.py", line 686, in run
    self.show.refresh_dir()
  File "/app/medusa/medusa/tv/series.py", line 1718, in refresh_dir
    self.load_episodes_from_dir()
  File "/app/medusa/medusa/tv/series.py", line 1006, in load_episodes_from_dir
    parse_result = NameParser(series=self, try_indexers=True).parse(ep_file_name)
  File "/app/medusa/medusa/name_parser/parser.py", line 366, in parse
    result = self._parse_string(name)
  File "/app/medusa/medusa/name_parser/parser.py", line 297, in _parse_string
    new_episode_numbers, new_season_numbers, new_absolute_numbers = self._parse_anime(result)
  File "/app/medusa/medusa/name_parser/parser.py", line 189, in _parse_anime
    scene_season = scene_exceptions.get_scene_exceptions_by_name(result.series_name)[0][1]
  File "/app/medusa/medusa/scene_exceptions.py", line 173, in get_scene_exceptions_by_name
    if show_name.lower() in show_names:
AttributeError: 'NoneType' object has no attribute 'lower'

# Fixed code
def get_scene_exceptions_by_name(show_name):
    """Look for a series_id, season and indexer for a given series scene exception."""
    # TODO: Rewrite to use exceptions_cache since there is no need to hit db.
    # TODO: Make the query more linient. For example. `Jojo's Bizarre Adventure Stardust Crusaders` will not match
    # while `Jojo's Bizarre Adventure - Stardust Crusaders` is available.
    if show_name is None:
        logger.debug("Scene exception lookup failed because no show name was provided")
        return [(None, None, None)]

    # Try the obvious case first
    cache_db_con = db.DBConnection("cache.db")
    scene_exceptions = cache_db_con.select(
        b"SELECT indexer, indexer_id, season "
        b"FROM scene_exceptions "
        b"WHERE show_name = ? ORDER BY season ASC",
        [show_name],
    )
    if scene_exceptions:
        # FIXME: Need to add additional layer indexer.
        return [
            (
                int(exception[b"indexer_id"]),
                int(exception[b"season"]),
                int(exception[b"indexer"]),
            )
            for exception in scene_exceptions
        ]

    result = []
    scene_exceptions = cache_db_con.select(
        b"SELECT show_name, indexer, indexer_id, season FROM scene_exceptions"
    )

    for exception in scene_exceptions:
        indexer = int(exception[b"indexer"])
        indexer_id = int(exception[b"indexer_id"])
        season = int(exception[b"season"])
        exception_name = exception[b"show_name"]

        sanitized_name = helpers.sanitize_scene_name(exception_name)
        show_names = (
            exception_name.lower(),
            sanitized_name.lower().replace(".", " "),
        )

        if show_name.lower() in show_names:
            logger.debug(
                "Scene exception lookup got indexer ID {cur_indexer}, using that",
                cur_indexer=indexer_id,
            )
            result.append((indexer_id, season, indexer))

    return result or [(None, None, None)]