mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
If requests.raw won't work, sut fudge it with a StringIO for now.
This commit is contained in:
parent
0db41bc853
commit
61fac02304
2 changed files with 6 additions and 5 deletions
|
@ -33,6 +33,7 @@ from utils.feed_functions import relative_timesince
|
|||
from utils.story_functions import truncate_chars, strip_tags, linkify, image_size
|
||||
from utils.scrubber import SelectiveScriptScrubber
|
||||
from utils import s3_utils
|
||||
from StringIO import StringIO
|
||||
|
||||
RECOMMENDATIONS_LIMIT = 5
|
||||
IGNORE_IMAGE_SOURCES = [
|
||||
|
@ -1884,7 +1885,8 @@ class MSharedStory(mongo.Document):
|
|||
if any(ignore in image_source for ignore in IGNORE_IMAGE_SOURCES):
|
||||
continue
|
||||
req = requests.get(image_source, headers=headers, stream=True)
|
||||
_, width, height = image_size(req.content)
|
||||
datastream = StringIO(req.content[:30])
|
||||
_, width, height = image_size(datastream)
|
||||
if width <= 16 or height <= 16:
|
||||
continue
|
||||
image_sizes.append({'src': image_source, 'size': (width, height)})
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.utils.html import strip_tags as strip_tags_django
|
|||
from django.conf import settings
|
||||
from utils.tornado_escape import linkify as linkify_tornado
|
||||
from utils.tornado_escape import xhtml_unescape as xhtml_unescape_tornado
|
||||
# from vendor import reseekfile
|
||||
from vendor import reseekfile
|
||||
|
||||
COMMENTS_RE = re.compile('\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>')
|
||||
|
||||
|
@ -239,9 +239,8 @@ def truncate_chars(value, max_length):
|
|||
return truncd_val + "..."
|
||||
|
||||
def image_size(datastream):
|
||||
# datastream = reseekfile.ReseekFile(datastream)
|
||||
# data = str(datastream.read(30))
|
||||
data = datastream[:30]
|
||||
datastream = reseekfile.ReseekFile(datastream)
|
||||
data = str(datastream.read(30))
|
||||
size = len(data)
|
||||
height = -1
|
||||
width = -1
|
||||
|
|
Loading…
Add table
Reference in a new issue