diff options
-rw-r--r-- | CHANGELOG.rst | 2 | ||||
-rw-r--r-- | mastodon/Mastodon.py | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 39c5e66..a928586 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst | |||
@@ -10,6 +10,8 @@ v1.7.0 | |||
10 | * Add missing streaming events | 10 | * Add missing streaming events |
11 | * Add missing parameters on directory endpoint (thanks heharkon) | 11 | * Add missing parameters on directory endpoint (thanks heharkon) |
12 | * This isn't somehing I changed but thank you a / triggerofsol for answering Many questions I had about specifics of what the API does that are not documented | 12 | * This isn't somehing I changed but thank you a / triggerofsol for answering Many questions I had about specifics of what the API does that are not documented |
13 | * Fixed search ignoring `exclude_unreviewed` (Thanks acidghost) | ||
14 | * Add support for using pathlib paths when loading media files (Thanks reagle) | ||
13 | * TECHNICALLY BREAKING CHANGE, but I would be quite surprised if this actually breaks anyone: Date parsing will now, when the date string is empty, return Jan. 1st, 1970 instead. This is to work around what I assume is a bug in Pleroma. | 15 | * TECHNICALLY BREAKING CHANGE, but I would be quite surprised if this actually breaks anyone: Date parsing will now, when the date string is empty, return Jan. 1st, 1970 instead. This is to work around what I assume is a bug in Pleroma. |
14 | 16 | ||
15 | v1.6.3 | 17 | v1.6.3 |
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 99133cf..7e9f06f 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -57,6 +57,12 @@ try: | |||
57 | except ImportError: | 57 | except ImportError: |
58 | magic = None | 58 | magic = None |
59 | 59 | ||
60 | try: | ||
61 | from pathlib import PurePath | ||
62 | except: | ||
63 | class PurePath: | ||
64 | pass | ||
65 | |||
60 | ### | 66 | ### |
61 | # Version check functions, including decorator and parser | 67 | # Version check functions, including decorator and parser |
62 | ### | 68 | ### |
@@ -1450,7 +1456,8 @@ class Mastodon: | |||
1450 | `offset`, `min_id` and `max_id` can be used to paginate. | 1456 | `offset`, `min_id` and `max_id` can be used to paginate. |
1451 | 1457 | ||
1452 | `exclude_unreviewed` can be used to restrict search results for hashtags to only | 1458 | `exclude_unreviewed` can be used to restrict search results for hashtags to only |
1453 | those that have been reviewed by moderators. It is on by default. | 1459 | those that have been reviewed by moderators. It is on by default. When using the |
1460 | v1 search API (pre 2.4.1), it is ignored. | ||
1454 | 1461 | ||
1455 | Will use search_v1 (no tag dicts in return values) on Mastodon versions before | 1462 | Will use search_v1 (no tag dicts in return values) on Mastodon versions before |
1456 | 2.4.1), search_v2 otherwise. Parameters other than resolve are only available | 1463 | 2.4.1), search_v2 otherwise. Parameters other than resolve are only available |
@@ -1461,7 +1468,7 @@ class Mastodon: | |||
1461 | Returns a `search result dict`_, with tags as `hashtag dicts`_. | 1468 | Returns a `search result dict`_, with tags as `hashtag dicts`_. |
1462 | """ | 1469 | """ |
1463 | if self.verify_minimum_version("2.4.1", cached=True): | 1470 | if self.verify_minimum_version("2.4.1", cached=True): |
1464 | return self.search_v2(q, resolve=resolve, result_type=result_type, account_id=account_id, offset=offset, min_id=min_id, max_id=max_id) | 1471 | return self.search_v2(q, resolve=resolve, result_type=result_type, account_id=account_id, offset=offset, min_id=min_id, max_id=max_id, exclude_unreviewed=exclude_unreviewed) |
1465 | else: | 1472 | else: |
1466 | self.__ensure_search_params_acceptable( | 1473 | self.__ensure_search_params_acceptable( |
1467 | account_id, offset, min_id, max_id) | 1474 | account_id, offset, min_id, max_id) |
@@ -4101,6 +4108,8 @@ class Mastodon: | |||
4101 | return mime_type | 4108 | return mime_type |
4102 | 4109 | ||
4103 | def __load_media_file(self, media_file, mime_type=None, file_name=None): | 4110 | def __load_media_file(self, media_file, mime_type=None, file_name=None): |
4111 | if isinstance(media_file, PurePath): | ||
4112 | media_file = str(media_file) | ||
4104 | if isinstance(media_file, str) and os.path.isfile(media_file): | 4113 | if isinstance(media_file, str) and os.path.isfile(media_file): |
4105 | mime_type = self.__guess_type(media_file) | 4114 | mime_type = self.__guess_type(media_file) |
4106 | media_file = open(media_file, 'rb') | 4115 | media_file = open(media_file, 'rb') |