import re


def detect_resolution(path):
    """Attempt to detect the domain information from the path.

    Args:
        path (str): Path.
    
    Returns:
        int : Domain
    
    Raises:
        ValueError : When the domain can't be detected.
    """
    matches = re.findall(r'[0-9]*km', path)

    num_matches = len(matches)
    if num_matches != 1:
        raise ValueError(f'Unable to detect domain in {path}. There should be exactly 1 domain segment in the path, found {num_matches}')
    
    return int(matches[0].replace('km', ''))