aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-23 23:48:38 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-23 23:48:38 +0200
commitf6d12aa5b1cc1dffcff31d1af1b0b58d9ecd4c1e (patch)
tree56359f4573e38702e9927eff97fe821f0e6b9ea0
parent268c2fea2880ef2124a494f07b2be9e172ad7fa9 (diff)
downloadmastodon.py-f6d12aa5b1cc1dffcff31d1af1b0b58d9ecd4c1e.tar.gz
Fix search issue, add pathlib path support
-rw-r--r--CHANGELOG.rst2
-rw-r--r--mastodon/Mastodon.py13
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
15v1.6.3 17v1.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:
57except ImportError: 57except ImportError:
58 magic = None 58 magic = None
59 59
60try:
61 from pathlib import PurePath
62except:
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')
Powered by cgit v1.2.3 (git 2.41.0)