aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2018-05-06 18:00:07 +0200
committerLorenz Diener <[email protected]>2018-05-06 18:00:07 +0200
commitc0a0c8f517611d0026d6d37fbe7c57eae1f1a3bb (patch)
treeb3322b75eda6436892196fcfc6dd5fbb670516e2
parentd633df28f756a14a19a4ff1a4f6a4b8600d1b3b8 (diff)
downloadmastodon.py-c0a0c8f517611d0026d6d37fbe7c57eae1f1a3bb.tar.gz
Add focal points
-rw-r--r--mastodon/Mastodon.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index beccf92..ffd4497 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -440,7 +440,7 @@ class Mastodon:
440 return self.timeline('local', max_id=max_id, since_id=since_id, 440 return self.timeline('local', max_id=max_id, since_id=since_id,
441 limit=limit) 441 limit=limit)
442 442
443 @api_version("1.0.0", "2.0.0") 443 @api_version("1.0.0", "2.3.0")
444 def timeline_public(self, max_id=None, since_id=None, limit=None, only_media=False): 444 def timeline_public(self, max_id=None, since_id=None, limit=None, only_media=False):
445 """ 445 """
446 Fetches the public / visible-network timeline, not including replies. 446 Fetches the public / visible-network timeline, not including replies.
@@ -450,7 +450,7 @@ class Mastodon:
450 return self.timeline('public', max_id=max_id, since_id=since_id, 450 return self.timeline('public', max_id=max_id, since_id=since_id,
451 limit=limit) 451 limit=limit)
452 452
453 @api_version("1.0.0", "2.0.0") 453 @api_version("1.0.0", "2.3.0")
454 def timeline_hashtag(self, hashtag, local=False, max_id=None, since_id=None, limit=None, only_media=False): 454 def timeline_hashtag(self, hashtag, local=False, max_id=None, since_id=None, limit=None, only_media=False):
455 """ 455 """
456 Fetch a timeline of toots with a given hashtag. The hashtag parameter 456 Fetch a timeline of toots with a given hashtag. The hashtag parameter
@@ -691,7 +691,7 @@ class Mastodon:
691 return self.__api_request('GET', '/api/v1/accounts/relationships', 691 return self.__api_request('GET', '/api/v1/accounts/relationships',
692 params) 692 params)
693 693
694 @api_version("1.0.0", "2.1.0") 694 @api_version("1.0.0", "2.3.0")
695 def account_search(self, q, limit=None, following=False): 695 def account_search(self, q, limit=None, following=False):
696 """ 696 """
697 Fetch matching accounts. Will lookup an account remotely if the search term is 697 Fetch matching accounts. Will lookup an account remotely if the search term is
@@ -1308,13 +1308,16 @@ class Mastodon:
1308 ### 1308 ###
1309 # Writing data: Media 1309 # Writing data: Media
1310 ### 1310 ###
1311 @api_version("1.0.0", "2.0.0") 1311 @api_version("1.0.0", "2.3.0")
1312 def media_post(self, media_file, mime_type=None, description=None): 1312 def media_post(self, media_file, mime_type=None, description=None, focus=None):
1313 """ 1313 """
1314 Post an image. `media_file` can either be image data or 1314 Post an image. `media_file` can either be image data or
1315 a file name. If image data is passed directly, the mime 1315 a file name. If image data is passed directly, the mime
1316 type has to be specified manually, otherwise, it is 1316 type has to be specified manually, otherwise, it is
1317 determined from the file name. 1317 determined from the file name. `focus` should be a tuple
1318 of floats between -1 and 1, giving the x and y coordinates
1319 of the images focus point for cropping (with the origin being the images
1320 center).
1318 1321
1319 Throws a `MastodonIllegalArgumentError` if the mime type of the 1322 Throws a `MastodonIllegalArgumentError` if the mime type of the
1320 passed data or file can not be determined properly. 1323 passed data or file can not be determined properly.
@@ -1335,10 +1338,13 @@ class Mastodon:
1335 file_name = "mastodonpyupload_" + str(time.time()) + "_" + str(random_suffix) + mimetypes.guess_extension( 1338 file_name = "mastodonpyupload_" + str(time.time()) + "_" + str(random_suffix) + mimetypes.guess_extension(
1336 mime_type) 1339 mime_type)
1337 1340
1341 if focus != None:
1342 focus = str(focus[0]) + "," + str(focus[1])
1343
1338 media_file_description = (file_name, media_file, mime_type) 1344 media_file_description = (file_name, media_file, mime_type)
1339 return self.__api_request('POST', '/api/v1/media', 1345 return self.__api_request('POST', '/api/v1/media',
1340 files={'file': media_file_description}, 1346 files={'file': media_file_description},
1341 params={'description': description}) 1347 params={'description': description, 'focus': focus})
1342 1348
1343 ### 1349 ###
1344 # Writing data: Domain blocks 1350 # Writing data: Domain blocks
Powered by cgit v1.2.3 (git 2.41.0)