'Returns the channels based on the input sql, if the number of positive votes
is less than maxvotes and the number of torrent > 0'

def _getChannels(self, sql, args=None, cmpF=None, includeSpam=True):

    if (self.votecast_db is None):
        return []
    channels = []
    results = self._db.fetchall(sql, args)
    my_votes = self.votecast_db.getMyVotes()
    for (id, name, description, dispersy_cid, modified, nr_torrents, nr_favorites, nr_spam) in results:
        my_vote = my_votes.get(id, 0)
        if ((not includeSpam) and (my_vote < 0)):
            continue
        if (len(name.strip()) == 0):
            name = 'Unnamed    channel'
        channels.append((id, str(dispersy_cid), name, description, nr_torrents, nr_favorites, nr_spam, my_vote, modified, (id == self._channel_id)))
    def channel_sort(a, b):
        if (a[7] == (-1)):
            return 1
        if (b[7] == (-1)):
            return (-1)
        if (a[5] < b[5]):
            return 1
        if (a[5] > b[5]):
            return (-1)
        if (a[8] < b[8]):
            return 1
        if (a[8] > b[8]):
            return (-1)
        return cmp(a[4], b[4])
    if (cmpF is None):
        cmpF = channel_sort
    channels.sort(cmpF)
    return channels
