from re import match


def from_osu_time_notation(time_string):
    """
    Transform from the osu! time notation to a time in milliseconds
:param time_string: String to convert from
:return: Time in milliseconds. Raises ValueError on failure.
    """

    try:
        time_match = match("(\d{2,}):(\d\d):(\d\d\d)", time_string)
    except:
        raise ValueError("Invalid parameter")

    if time_match is not None:
        mins = int(time_match.group(1))
        secs = int(time_match.group(2))
        millisecs = int(time_match.group(3))
        return mins * 60000 + secs * 1000 + millisecs
    else:
        raise ValueError("Not a valid osu! time notation string!")