import re


def parse_duration(duration):
    """
    Parses duration field from MyAnimeList.

    Arguments:
        duration: str
            Duration as written for an anime property on MyAnimeList.

    Returns:
        time: int
            Time to watch in minutes
    """
    time = 0
    for scale, unit in ((60, "hr"), (1, "min")):
        substring = re.search(r"(\d+) {unit}".format(unit=unit), duration)
        if substring:
            time += scale * int(substring.group(1))

    return time