'Decides whether we should look for next ep/season based on whether we found/accepted any episodes.'

def on_search_complete(self, entry, task=None, identified_by=None, **kwargs):

    with Session() as session:
        series = session.query(Series).filter((Series.name == entry[u'series_name'])).first()
        latest = get_latest_release(series)
        db_release = session.query(EpisodeRelease).join(EpisodeRelease.episode).join(Episode.series).filter((Series.name == entry[u'series_name'])).filter((Episode.season == entry[u'series_season'])).filter((Episode.number == entry[u'series_episode'])).first()
        if entry.accepted:
            log.debug((u'%s    %s    was    accepted,    rerunning    to    look    for    next    ep.' % (entry[u'series_name'], entry[u'series_id'])))
            self.rerun_entries.append(self.search_entry(series, entry[u'series_season'], (entry[u'series_episode'] + 1), task))
            task.max_reruns += 1
            task.rerun(plugin=u'next_series_episodes', reason=u'Look    for    next    episode')
        elif db_release:
            return
        elif (latest and (identified_by == u'ep') and ((entry[u'series_season'] == latest.season) and (entry[u'series_episode'] == (latest.number + 1)))):
            self.rerun_entries.append(self.search_entry(series, (latest.season + 1), 1, task))
            log.debug((u'%s    %s    not    found,    rerunning    to    look    for    next    season' % (entry[u'series_name'], entry[u'series_id'])))
            task.rerun(plugin=u'next_series_episodes', reason=u'Look    for    next    season')
