# Buggy code
def rules():
    """Return all custom rules to be applied to guessit default api.

    IMPORTANT! The order is important.
    Certain rules needs to be executed first, and others should be executed at the end.
    DO NOT define priority or dependency in each rule, it can become a mess. Better to just define the correct order
    in this method.

    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    return Rebulk().rules(
        FixTvChaosUkWorkaround,
        FixAnimeReleaseGroup,
        SpanishNewpctReleaseName,
        FixInvalidTitleOrAlternativeTitle,
        FixSeasonAndEpisodeConflicts,
        FixWrongTitleDueToFilmTitle,
        FixSeasonNotDetected,
        FixWrongSeasonRangeDetectionDueToEpisode,
        FixSeasonRangeDetection,
        FixEpisodeRangeDetection,
        FixEpisodeRangeWithSeasonDetection,
        FixWrongTitlesWithCompleteKeyword,
        AnimeWithSeasonAbsoluteEpisodeNumbers,
        AnimeAbsoluteEpisodeNumbers,
        AbsoluteEpisodeNumbers,
        PartsAsEpisodeNumbers,
        ExpectedTitlePostProcessor,
        CreateAliasWithAlternativeTitles,
        CreateAliasWithCountryOrYear,
        EnhanceReleaseGroupDetection,
        ReleaseGroupPostProcessor,
        FixMultipleTitles,
    )


# Traceback (AttributeError)
FINDSUBTITLES :: [42fd472] Traceback (most recent call last):
File "/home/osmc/SickRage/sickbeard/subtitles.py", line 326, in download_best_subs
for s in subtitles_list], key=operator.itemgetter(1), reverse=True)
File "/home/osmc/SickRage/lib/subliminal/score.py", line 88, in compute_score
matches = subtitle.get_matches(video)
File "/home/osmc/SickRage/lib/subliminal/providers/legendastv.py", line 147, in get_matches
matches |= guess_matches(video, guessit(self.archive.name, {'type': self.type}))
File "/home/osmc/SickRage/lib/subliminal/subtitle.py", line 233, in guess_matches
if video.format and 'format' in guess and guess['format'].lower() == video.format.lower():
AttributeError: 'list' object has no attribute 'lower'
Traceback (most recent call last):
File "/home/osmc/SickRage/sickbeard/subtitles.py", line 326, in download_best_subs
for s in subtitles_list], key=operator.itemgetter(1), reverse=True)
File "/home/osmc/SickRage/lib/subliminal/score.py", line 88, in compute_score
matches = subtitle.get_matches(video)
File "/home/osmc/SickRage/lib/subliminal/providers/legendastv.py", line 147, in get_matches
matches |= guess_matches(video, guessit(self.archive.name, {'type': self.type}))
File "/home/osmc/SickRage/lib/subliminal/subtitle.py", line 233, in guess_matches
if video.format and 'format' in guess and guess['format'].lower() == video.format.lower():
AttributeError: 'list' object has no attribute 'lower'

# Fixed code
def rules():
    """Return all custom rules to be applied to guessit default api.

    IMPORTANT! The order is important.
    Certain rules needs to be executed first, and others should be executed at the end.
    DO NOT define priority or dependency in each rule, it can become a mess. Better to just define the correct order
    in this method.

    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    return Rebulk().rules(
        FixTvChaosUkWorkaround,
        FixAnimeReleaseGroup,
        SpanishNewpctReleaseName,
        FixInvalidTitleOrAlternativeTitle,
        FixSeasonAndEpisodeConflicts,
        FixWrongTitleDueToFilmTitle,
        FixSeasonNotDetected,
        FixWrongSeasonRangeDetectionDueToEpisode,
        FixSeasonRangeDetection,
        FixEpisodeRangeDetection,
        FixEpisodeRangeWithSeasonDetection,
        FixWrongTitlesWithCompleteKeyword,
        AnimeWithSeasonAbsoluteEpisodeNumbers,
        AnimeAbsoluteEpisodeNumbers,
        AbsoluteEpisodeNumbers,
        PartsAsEpisodeNumbers,
        ExpectedTitlePostProcessor,
        CreateAliasWithAlternativeTitles,
        CreateAliasWithCountryOrYear,
        EnhanceReleaseGroupDetection,
        ReleaseGroupPostProcessor,
        FixMultipleTitles,
        FixMultipleFormats,
    )