def sort(self): self._root.controller.clearEpisodeListModel.emit() caption, eql = EPISODE_LIST_FILTERS[self._filter] if eql is None: self._filtered = self._objects else: eql = query.EQL(eql) match = lambda episode: eql.match(episode._episode) self._filtered = filter(match, self._objects) def to_dict(episode): return { 'episode_id': episode._episode.id, 'episode': episode, 'title': episode.qtitle, 'podcast': episode.qpodcast, 'cover_url': episode.qpodcast.qcoverart, 'filetype': episode.qfiletype, 'duration': episode.qduration, 'downloading': episode.qdownloading, 'position': episode.qposition, 'progress': episode.qprogress, 'downloaded': episode.qdownloaded, 'isnew': episode.qnew, 'archive': episode.qarchive, } self._processed = map(to_dict, self._filtered[:EPISODE_LIST_LIMIT]) self.reset() self._root.controller.setEpisodeListModel.emit()
def filter_and_load_episodes(): caption, eql = EPISODE_LIST_FILTERS[self._filter] if eql is None: self._filtered = self._objects else: eql = query.EQL(eql) match = lambda episode: eql.match(episode._episode) self._filtered = filter(match, self._objects) def to_dict(episode): return { 'episode_id': episode._episode.id, 'episode': episode, 'title': episode.qtitle, 'podcast': episode.qpodcast, 'cover_url': episode.qpodcast.qcoverart, 'filetype': episode.qfiletype, 'duration': episode.qduration, 'downloading': episode.qdownloading, 'position': episode.qposition, 'progress': episode.qprogress, 'downloaded': episode.qdownloaded, 'isnew': episode.qnew, 'archive': episode.qarchive, } processed = map(to_dict, self._filtered[:EPISODE_LIST_LIMIT]) self._root.setEpisodeListModel.emit(processed) # Keep a reference here to avoid crashes self._processed = processed
def sort(self): caption, eql = EPISODE_LIST_FILTERS[self._filter] if eql is None: self._filtered = self._objects else: eql = query.EQL(eql) match = lambda episode: eql.match(episode._episode) self._filtered = filter(match, self._objects) self.reset()
def _do_filter(self, items, is_tuple=False): """Filter a list of items via the attached SQL If is_tuple is True, the list of items should be a list of (podcast, episode) tuples, otherwise it should just be a list of episode objects. """ if self.eql is not None: eql = query.EQL(self.eql) if is_tuple: match = lambda (podcast, episode): eql.match(episode) else: match = eql.match items = filter(match, items) return items