def parse_quality(value: str) ->int:
    """Return quality selector parsed from user input value.

    @raises ValueError: If value is not a valid quality selector.
    """
    if value == 'min':
        return 0
    elif value == 'max':
        return -1
    try:
        return int(value)
    except ValueError:
        raise ValueError("Quality '{}' is not a valid value.".format(value))
