human
Complete this python program:
def mark_expired(session):
assistant
#Here is the Python program you requested.

    """Marks series and episodes that have expired since we cached them
    """
    last_check = persist.get(u'last_check')
    if (not last_check):
        persist[u'last_check'] = datetime.utcnow()
        return
    if ((datetime.utcnow() - last_check) <= timedelta(hours=2)):
        return
    new_last_check = datetime.utcnow()
    try:
        last_check_epoch = (int((last_check - datetime(1970, 1, 1)).total_seconds()) - 60)
        log.debug(u'Getting    updates    from    thetvdb    (%s)', last_check_epoch)
        updates = TVDBRequest().get(u'updated/query', fromTime=last_check_epoch)
    except requests.RequestException as e:
        log.error(u'Could    not    get    update    information    from    tvdb:    %s', e)
        return
    def chunked(seq):
        u'Helper    to    divide    our    expired    lists    into    sizes    sqlite    can    handle    in    a    query.    (<1000)'
        for i in range(0, len(seq), 900):
            (yield seq[i:(i + 900)])
    expired_series = ([series[u'id'] for series in updates] if updates else [])
    for chunk in chunked(expired_series):
        series_updated = session.query(TVDBSeries).filter(TVDBSeries.id.in_(chunk)).update({u'expired': True}, u'fetch')
        episodes_updated = session.query(TVDBEpisode).filter(TVDBEpisode.series_id.in_(chunk)).update({u'expired': True}, u'fetch')
        log.debug(u'%s    series    and    %s    episodes    marked    as    expired', series_updated, episodes_updated)
    persist[u'last_check'] = new_last_check