'Restore the episodes of a failed download to their original state'

@staticmethod
def revertFailedEpisode(epObj):

    dbData = [x[u'doc'] for x in sickrage.srCore.failedDB.db.all(u'history', with_doc=True) if ((x[u'doc'][u'showid'] == epObj.show.indexerid) and (x[u'doc'][u'season'] == epObj.season))]
    history_eps = dict([(res[u'episode'], res) for res in dbData])
    try:
        sickrage.srCore.srLogger.info((u'Reverting    episode    (%s,    %s):    %s' % (epObj.season, epObj.episode, epObj.name)))
        with epObj.lock:
            if (epObj.episode in history_eps):
                sickrage.srCore.srLogger.info(u'Found    in    history')
                epObj.status = history_eps[epObj.episode][u'old_status']
            else:
                sickrage.srCore.srLogger.warning(u'WARNING:    Episode    not    found    in    history.    Setting    it    back    to    WANTED')
                epObj.status = WANTED
                epObj.saveToDB()
    except EpisodeNotFoundException as e:
        sickrage.srCore.srLogger.warning(u'Unable    to    create    episode,    please    set    its    status    manually:    {}'.format(e.message))
