Improve image fetching in ThreadABC

This commit is contained in:
Mads Marquart
2020-01-14 18:47:14 +01:00
parent 55182e21b6
commit 117433da8a
4 changed files with 45 additions and 34 deletions

View File

@@ -1,4 +1,3 @@
import itertools
import fbchat
session = fbchat.Session.login("<email>", "<password>")
@@ -62,7 +61,9 @@ print("thread's name: {}".format(thread.name))
# Here should be an example of `getUnread`
# Print image url for 20 last images from thread.
images = thread.fetch_images()
for image in itertools.islice(image, 20):
print(image.large_preview_url)
# Print image url for up to 20 last images from thread.
images = list(thread.fetch_images(limit=20))
for image in images:
if isinstance(image, fbchat.ImageAttachment):
url = c.fetch_image_url(image.id)
print(url)