def duration_to_seconds(duration_str):
    """
    Acceptable formats are: "MM:SS", "HH:MM" and "HH:MM:SS".
    """
    values = duration_str.split(':')
    
    if len(values) == 1:
        raise Exception('Invalid value supplied: %s', duration_str)
    
    seconds = 0
    
    for i, val in enumerate(reversed(values)):        
        val = int(val) * pow(60, i)
        seconds = seconds + val
        
    return seconds
dataset/ETHPy150Open pascalw/Airplayer/airplayer/utils.py/duration_to_seconds/original