# Buggy code
def collectEpisodesFromSearchThread(show):
    """
    Collects all episodes from from the searchQueueScheduler and looks for episodes that are in status queued or searching.
    If episodes are found in FORCED_SEARCH_HISTORY, these are set to status finished.
    """
    episodes = []

    # Queued Searches
    searchstatus = SEARCH_STATUS_QUEUED
    for search_thread in sickbeard.searchQueueScheduler.action.get_all_ep_from_queue(
        show
    ):
        episodes += getEpisodes(search_thread, searchstatus)

    # Running Searches
    searchstatus = SEARCH_STATUS_SEARCHING
    if sickbeard.searchQueueScheduler.action.is_manualsearch_in_progress():
        search_thread = sickbeard.searchQueueScheduler.action.currentItem

        if search_thread.success:
            searchstatus = SEARCH_STATUS_FINISHED

        episodes += getEpisodes(search_thread, searchstatus)

    # Finished Searches
    searchstatus = SEARCH_STATUS_FINISHED
    for search_thread in sickbeard.search_queue.FORCED_SEARCH_HISTORY:
        if show and not str(search_thread.show.indexerid) == show:
            continue

        if isinstance(
            search_thread, sickbeard.search_queue.ForcedSearchQueueItem
        ) and not [
            x
            for x in episodes
            if x["episodeindexid"] == search_thread.segment.indexerid
        ]:
            episodes += getEpisodes(search_thread, searchstatus)
        else:
            # These are only Failed Downloads/Retry search thread items.. lets loop through the segment/episodes
            if not [
                i
                for i, j in zip(search_thread.segment, episodes)
                if i.indexerid == j["episodeindexid"]
            ]:
                episodes += getEpisodes(search_thread, searchstatus)

    return episodes


# Traceback (TypeError)
Thread-15 :: [80123f9] Failed doing webui callback: Traceback (most recent call last):
File "/home/osmc/SickRage/sickbeard/webserve.py", line 322, in async_call
result = function(**kwargs)
File "/home/osmc/SickRage/sickbeard/webserve.py", line 1485, in manualSearchCheckCache
episodesInSearch = collectEpisodesFromSearchThread(show)
File "/home/osmc/SickRage/sickbeard/manual_search.py", line 148, in collectEpisodesFromSearchThread
if not [i for i, j in zip(search_thread.segment, episodes) if i.indexerid == j['episodeindexid']]:
TypeError: zip argument #1 must support iteration

# Fixed code
def collectEpisodesFromSearchThread(show):
    """
    Collects all episodes from from the searchQueueScheduler and looks for episodes that are in status queued or searching.
    If episodes are found in FORCED_SEARCH_HISTORY, these are set to status finished.
    """
    episodes = []

    # Queued Searches
    searchstatus = SEARCH_STATUS_QUEUED
    for search_thread in sickbeard.searchQueueScheduler.action.get_all_ep_from_queue(
        show
    ):
        episodes += getEpisodes(search_thread, searchstatus)

    # Running Searches
    searchstatus = SEARCH_STATUS_SEARCHING
    if sickbeard.searchQueueScheduler.action.is_manualsearch_in_progress():
        search_thread = sickbeard.searchQueueScheduler.action.currentItem

        if search_thread.success:
            searchstatus = SEARCH_STATUS_FINISHED

        episodes += getEpisodes(search_thread, searchstatus)

    # Finished Searches
    searchstatus = SEARCH_STATUS_FINISHED
    for search_thread in sickbeard.search_queue.FORCED_SEARCH_HISTORY:
        if show and not str(search_thread.show.indexerid) == show:
            continue

        if isinstance(search_thread, sickbeard.search_queue.ForcedSearchQueueItem):
            if not [
                x
                for x in episodes
                if x["episodeindexid"] == search_thread.segment.indexerid
            ]:
                episodes += getEpisodes(search_thread, searchstatus)
        else:
            # These are only Failed Downloads/Retry search thread items.. lets loop through the segment/episodes
            if not [
                i
                for i, j in zip(search_thread.segment, episodes)
                if i.indexerid == j["episodeindexid"]
            ]:
                episodes += getEpisodes(search_thread, searchstatus)

    return episodes