'Search for a show with a given name on all the indexers, in a specific language'

def run(self):

    results = []
    lang_id = self.valid_languages[self.lang]
    if (self.name and (not self.indexerid)):
        for _indexer in (srIndexerApi().indexers if (self.indexer == 0) else [int(self.indexer)]):
            lINDEXER_API_PARMS = srIndexerApi(_indexer).api_params.copy()
            lINDEXER_API_PARMS[u'language'] = (self.lang or sickrage.srCore.srConfig.INDEXER_DEFAULT_LANGUAGE)
            lINDEXER_API_PARMS[u'actors'] = False
            lINDEXER_API_PARMS[u'custom_ui'] = AllShowsUI
            t = srIndexerApi(_indexer).indexer(**lINDEXER_API_PARMS)
            try:
                apiData = t[str(self.name).encode()]
            except (indexer_shownotfound, indexer_showincomplete, indexer_error):
                sickrage.srCore.srLogger.warning((u'API    ::    Unable    to    find    show    with    id    ' + str(self.indexerid)))
                continue
            for curSeries in apiData:
                results.append({indexer_ids[_indexer]: int(curSeries[u'id']), u'name': curSeries[u'seriesname'], u'first_aired': curSeries[u'firstaired'], u'indexer': int(_indexer)})
        return _responds(RESULT_SUCCESS, {u'results': results, u'langid': lang_id})
    elif self.indexerid:
        for _indexer in (srIndexerApi().indexers if (self.indexer == 0) else [int(self.indexer)]):
            lINDEXER_API_PARMS = srIndexerApi(_indexer).api_params.copy()
            lINDEXER_API_PARMS[u'language'] = (self.lang or sickrage.srCore.srConfig.INDEXER_DEFAULT_LANGUAGE)
            lINDEXER_API_PARMS[u'actors'] = False
            t = srIndexerApi(_indexer).indexer(**lINDEXER_API_PARMS)
            try:
                myShow = t[int(self.indexerid)]
            except (indexer_shownotfound, indexer_showincomplete, indexer_error):
                sickrage.srCore.srLogger.warning((u'API    ::    Unable    to    find    show    with    id    ' + str(self.indexerid)))
                return _responds(RESULT_SUCCESS, {u'results': [], u'langid': lang_id})
            if (not myShow.data[u'seriesname']):
                sickrage.srCore.srLogger.debug(((u'API    ::    Found    show    with    indexerid:    ' + str(self.indexerid)) + u',    however    it    contained    no    show    name'))
                return _responds(RESULT_FAILURE, msg=u'Show    contains    no    name,    invalid    result')
            results = [{indexer_ids[_indexer]: int(myShow.data[u'id']), u'name': myShow.data[u'seriesname'], u'first_aired': myShow.data[u'firstaired'], u'indexer': int(_indexer)}]
            break
        return _responds(RESULT_SUCCESS, {u'results': results, u'langid': lang_id})
    else:
        return _responds(RESULT_FAILURE, msg=u'Either    a    unique    id    or    name    is    required!')
