'Runs the timeframe logic to determine if we should wait for a better quality.
Saves current best to backlog if timeframe has not expired.
:returns: True - if we should keep the quality (or qualities) restriction
False - if the quality restriction should be released, due to timeframe expiring'

def process_timeframe(self, task, config, episode, entries):

    if (u'timeframe' not in config):
        return True
    best = entries[0]
    log.debug(u'timeframe:    %s', config[u'timeframe'])
    timeframe = parse_timedelta(config[u'timeframe'])
    if config.get(u'quality'):
        req = qualities.Requirements(config[u'quality'])
        seen_times = [rls.first_seen for rls in episode.releases if req.allows(rls.quality)]
    else:
        seen_times = [rls.first_seen for rls in episode.releases]
    first_seen = (min(seen_times) if seen_times else datetime.now())
    expires = (first_seen + timeframe)
    log.debug(u'timeframe:    %s,    first_seen:    %s,    expires:    %s', timeframe, first_seen, expires)
    stop = (normalize_series_name(task.options.stop_waiting) == episode.series._name_normalized)
    if ((expires <= datetime.now()) or stop):
        log.info(u'Timeframe    expired,    releasing    quality    restriction.')
        return False
    else:
        diff = (expires - datetime.now())
        (hours, remainder) = divmod(diff.seconds, 3600)
        hours += (diff.days * 24)
        (minutes, _) = divmod(remainder, 60)
        log.info(u'`%s`:    timeframe    waiting    for    %02dh:%02dmin.    Currently    best    is    `%s`.', episode.series.name, hours, minutes, best[u'title'])
        if self.backlog:
            self.backlog.instance.add_backlog(task, best, session=object_session(episode))
        return True
