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_movies(self, **kwargs): """ Loads all entries for movies :param kwargs: Pass in argument for querying :return: defered return """ movies = yield Movie.find(**kwargs) movies.order_by(Desc(Movie.id)) data = list() for movie in movies: if movie.torrent_queue.status == 'DELETED': continue data.append(movie.dict(json=True)) defer.returnValue(data)