import re


def scale_times_to_generate(times_to_generate: int, time_frame: str) -> int:
    """Adjusts the number of times to generate the prices based on a time frame.

    Parameters
    ----------
    times_to_generate : int
        The number of time to generate prices.
    time_frame : str
        The time frame for generating.
        (e.g. 1h, 1min, 1w, 1d)

    Returns
    -------
    int
        The adjusted number of times to generate.

    Raises
    ------
    ValueError
        Raised if the `time_frame` provided does not match the correct format.
    """

    if 'MIN' in time_frame.upper():
        times_to_generate *= int(re.findall(r'\d+', time_frame)[0])
    elif 'H' in time_frame.upper():
        times_to_generate *= int(re.findall(r'\d+', time_frame)[0]) * 60
    elif 'D' in time_frame.upper():
        times_to_generate *= int(re.findall(r'\d+', time_frame)[0]) * 60 * 24
    elif 'W' in time_frame.upper():
        times_to_generate *= int(re.findall(r'\d+', time_frame)[0]) * 60 * 24 * 7
    elif 'M' in time_frame.upper():
        times_to_generate *= int(re.findall(r'\d+', time_frame)[0]) * 60 * 24 * 7 * 30
    else:
        raise ValueError('Timeframe must be either in minutes (min), hours (H), days (D), weeks (W), or months (M)')

    return times_to_generate