def _create_directory(self, torrent_queue_id): """ Create a directory for content of files downloaded """ movie = Movie.find( Movie.torrent_queue_id == torrent_queue_id, async=False ).one() if movie is not None: return self.__mkdir(movie.name) tv_show = TVShow.find( TVShow.torrent_queue_id == torrent_queue_id, async=False ).one() if tv_show is not None: return self.__mkdir(tv_show.name) return None
def get_tvshows(self, **kwargs): """ Loads all entries for tv shows :param kwargs: Pass in argument for querying :return: defered return """ tv_shows = yield TVShow.find(**kwargs) tv_shows.order_by(Desc(TVShow.id)) data = list() for tv_show in tv_shows: if tv_show.torrent_queue.status == 'DELETED': continue data.append(tv_show.dict(json=True)) defer.returnValue(data)