regluit/core/management/commands/despam_descriptions.py

18 lines
792 B
Python

from django.core.management.base import BaseCommand
from regluit.core import models, bookloader
class Command(BaseCommand):
help = "check description db for free ebook spam"
def handle(self, **options):
spam_strings=["1stWorldLibrary.ORG", "GeneralBooksClub.com", "million-books.com", "AkashaPublishing.Com"]
for spam_string in spam_strings:
qs=models.Work.objects.filter(description__icontains=spam_string)
print "Number of Works with %s in description: %s" % (spam_string, qs.count())
for work in qs:
work.description = bookloader.despam_description(work.description)
print "updating work %s" % work
bookloader.add_openlibrary(work, hard_refresh = True)