human
Complete this python program:
def _best_song_match(songs, title, duration, titleweight, durationweight):
assistant
#Here is the Python program you requested.

    """Select best matching song based on title, length.
    Score from 0 to 1 where 1 is best. titleweight and durationweight
    parameters added to enable function usage when duration can\t be guessed
    """
    seqmatch = difflib.SequenceMatcher
    def variance(a, b):
        '    Return    difference    ratio.    '
        return (float(abs((a - b))) / max(a, b))
    candidates = []
    ignore = 'music    video    lyrics    new    lyrics    video    audio'.split()
    extra = 'official    original    vevo'.split()
    for song in songs:
        (dur, tit) = (int(song.length), song.title)
        util.dbg('Title:    %s,    Duration:    %s', tit, dur)
        for word in extra:
            if ((word in tit.lower()) and (word not in title.lower())):
                pattern = re.compile(word, re.I)
                tit = pattern.sub('', tit)
        for word in ignore:
            if ((word in tit.lower()) and (word not in title.lower())):
                pattern = re.compile(word, re.I)
                tit = pattern.sub('', tit)
        replacechars = re.compile('[\\]\\[\\)\\(\\-]')
        tit = replacechars.sub('    ', tit)
        multiple_spaces = re.compile('(\\s)(\\s*)')
        tit = multiple_spaces.sub('\\1', tit)
        title_score = seqmatch(None, title.lower(), tit.lower()).ratio()
        duration_score = (1 - variance(duration, dur))
        util.dbg('Title    score:    %s,    Duration    score:    %s', title_score, duration_score)
        score = ((duration_score * durationweight) + (title_score * titleweight))
        candidates.append((score, song))
    (best_score, best_song) = max(candidates, key=(lambda x: x[0]))
    percent_score = int((100 * best_score))
    return (best_song, percent_score)