|
|
|
@ -117,8 +117,10 @@ class PreviewUrlResource(DirectServeResource): |
|
|
|
|
pattern = entry[attrib] |
|
|
|
|
value = getattr(url_tuple, attrib) |
|
|
|
|
logger.debug( |
|
|
|
|
("Matching attrib '%s' with value '%s' against" " pattern '%s'") |
|
|
|
|
% (attrib, value, pattern) |
|
|
|
|
"Matching attrib '%s' with value '%s' against" " pattern '%s'", |
|
|
|
|
attrib, |
|
|
|
|
value, |
|
|
|
|
pattern, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
if value is None: |
|
|
|
@ -186,7 +188,7 @@ class PreviewUrlResource(DirectServeResource): |
|
|
|
|
|
|
|
|
|
media_info = yield self._download_url(url, user) |
|
|
|
|
|
|
|
|
|
logger.debug("got media_info of '%s'" % media_info) |
|
|
|
|
logger.debug("got media_info of '%s'", media_info) |
|
|
|
|
|
|
|
|
|
if _is_media(media_info["media_type"]): |
|
|
|
|
file_id = media_info["filesystem_id"] |
|
|
|
@ -254,7 +256,7 @@ class PreviewUrlResource(DirectServeResource): |
|
|
|
|
og["og:image:width"] = dims["width"] |
|
|
|
|
og["og:image:height"] = dims["height"] |
|
|
|
|
else: |
|
|
|
|
logger.warn("Couldn't get dims for %s" % og["og:image"]) |
|
|
|
|
logger.warn("Couldn't get dims for %s", og["og:image"]) |
|
|
|
|
|
|
|
|
|
og["og:image"] = "mxc://%s/%s" % ( |
|
|
|
|
self.server_name, |
|
|
|
@ -268,7 +270,7 @@ class PreviewUrlResource(DirectServeResource): |
|
|
|
|
logger.warn("Failed to find any OG data in %s", url) |
|
|
|
|
og = {} |
|
|
|
|
|
|
|
|
|
logger.debug("Calculated OG for %s as %s" % (url, og)) |
|
|
|
|
logger.debug("Calculated OG for %s as %s", url, og) |
|
|
|
|
|
|
|
|
|
jsonog = json.dumps(og) |
|
|
|
|
|
|
|
|
@ -297,7 +299,7 @@ class PreviewUrlResource(DirectServeResource): |
|
|
|
|
|
|
|
|
|
with self.media_storage.store_into_file(file_info) as (f, fname, finish): |
|
|
|
|
try: |
|
|
|
|
logger.debug("Trying to get url '%s'" % url) |
|
|
|
|
logger.debug("Trying to get url '%s'", url) |
|
|
|
|
length, headers, uri, code = yield self.client.get_file( |
|
|
|
|
url, output_stream=f, max_size=self.max_spider_size |
|
|
|
|
) |
|
|
|
|