'Get the list of episodes for one or all seasons of a show'

def run(self):

    showObj = findCertainShow(sickrage.srCore.SHOWLIST, int(self.indexerid))
    if (not showObj):
        return _responds(RESULT_FAILURE, msg=u'Show    not    found')
    if (self.season is None):
        seasons = {}
        for row in [x[u'doc'] for x in sickrage.srCore.mainDB.db.get_many(u'tv_episodes', self.indexerid, with_doc=True)]:
            (status, quality) = Quality.splitCompositeStatus(int(row[u'status']))
            row[u'status'] = _get_status_Strings(status)
            row[u'quality'] = get_quality_string(quality)
            if (tryInt(row[u'airdate'], 1) > 693595):
                dtEpisodeAirs = srdatetime.srDateTime.convert_to_setting(tz_updater.parse_date_time(row[u'airdate'], showObj.airs, showObj.network))
                row[u'airdate'] = srdatetime.srDateTime.srfdate(dtEpisodeAirs, d_preset=dateFormat)
            else:
                row[u'airdate'] = u'Never'
            curSeason = int(row[u'season'])
            curEpisode = int(row[u'episode'])
            del row[u'season']
            del row[u'episode']
            if (not (curSeason in seasons)):
                seasons[curSeason] = {}
            seasons[curSeason][curEpisode] = row
    else:
        dbData = [x[u'doc'] for x in sickrage.srCore.mainDB.db.get_many(u'tv_episodes', self.indexerid, with_doc=True) if (x[u'season'] == self.season)]
        if (len(dbData) is 0):
            return _responds(RESULT_FAILURE, msg=u'Season    not    found')
        seasons = {}
        for row in dbData:
            curEpisode = int(row[u'episode'])
            del row[u'episode']
            (status, quality) = Quality.splitCompositeStatus(int(row[u'status']))
            row[u'status'] = _get_status_Strings(status)
            row[u'quality'] = get_quality_string(quality)
            if (tryInt(row[u'airdate'], 1) > 693595):
                dtEpisodeAirs = srdatetime.srDateTime.convert_to_setting(tz_updater.parse_date_time(row[u'airdate'], showObj.airs, showObj.network))
                row[u'airdate'] = srdatetime.srDateTime.srfdate(dtEpisodeAirs, d_preset=dateFormat)
            else:
                row[u'airdate'] = u'Never'
            if (not (curEpisode in seasons)):
                seasons[curEpisode] = {}
            seasons[curEpisode] = row
    return _responds(RESULT_SUCCESS, seasons)
