Example #1
0
    def handle(self, *args, **options):
        for series in Series.objects.all():
            tvdb.create_or_update_series(series.tvdbid)

        last_update = LastUpdate.objects.get()
        last_update.datetime = datetime.now()
        last_update.save()
Example #2
0
    def test_remove_stale_episodes(self):
        series = Series.objects.create(tvdbid=152831)
        Episode.objects.create(series=series, season=8, episode=1)
        self.assertEqual(series.episodes.filter(season=8).exists(), True)

        with Replace('requests.get', self.get_series_all_7_seasons):
            tvdb.create_or_update_series(series.tvdbid)

        self.assertEqual(series.episodes.filter(season=8).exists(), False)
Example #3
0
    def test_update_series(self):
        with Replace('requests.get', self.get_series_all_6_seasons):
            tvdb.create_or_update_series(152831)
            created_series = Series.objects.get(tvdbid=152831)
            self.assertEqual(len(created_series.episodes_by_season()), 6)

        with Replace('requests.get', self.get_series_all_7_seasons):
            tvdb.create_or_update_series(152831)
            updated_series = Series.objects.get(tvdbid=152831)
            self.assertEqual(updated_series.name, 'Adventure Time')
            self.assertEqual(len(updated_series.episodes_by_season()), 7)
            self.assertEqual(created_series.id, updated_series.id)
            self.assertEqual(Series.objects.count(), 1)
Example #4
0
 def test_create_series(self):
     with Replace('requests.get', self.get_series_all_6_seasons):
         tvdb.create_or_update_series(152831)
         series = Series.objects.get(tvdbid=152831)
         self.assertEqual(series.name, 'Adventure Time')
         self.assertEqual(len(series.episodes_by_season()), 6)
Example #5
0
 def create_or_sync(tvdbid):
     try:
         return Series.objects.get(tvdbid=tvdbid)
     except Series.DoesNotExist:
         from thetvdb import tvdb
         return tvdb.create_or_update_series(tvdbid)