def duration(text, loader_context):
    cformat = loader_context.get('duration')
    #Value completion in special cases
    text_int = None
    try:
        text_int = int(text)
    except ValueError:
        pass
    if(cformat == '%H:%M'):
        if text_int:
            text += ':00'
    if(cformat == '%M'):
        text = _breakdown_time_unit_overlap(text, 60)
        cformat = '%H:%M'
    if(cformat == '%M:%S'):
        if text_int:
            text += ':00'
        text = _breakdown_time_unit_overlap(text, 60)
        cformat = '%H:%M:%S'
    if(cformat == '%S'):
        if text_int:
            if text_int >= 3600:
                hours_str = str(text_int // 3600) + ':'
                secs_under_hour_str = str(text_int % 3600)
                text = hours_str + _breakdown_time_unit_overlap(secs_under_hour_str, 60)
                cformat = '%H:%M:%S'
            else:
                text = _breakdown_time_unit_overlap(text, 60)
                cformat = '%M:%S'
    try:
        duration = datetime.datetime.strptime(text, cformat)
    except ValueError:
        loader_context.get('spider').log('Duration could not be parsed ("{t}", Format string: "{f}")!'.format(t=text, f=cformat), logging.ERROR)
        return None
    return duration.strftime('%H:%M:%S')
dataset/ETHPy150Open holgerd77/django-dynamic-scraper/dynamic_scraper/utils/processors.py/duration/original