diff --git a/djangofeeds/feedutil.py b/djangofeeds/feedutil.py index e33225e..e9d4dce 100644 --- a/djangofeeds/feedutil.py +++ b/djangofeeds/feedutil.py @@ -1,3 +1,4 @@ +import hashlib import time import urllib import urllib2 @@ -7,8 +8,7 @@ from base64 import b64encode from datetime import datetime, timedelta -from django.utils.text import truncate_html_words -from django.utils.hashcompat import md5_constructor +from django.utils.text import Truncator from djangofeeds import conf from djangofeeds.optimization import PostContentOptimizer @@ -27,7 +27,7 @@ def format_date(t): def md5sum(text): """Return the md5sum of a text string.""" - return md5_constructor(text).hexdigest() + return hashlib.md5(text).hexdigest() def safe_encode(value): @@ -171,7 +171,8 @@ def build_img(img_dict): img = "" content = img + content try: - content = truncate_html_words(content, conf.DEFAULT_ENTRY_WORD_LIMIT) + truncator = Truncator(text=content) + content =truncator.words(num=conf.DEFAULT_ENTRY_WORD_LIMIT, html=True) except UnicodeDecodeError: content = "" diff --git a/djangofeeds/models.py b/djangofeeds/models.py index cff322c..3f0f384 100644 --- a/djangofeeds/models.py +++ b/djangofeeds/models.py @@ -6,7 +6,7 @@ from django.db import models from django.db.models import signals from django.utils.translation import ugettext_lazy as _ -from django.utils.hashcompat import md5_constructor +import hashlib from djangofeeds import conf from djangofeeds.utils import naturaldate @@ -337,7 +337,7 @@ class Meta: def auto_guid(self): """Automatically generate a new guid from the metadata available.""" - return md5_constructor("|".join(( + return hashlib.md5("|".join(( self.title, self.link, self.author))).hexdigest() def __unicode__(self):