diff options
author | Lorenz Diener <[email protected]> | 2019-06-22 15:29:46 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2019-06-22 15:29:46 +0200 |
commit | 50a60320ffa4febc88ff0271e103ab7c514f3dd7 (patch) | |
tree | b88d577ab068f0f9aa217da85fcf3a628814b706 | |
parent | 052b7f7cd319bd39f5c9db1b0322e9e4445a123e (diff) | |
parent | 4a2a723a1ebeba28c45c83a9454987984870ed26 (diff) | |
download | mastodon.py-50a60320ffa4febc88ff0271e103ab7c514f3dd7.tar.gz |
Merge pull request #176 from limburgher/master
Patch to make blurhash optional.
-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: |