diff options
author | Gwyn Ciesla <[email protected]> | 2019-06-12 13:40:53 -0500 |
---|---|---|
committer | Gwyn Ciesla <[email protected]> | 2019-06-12 13:40:53 -0500 |
commit | 4a2a723a1ebeba28c45c83a9454987984870ed26 (patch) | |
tree | 62db5379f5e8dd65820f4a299378778cebd16a2a /mastodon | |
parent | 1a120f03939d36bc14bda0931819db0ab45908af (diff) | |
download | mastodon.py-4a2a723a1ebeba28c45c83a9454987984870ed26.tar.gz |
Patch to make blurhash optional.
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index ef71078..9b08bcf 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -36,7 +36,12 @@ except: | |||
36 | 36 | ||
37 | import base64 | 37 | import base64 |
38 | import json | 38 | import json |
39 | import blurhash | 39 | |
40 | IMPL_HAS_BLURHASH = True | ||
41 | try: | ||
42 | import blurhash | ||
43 | except: | ||
44 | IMPL_HAS_BLURHASH = False | ||
40 | 45 | ||
41 | try: | 46 | try: |
42 | from urllib.parse import urlparse | 47 | from urllib.parse import urlparse |
@@ -2385,6 +2390,9 @@ class Mastodon: | |||
2385 | For further info and tips for advanced usage, refer to the documentation for the | 2390 | For further info and tips for advanced usage, refer to the documentation for the |
2386 | blurhash module: https://github.com/halcy/blurhash-python | 2391 | blurhash module: https://github.com/halcy/blurhash-python |
2387 | """ | 2392 | """ |
2393 | if not IMPL_HAS_BLURHASH: | ||
2394 | raise NotImplementedError('To use the blurhash functions, please install the blurhash python module.') | ||
2395 | |||
2388 | # Figure out what size to decode to | 2396 | # Figure out what size to decode to |
2389 | decode_components_x, decode_components_y = blurhash.components(media_dict["blurhash"]) | 2397 | decode_components_x, decode_components_y = blurhash.components(media_dict["blurhash"]) |
2390 | if size_per_component == False: | 2398 | if size_per_component == False: |