diff --git a/screenless/bureau/publications/publications.py b/screenless/bureau/publications/publications.py index 917cbac..e4433ee 100644 --- a/screenless/bureau/publications/publications.py +++ b/screenless/bureau/publications/publications.py @@ -6,6 +6,7 @@ import json import os import random import string +import tempfile import threading import urllib.request, urllib.parse, urllib.error @@ -318,6 +319,8 @@ class Publications(Bureau): def fetch_og(entry): """ get OpenGraph data for entry + and download image + TODO: add microdata support here to get author """ og_data = self._get_ogdata(entry.link) if hasattr(entry, "media_thumbnail"): @@ -327,6 +330,14 @@ class Publications(Bureau): else: entry.img = " " + if entry.imge != " ": + fileext = "." + entry.img.rsplit(".",1)[1] + filename = tempfile.mktemp(fileext) + print("fetching", entry.img, filename) + urllib.request.urlretrieve(entry.img, filename) + entry.img = "file://" + filename + + thread = threading.Thread(target=fetch_og, args=(entry,)) threads.append(thread) thread.start()