import datetime as datetime_class # забыл добавить в ответ
duration = datetime.strptime(duration, "%H:%M:%S")
x_duration =datetime_class.timedelta(hours=duration.hour, minutes=duration.minute, seconds=duration.second).total_seconds()
duration = timedelta(seconds = x_duration)