Exemplo n.º 1
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("bulk_import takes one argument: " "%i argument(s) given" % len(args))
        try:
            feed = models.Feed.objects.get(pk=args[0])
        except models.Feed.DoesNotExist:
            raise CommandError("Feed with pk %s does not exist" % args[0])

        bulk_feed = bulk_import(feed.feed_url)
        try:
            verbose = int(options["verbosity"]) > 1
        except ValueError:
            verbose = False

        stats = {"total": 0, "imported": 0, "skipped": 0}
        try:
            for i in feed._update_items_generator(verbose=verbose, parsed_feed=bulk_feed, clear_rejected=True):
                if not models.Feed.objects.filter(pk=feed.pk).count():
                    # someone deleted the feed, quit
                    break
                stats["total"] += 1
                if i["video"] is not None:
                    stats["imported"] += 1
                else:
                    stats["skipped"] += 1
        finally:
            feed.status = models.FEED_STATUS_ACTIVE
            feed.save()
        print simplejson.dumps(stats),
Exemplo n.º 2
0
    def use_old_bulk_import(self, parsed_feed, feed):
        bulk_feed = bulk_import(feed_url=None, parsed_feed=parsed_feed)

        stats = {
            'total': 0,
            'imported': 0,
            'skipped': 0
            }
        try:
            for i in feed._update_items_generator(verbose=self.verbose,
                                                  parsed_feed=bulk_feed,
                                                  clear_rejected=True,
                                                  actually_save_thumbnails=True):
                if not models.Feed.objects.filter(pk=feed.pk).count():
                    # someone deleted the feed, quit
                    break
                stats['total'] += 1
                if i['video'] is not None:
                    stats['imported'] += 1
                else:
                    stats['skipped'] += 1
        finally:
            feed.status = models.FEED_STATUS_ACTIVE
            feed.save()
        print simplejson.dumps(stats),
Exemplo n.º 3
0
    def use_old_bulk_import(self, parsed_feed, feed):
        bulk_feed = bulk_import(feed_url=None, parsed_feed=parsed_feed)

        stats = {'total': 0, 'imported': 0, 'skipped': 0}
        try:
            for i in feed._update_items_generator(
                    verbose=self.verbose,
                    parsed_feed=bulk_feed,
                    clear_rejected=True,
                    actually_save_thumbnails=True):
                if not models.Feed.objects.filter(pk=feed.pk).count():
                    # someone deleted the feed, quit
                    break
                stats['total'] += 1
                if i['video'] is not None:
                    stats['imported'] += 1
                else:
                    stats['skipped'] += 1
        finally:
            feed.status = models.FEED_STATUS_ACTIVE
            feed.save()
        print simplejson.dumps(stats),