aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DEVELOPMENT.md2
-rw-r--r--docs/index.rst5
-rw-r--r--mastodon/Mastodon.py40
3 files changed, 43 insertions, 4 deletions
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
index 6d9e10d..5644dea 100644
--- a/DEVELOPMENT.md
+++ b/DEVELOPMENT.md
@@ -4,8 +4,6 @@ Here's some general stuff to keep in mind, and some work that needs to be done
4 use requests over urllib, et cetera. 4 use requests over urllib, et cetera.
5 5
6* Current TODOs (2.3 support): 6* Current TODOs (2.3 support):
7 * Add support for media updating
8 * Add support for focal points
9 * Add support for idempotency keys 7 * Add support for idempotency keys
10 * Document error handling better 8 * Document error handling better
11 9
diff --git a/docs/index.rst b/docs/index.rst
index 62f5842..4bcc70d 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -256,6 +256,8 @@ Toot dicts
256 'language': # The language of the toot, if specified by the server. 256 'language': # The language of the toot, if specified by the server.
257 'muted': # Boolean denoting whether the user has muted this status by 257 'muted': # Boolean denoting whether the user has muted this status by
258 # way of conversation muting 258 # way of conversation muting
259 'pinned': # Boolean denoting whether or not the status is currently pinned for the
260 # associated account.
259 } 261 }
260 262
261Mention dicts 263Mention dicts
@@ -662,6 +664,8 @@ interact with already posted statuses.
662.. automethod:: Mastodon.status_unfavourite 664.. automethod:: Mastodon.status_unfavourite
663.. automethod:: Mastodon.status_mute 665.. automethod:: Mastodon.status_mute
664.. automethod:: Mastodon.status_unmute 666.. automethod:: Mastodon.status_unmute
667.. automethod:: Mastodon.status_pin
668.. automethod:: Mastodon.status_unpin
665.. automethod:: Mastodon.status_delete 669.. automethod:: Mastodon.status_delete
666 670
667Writing data: Notifications 671Writing data: Notifications
@@ -714,6 +718,7 @@ to attach media to statuses.
714.. _media_post(): 718.. _media_post():
715 719
716.. automethod:: Mastodon.media_post 720.. automethod:: Mastodon.media_post
721.. automethod:: Mastodon.media_update
717 722
718Writing data: Reports 723Writing data: Reports
719--------------------- 724---------------------
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index e616aa3..b9e880d 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -111,7 +111,7 @@ class Mastodon:
111 __DICT_VERSION_MENTION = "1.0.0" 111 __DICT_VERSION_MENTION = "1.0.0"
112 __DICT_VERSION_MEDIA = "2.3.0" 112 __DICT_VERSION_MEDIA = "2.3.0"
113 __DICT_VERSION_ACCOUNT = "2.3.0" 113 __DICT_VERSION_ACCOUNT = "2.3.0"
114 __DICT_VERSION_STATUS = bigger_version(bigger_version(bigger_version(bigger_version("2.0.0", 114 __DICT_VERSION_STATUS = bigger_version(bigger_version(bigger_version(bigger_version("2.1.0",
115 __DICT_VERSION_MEDIA), __DICT_VERSION_ACCOUNT), __DICT_VERSION_APPLICATION), __DICT_VERSION_MENTION) 115 __DICT_VERSION_MEDIA), __DICT_VERSION_ACCOUNT), __DICT_VERSION_APPLICATION), __DICT_VERSION_MENTION)
116 __DICT_VERSION_INSTANCE = bigger_version("2.3.0", __DICT_VERSION_ACCOUNT) 116 __DICT_VERSION_INSTANCE = bigger_version("2.3.0", __DICT_VERSION_ACCOUNT)
117 __DICT_VERSION_HASHTAG = "1.0.0" 117 __DICT_VERSION_HASHTAG = "1.0.0"
@@ -761,7 +761,7 @@ class Mastodon:
761 @api_version("2.1.0", "2.1.0", __DICT_VERSION_LIST) 761 @api_version("2.1.0", "2.1.0", __DICT_VERSION_LIST)
762 def account_lists(self, id): 762 def account_lists(self, id):
763 """ 763 """
764 Get all of the logged in users lists which the specified user is 764 Get all of the logged-in users lists which the specified user is
765 a member of. 765 a member of.
766 766
767 Returns a list of `list dicts`_. 767 Returns a list of `list dicts`_.
@@ -1108,6 +1108,28 @@ class Mastodon:
1108 url = '/api/v1/statuses/{0}/unmute'.format(str(id)) 1108 url = '/api/v1/statuses/{0}/unmute'.format(str(id))
1109 return self.__api_request('POST', url) 1109 return self.__api_request('POST', url)
1110 1110
1111 @api_version("2.1.0", "2.1.0", __DICT_VERSION_STATUS)
1112 def status_pin(self, id):
1113 """
1114 Pin a status for the logged-in user.
1115
1116 Returns a `toot dict`_ with the now pinned status
1117 """
1118 id = self.__unpack_id(id)
1119 url = '/api/v1/statuses/{0}/pin'.format(str(id))
1120 return self.__api_request('POST', url)
1121
1122 @api_version("2.1.0", "2.1.0", __DICT_VERSION_STATUS)
1123 def status_unpin(self, id):
1124 """
1125 Unpin a pinned status for the logged-in user.
1126
1127 Returns a `toot dict`_ with the status that used to be pinned.
1128 """
1129 id = self.__unpack_id(id)
1130 url = '/api/v1/statuses/{0}/unpin'.format(str(id))
1131 return self.__api_request('POST', url)
1132
1111 ### 1133 ###
1112 # Writing data: Notifications 1134 # Writing data: Notifications
1113 ### 1135 ###
@@ -1402,7 +1424,21 @@ class Mastodon:
1402 return self.__api_request('POST', '/api/v1/media', 1424 return self.__api_request('POST', '/api/v1/media',
1403 files={'file': media_file_description}, 1425 files={'file': media_file_description},
1404 params={'description': description, 'focus': focus}) 1426 params={'description': description, 'focus': focus})
1427
1428 @api_version("2.3.0", "2.3.0", __DICT_VERSION_MEDIA)
1429 def media_update(self, id, description=None, focus=None):
1430 """
1431 Update the metadata of the media file with the given `id`. `description` and
1432 `focus` are as in `media_post()`_ .
1433 """
1434 id = self.__unpack_id(id)
1405 1435
1436 if focus != None:
1437 focus = str(focus[0]) + "," + str(focus[1])
1438
1439 params = self.__generate_params(locals(), ['id'])
1440 return self.__api_request('PUT', '/api/v1/media/{0}'.format(str(id)), params)
1441
1406 ### 1442 ###
1407 # Writing data: Domain blocks 1443 # Writing data: Domain blocks
1408 ### 1444 ###
Powered by cgit v1.2.3 (git 2.41.0)