def test_tv_show_with_when_before_air_date(self): tv_show = TVShow() tv_show.name = u'The Walking Dead' tv_show.season_number = 4 tv_show.episode_number = 10 tv_show.air_date = datetime.strptime('2089-08-17', '%Y-%m-%d') tv_show.episode_name = u'TWD' tv_show.rating = 9 tv_show.create() queue = TorrentQueue.load_pending_queue(async=False) self.assertEquals(0, len(queue)) tv_show = TVShow.load(id=1) self.assertEquals(1, len(tv_show))
def test_tv_show_no_when(self): tv_show = TVShow() tv_show.name = u'The Walking Dead' tv_show.season_number = 4 tv_show.episode_number = 10 tv_show.air_date = datetime.strptime('1989-08-17', '%Y-%m-%d') tv_show.episode_name = u'TWD' tv_show.rating = 9 tv_show.create() queue = TorrentQueue.load() self.assertEquals(1, len(queue)) tv_show = TVShow.load(id=1) self.assertEquals(1, len(tv_show))
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)