Performs replacement of series name.

    Allow specified replacements of series names in cases where default
    filenames match the wrong series, e.g. missing year gives wrong answer,
    or vice versa. This helps the TVDB query get the right match.

def _replace_series_name(seriesname, replacements):
    """Performs replacement of series name.

    Allow specified replacements of series names in cases where default
    filenames match the wrong series, e.g. missing year gives wrong answer,
    or vice versa. This helps the TVDB query get the right match.
    """
    for pat, replacement in six.iteritems(replacements):
        if re.match(pat, seriesname, re.IGNORECASE | re.UNICODE):
            return replacement
    return seriesname