diff options
author | Lorenz Diener <[email protected]> | 2018-05-07 00:53:13 +0200 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2018-05-07 00:53:13 +0200 |
commit | 8d5fe70c7e52656b2f89d0acfb1aed23bf583041 (patch) | |
tree | a210ef1ba6255d8f64fdd623de41f0e6931c4508 /mastodon | |
parent | c0a0c8f517611d0026d6d37fbe7c57eae1f1a3bb (diff) | |
download | mastodon.py-8d5fe70c7e52656b2f89d0acfb1aed23bf583041.tar.gz |
Fix some bugs, update tests
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 200 |
1 files changed, 126 insertions, 74 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index ffd4497..b186344 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -38,7 +38,20 @@ def parse_version_string(version_string): | |||
38 | ] | 38 | ] |
39 | return version_parts | 39 | return version_parts |
40 | 40 | ||
41 | def api_version(created_ver, last_changed_ver): | 41 | def bigger_version(version_string_a, version_string_b): |
42 | """Returns the bigger version of two version strings.""" | ||
43 | major_a, minor_a, patch_a = parse_version_string(version_string_a) | ||
44 | major_b, minor_b, patch_b = parse_version_string(version_string_b) | ||
45 | |||
46 | if major_a > major_b: | ||
47 | return version_string_a | ||
48 | elif major_a == major_b and minor_a > minor_b: | ||
49 | return version_string_a | ||
50 | elif major_a == major_b and minor_a == minor_b and patch_a > patch_b: | ||
51 | return version_string_a | ||
52 | return version_string_b | ||
53 | |||
54 | def api_version(created_ver, last_changed_ver, return_value_ver): | ||
42 | """Version check decorator. Currently only checks Bigger Than.""" | 55 | """Version check decorator. Currently only checks Bigger Than.""" |
43 | def api_min_version_decorator(function): | 56 | def api_min_version_decorator(function): |
44 | def wrapper(function, self, *args, **kwargs): | 57 | def wrapper(function, self, *args, **kwargs): |
@@ -46,7 +59,7 @@ def api_version(created_ver, last_changed_ver): | |||
46 | if self.version_check_mode == "created": | 59 | if self.version_check_mode == "created": |
47 | version = created_ver | 60 | version = created_ver |
48 | else: | 61 | else: |
49 | version = last_changed_ver | 62 | version = bigger_version(last_changed_ver, return_value_ver) |
50 | major, minor, patch = parse_version_string(version) | 63 | major, minor, patch = parse_version_string(version) |
51 | if major > self.mastodon_major: | 64 | if major > self.mastodon_major: |
52 | raise MastodonVersionError("Version check failed (Need version " + version + ")") | 65 | raise MastodonVersionError("Version check failed (Need version " + version + ")") |
@@ -93,6 +106,26 @@ class Mastodon: | |||
93 | __DEFAULT_STREAM_RECONNECT_WAIT_SEC = 5 | 106 | __DEFAULT_STREAM_RECONNECT_WAIT_SEC = 5 |
94 | __SUPPORTED_MASTODON_VERSION = "2.3.0" | 107 | __SUPPORTED_MASTODON_VERSION = "2.3.0" |
95 | 108 | ||
109 | # Dict versions | ||
110 | __DICT_VERSION_APPLICATION = "1.0.0" | ||
111 | __DICT_VERSION_MENTION = "1.0.0" | ||
112 | __DICT_VERSION_MEDIA = "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", | ||
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) | ||
117 | __DICT_VERSION_HASHTAG = "1.0.0" | ||
118 | __DICT_VERSION_EMOJI = "2.1.0" | ||
119 | __DICT_VERSION_RELATIONSHIP = "1.4.0" | ||
120 | __DICT_VERSION_NOTIFICATION = bigger_version(bigger_version("1.0.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS) | ||
121 | __DICT_VERSION_CONTEXT = bigger_version("1.0.0", __DICT_VERSION_STATUS) | ||
122 | __DICT_VERSION_LIST = "2.1.0" | ||
123 | __DICT_VERSION_CARD = "2.0.0" | ||
124 | __DICT_VERSION_SEARCHRESULT = bigger_version(bigger_version(bigger_version("1.0.0", | ||
125 | __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS), __DICT_VERSION_HASHTAG) | ||
126 | __DICT_VERSION_ACTIVITY = "2.1.2" | ||
127 | __DICT_VERSION_REPORT = "1.1.0" | ||
128 | |||
96 | ### | 129 | ### |
97 | # Registering apps | 130 | # Registering apps |
98 | ### | 131 | ### |
@@ -349,7 +382,7 @@ class Mastodon: | |||
349 | ### | 382 | ### |
350 | # Reading data: Instances | 383 | # Reading data: Instances |
351 | ### | 384 | ### |
352 | @api_version("1.1.0", "2.3.0") | 385 | @api_version("1.1.0", "2.3.0", __DICT_VERSION_INSTANCE) |
353 | def instance(self): | 386 | def instance(self): |
354 | """ | 387 | """ |
355 | Retrieve basic information about the instance, including the URI and administrative contact email. | 388 | Retrieve basic information about the instance, including the URI and administrative contact email. |
@@ -366,7 +399,7 @@ class Mastodon: | |||
366 | """ | 399 | """ |
367 | return self.__api_request('GET', '/api/v1/instance/') | 400 | return self.__api_request('GET', '/api/v1/instance/') |
368 | 401 | ||
369 | @api_version("2.1.2", "2.1.2") | 402 | @api_version("2.1.2", "2.1.2", __DICT_VERSION_ACTIVITY) |
370 | def instance_activity(self): | 403 | def instance_activity(self): |
371 | """ | 404 | """ |
372 | Retrieve activity stats about the instance. May be disabled by the instance administrator - throws | 405 | Retrieve activity stats about the instance. May be disabled by the instance administrator - throws |
@@ -378,7 +411,7 @@ class Mastodon: | |||
378 | """ | 411 | """ |
379 | return self.__api_request('GET', '/api/v1/instance/activity') | 412 | return self.__api_request('GET', '/api/v1/instance/activity') |
380 | 413 | ||
381 | @api_version("2.1.2", "2.1.2") | 414 | @api_version("2.1.2", "2.1.2", "2.1.2") |
382 | def instance_peers(self): | 415 | def instance_peers(self): |
383 | """ | 416 | """ |
384 | Retrieve the instances that this instance knows about. May be disabled by the instance administrator - throws | 417 | Retrieve the instances that this instance knows about. May be disabled by the instance administrator - throws |
@@ -391,7 +424,7 @@ class Mastodon: | |||
391 | ### | 424 | ### |
392 | # Reading data: Timelines | 425 | # Reading data: Timelines |
393 | ## | 426 | ## |
394 | @api_version("1.0.0", "2.0.0") | 427 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
395 | def timeline(self, timeline="home", max_id=None, since_id=None, limit=None): | 428 | def timeline(self, timeline="home", max_id=None, since_id=None, limit=None): |
396 | """ | 429 | """ |
397 | Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', | 430 | Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', |
@@ -420,7 +453,7 @@ class Mastodon: | |||
420 | url = '/api/v1/timelines/{0}'.format(timeline) | 453 | url = '/api/v1/timelines/{0}'.format(timeline) |
421 | return self.__api_request('GET', url, params) | 454 | return self.__api_request('GET', url, params) |
422 | 455 | ||
423 | @api_version("1.0.0", "2.0.0") | 456 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
424 | def timeline_home(self, max_id=None, since_id=None, limit=None): | 457 | def timeline_home(self, max_id=None, since_id=None, limit=None): |
425 | """ | 458 | """ |
426 | Fetch the logged-in users home timeline (i.e. followed users and self). | 459 | Fetch the logged-in users home timeline (i.e. followed users and self). |
@@ -430,7 +463,7 @@ class Mastodon: | |||
430 | return self.timeline('home', max_id=max_id, since_id=since_id, | 463 | return self.timeline('home', max_id=max_id, since_id=since_id, |
431 | limit=limit) | 464 | limit=limit) |
432 | 465 | ||
433 | @api_version("1.0.0", "2.0.0") | 466 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
434 | def timeline_local(self, max_id=None, since_id=None, limit=None): | 467 | def timeline_local(self, max_id=None, since_id=None, limit=None): |
435 | """ | 468 | """ |
436 | Fetches the local / instance-wide timeline, not including replies. | 469 | Fetches the local / instance-wide timeline, not including replies. |
@@ -440,24 +473,40 @@ class Mastodon: | |||
440 | return self.timeline('local', max_id=max_id, since_id=since_id, | 473 | return self.timeline('local', max_id=max_id, since_id=since_id, |
441 | limit=limit) | 474 | limit=limit) |
442 | 475 | ||
443 | @api_version("1.0.0", "2.3.0") | 476 | @api_version("1.0.0", "2.3.0", __DICT_VERSION_STATUS) |
444 | def timeline_public(self, max_id=None, since_id=None, limit=None, only_media=False): | 477 | def timeline_public(self, max_id=None, since_id=None, limit=None, only_media=False): |
445 | """ | 478 | """ |
446 | Fetches the public / visible-network timeline, not including replies. | 479 | Fetches the public / visible-network timeline, not including replies. |
447 | 480 | ||
481 | Set `only_media` to True to retrieve only statuses with media attachments. | ||
482 | |||
448 | Returns a list of `toot dicts`_. | 483 | Returns a list of `toot dicts`_. |
449 | """ | 484 | """ |
450 | return self.timeline('public', max_id=max_id, since_id=since_id, | 485 | if max_id != None: |
451 | limit=limit) | 486 | max_id = self.__unpack_id(max_id) |
487 | |||
488 | if since_id != None: | ||
489 | since_id = self.__unpack_id(since_id) | ||
490 | |||
491 | params_initial = locals() | ||
492 | |||
493 | if only_media == False: | ||
494 | del params_initial['only_media'] | ||
495 | |||
496 | url = '/api/v1/timelines/public' | ||
497 | params = self.__generate_params(params_initial) | ||
498 | |||
499 | return self.__api_request('GET', url, params) | ||
452 | 500 | ||
453 | @api_version("1.0.0", "2.3.0") | 501 | @api_version("1.0.0", "2.3.0", __DICT_VERSION_STATUS) |
454 | def timeline_hashtag(self, hashtag, local=False, max_id=None, since_id=None, limit=None, only_media=False): | 502 | def timeline_hashtag(self, hashtag, local=False, max_id=None, since_id=None, limit=None, only_media=False): |
455 | """ | 503 | """ |
456 | Fetch a timeline of toots with a given hashtag. The hashtag parameter | 504 | Fetch a timeline of toots with a given hashtag. The hashtag parameter |
457 | should not contain the leading #. | 505 | should not contain the leading #. |
458 | 506 | ||
459 | Set `local` to True to retrieve only instance-local tagged posts. | 507 | Set `local` to True to retrieve only instance-local tagged posts. |
460 | 508 | Set `only_media` to True to retrieve only statuses with media attachments. | |
509 | |||
461 | Returns a list of `toot dicts`_. | 510 | Returns a list of `toot dicts`_. |
462 | """ | 511 | """ |
463 | if hashtag.startswith("#"): | 512 | if hashtag.startswith("#"): |
@@ -474,12 +523,15 @@ class Mastodon: | |||
474 | if local == False: | 523 | if local == False: |
475 | del params_initial['local'] | 524 | del params_initial['local'] |
476 | 525 | ||
526 | if only_media == False: | ||
527 | del params_initial['only_media'] | ||
528 | |||
477 | url = '/api/v1/timelines/tag/{0}'.format(hashtag) | 529 | url = '/api/v1/timelines/tag/{0}'.format(hashtag) |
478 | params = self.__generate_params(params_initial, ['hashtag']) | 530 | params = self.__generate_params(params_initial, ['hashtag']) |
479 | 531 | ||
480 | return self.__api_request('GET', url, params) | 532 | return self.__api_request('GET', url, params) |
481 | 533 | ||
482 | @api_version("2.1.0", "2.1.0") | 534 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_STATUS) |
483 | def timeline_list(self, id, max_id=None, since_id=None, limit=None): | 535 | def timeline_list(self, id, max_id=None, since_id=None, limit=None): |
484 | """ | 536 | """ |
485 | Fetches a timeline containing all the toots by users in a given list. | 537 | Fetches a timeline containing all the toots by users in a given list. |
@@ -493,7 +545,7 @@ class Mastodon: | |||
493 | ### | 545 | ### |
494 | # Reading data: Statuses | 546 | # Reading data: Statuses |
495 | ### | 547 | ### |
496 | @api_version("1.0.0", "2.0.0") | 548 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
497 | def status(self, id): | 549 | def status(self, id): |
498 | """ | 550 | """ |
499 | Fetch information about a single toot. | 551 | Fetch information about a single toot. |
@@ -506,7 +558,7 @@ class Mastodon: | |||
506 | url = '/api/v1/statuses/{0}'.format(str(id)) | 558 | url = '/api/v1/statuses/{0}'.format(str(id)) |
507 | return self.__api_request('GET', url) | 559 | return self.__api_request('GET', url) |
508 | 560 | ||
509 | @api_version("1.0.0", "1.0.0") | 561 | @api_version("1.0.0", "1.0.0", __DICT_VERSION_CARD) |
510 | def status_card(self, id): | 562 | def status_card(self, id): |
511 | """ | 563 | """ |
512 | Fetch a card associated with a status. A card describes an object (such as an | 564 | Fetch a card associated with a status. A card describes an object (such as an |
@@ -520,7 +572,7 @@ class Mastodon: | |||
520 | url = '/api/v1/statuses/{0}/card'.format(str(id)) | 572 | url = '/api/v1/statuses/{0}/card'.format(str(id)) |
521 | return self.__api_request('GET', url) | 573 | return self.__api_request('GET', url) |
522 | 574 | ||
523 | @api_version("1.0.0", "1.0.0") | 575 | @api_version("1.0.0", "1.0.0", __DICT_VERSION_CONTEXT) |
524 | def status_context(self, id): | 576 | def status_context(self, id): |
525 | """ | 577 | """ |
526 | Fetch information about ancestors and descendants of a toot. | 578 | Fetch information about ancestors and descendants of a toot. |
@@ -533,7 +585,7 @@ class Mastodon: | |||
533 | url = '/api/v1/statuses/{0}/context'.format(str(id)) | 585 | url = '/api/v1/statuses/{0}/context'.format(str(id)) |
534 | return self.__api_request('GET', url) | 586 | return self.__api_request('GET', url) |
535 | 587 | ||
536 | @api_version("1.0.0", "2.1.0") | 588 | @api_version("1.0.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
537 | def status_reblogged_by(self, id): | 589 | def status_reblogged_by(self, id): |
538 | """ | 590 | """ |
539 | Fetch a list of users that have reblogged a status. | 591 | Fetch a list of users that have reblogged a status. |
@@ -546,7 +598,7 @@ class Mastodon: | |||
546 | url = '/api/v1/statuses/{0}/reblogged_by'.format(str(id)) | 598 | url = '/api/v1/statuses/{0}/reblogged_by'.format(str(id)) |
547 | return self.__api_request('GET', url) | 599 | return self.__api_request('GET', url) |
548 | 600 | ||
549 | @api_version("1.0.0", "2.1.0") | 601 | @api_version("1.0.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
550 | def status_favourited_by(self, id): | 602 | def status_favourited_by(self, id): |
551 | """ | 603 | """ |
552 | Fetch a list of users that have favourited a status. | 604 | Fetch a list of users that have favourited a status. |
@@ -562,7 +614,7 @@ class Mastodon: | |||
562 | ### | 614 | ### |
563 | # Reading data: Notifications | 615 | # Reading data: Notifications |
564 | ### | 616 | ### |
565 | @api_version("1.0.0", "1.0.0") | 617 | @api_version("1.0.0", "1.0.0", __DICT_VERSION_NOTIFICATION) |
566 | def notifications(self, id=None, max_id=None, since_id=None, limit=None): | 618 | def notifications(self, id=None, max_id=None, since_id=None, limit=None): |
567 | """ | 619 | """ |
568 | Fetch notifications (mentions, favourites, reblogs, follows) for the logged-in | 620 | Fetch notifications (mentions, favourites, reblogs, follows) for the logged-in |
@@ -589,7 +641,7 @@ class Mastodon: | |||
589 | ### | 641 | ### |
590 | # Reading data: Accounts | 642 | # Reading data: Accounts |
591 | ### | 643 | ### |
592 | @api_version("1.0.0", "1.0.0") | 644 | @api_version("1.0.0", "1.0.0", __DICT_VERSION_ACCOUNT) |
593 | def account(self, id): | 645 | def account(self, id): |
594 | """ | 646 | """ |
595 | Fetch account information by user `id`. | 647 | Fetch account information by user `id`. |
@@ -600,7 +652,7 @@ class Mastodon: | |||
600 | url = '/api/v1/accounts/{0}'.format(str(id)) | 652 | url = '/api/v1/accounts/{0}'.format(str(id)) |
601 | return self.__api_request('GET', url) | 653 | return self.__api_request('GET', url) |
602 | 654 | ||
603 | @api_version("1.0.0", "2.1.0") | 655 | @api_version("1.0.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
604 | def account_verify_credentials(self): | 656 | def account_verify_credentials(self): |
605 | """ | 657 | """ |
606 | Fetch logged-in user's account information. | 658 | Fetch logged-in user's account information. |
@@ -609,7 +661,7 @@ class Mastodon: | |||
609 | """ | 661 | """ |
610 | return self.__api_request('GET', '/api/v1/accounts/verify_credentials') | 662 | return self.__api_request('GET', '/api/v1/accounts/verify_credentials') |
611 | 663 | ||
612 | @api_version("1.0.0", "2.0.0") | 664 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
613 | def account_statuses(self, id, only_media=False, pinned=False, exclude_replies=False, max_id=None, since_id=None, limit=None): | 665 | def account_statuses(self, id, only_media=False, pinned=False, exclude_replies=False, max_id=None, since_id=None, limit=None): |
614 | """ | 666 | """ |
615 | Fetch statuses by user `id`. Same options as `timeline()`_ are permitted. | 667 | Fetch statuses by user `id`. Same options as `timeline()`_ are permitted. |
@@ -642,7 +694,7 @@ class Mastodon: | |||
642 | url = '/api/v1/accounts/{0}/statuses'.format(str(id)) | 694 | url = '/api/v1/accounts/{0}/statuses'.format(str(id)) |
643 | return self.__api_request('GET', url, params) | 695 | return self.__api_request('GET', url, params) |
644 | 696 | ||
645 | @api_version("1.0.0", "2.1.0") | 697 | @api_version("1.0.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
646 | def account_following(self, id, max_id=None, since_id=None, limit=None): | 698 | def account_following(self, id, max_id=None, since_id=None, limit=None): |
647 | """ | 699 | """ |
648 | Fetch users the given user is following. | 700 | Fetch users the given user is following. |
@@ -660,7 +712,7 @@ class Mastodon: | |||
660 | url = '/api/v1/accounts/{0}/following'.format(str(id)) | 712 | url = '/api/v1/accounts/{0}/following'.format(str(id)) |
661 | return self.__api_request('GET', url, params) | 713 | return self.__api_request('GET', url, params) |
662 | 714 | ||
663 | @api_version("1.0.0", "2.1.0") | 715 | @api_version("1.0.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
664 | def account_followers(self, id, max_id=None, since_id=None, limit=None): | 716 | def account_followers(self, id, max_id=None, since_id=None, limit=None): |
665 | """ | 717 | """ |
666 | Fetch users the given user is followed by. | 718 | Fetch users the given user is followed by. |
@@ -678,7 +730,7 @@ class Mastodon: | |||
678 | url = '/api/v1/accounts/{0}/followers'.format(str(id)) | 730 | url = '/api/v1/accounts/{0}/followers'.format(str(id)) |
679 | return self.__api_request('GET', url, params) | 731 | return self.__api_request('GET', url, params) |
680 | 732 | ||
681 | @api_version("1.0.0", "1.4.0") | 733 | @api_version("1.0.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) |
682 | def account_relationships(self, id): | 734 | def account_relationships(self, id): |
683 | """ | 735 | """ |
684 | Fetch relationship (following, followed_by, blocking, follow requested) of | 736 | Fetch relationship (following, followed_by, blocking, follow requested) of |
@@ -691,7 +743,7 @@ class Mastodon: | |||
691 | return self.__api_request('GET', '/api/v1/accounts/relationships', | 743 | return self.__api_request('GET', '/api/v1/accounts/relationships', |
692 | params) | 744 | params) |
693 | 745 | ||
694 | @api_version("1.0.0", "2.3.0") | 746 | @api_version("1.0.0", "2.3.0", __DICT_VERSION_ACCOUNT) |
695 | def account_search(self, q, limit=None, following=False): | 747 | def account_search(self, q, limit=None, following=False): |
696 | """ | 748 | """ |
697 | Fetch matching accounts. Will lookup an account remotely if the search term is | 749 | Fetch matching accounts. Will lookup an account remotely if the search term is |
@@ -703,7 +755,7 @@ class Mastodon: | |||
703 | params = self.__generate_params(locals()) | 755 | params = self.__generate_params(locals()) |
704 | return self.__api_request('GET', '/api/v1/accounts/search', params) | 756 | return self.__api_request('GET', '/api/v1/accounts/search', params) |
705 | 757 | ||
706 | @api_version("2.1.0", "2.1.0") | 758 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_LIST) |
707 | def account_lists(self, id): | 759 | def account_lists(self, id): |
708 | """ | 760 | """ |
709 | Get all of the logged in users lists which the specified user is | 761 | Get all of the logged in users lists which the specified user is |
@@ -719,7 +771,7 @@ class Mastodon: | |||
719 | ### | 771 | ### |
720 | # Reading data: Searching | 772 | # Reading data: Searching |
721 | ### | 773 | ### |
722 | @api_version("1.1.0", "2.1.0") | 774 | @api_version("1.1.0", "2.1.0", __DICT_VERSION_SEARCHRESULT) |
723 | def search(self, q, resolve=False): | 775 | def search(self, q, resolve=False): |
724 | """ | 776 | """ |
725 | Fetch matching hashtags, accounts and statuses. Will search federated | 777 | Fetch matching hashtags, accounts and statuses. Will search federated |
@@ -733,7 +785,7 @@ class Mastodon: | |||
733 | ### | 785 | ### |
734 | # Reading data: Lists | 786 | # Reading data: Lists |
735 | ### | 787 | ### |
736 | @api_version("2.1.0", "2.1.0") | 788 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_LIST) |
737 | def lists(self): | 789 | def lists(self): |
738 | """ | 790 | """ |
739 | Fetch a list of all the Lists by the logged-in user. | 791 | Fetch a list of all the Lists by the logged-in user. |
@@ -742,7 +794,7 @@ class Mastodon: | |||
742 | """ | 794 | """ |
743 | return self.__api_request('GET', '/api/v1/lists') | 795 | return self.__api_request('GET', '/api/v1/lists') |
744 | 796 | ||
745 | @api_version("2.1.0", "2.1.0") | 797 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_LIST) |
746 | def list(self, id): | 798 | def list(self, id): |
747 | """ | 799 | """ |
748 | Fetch info about a specific list. | 800 | Fetch info about a specific list. |
@@ -752,7 +804,7 @@ class Mastodon: | |||
752 | id = self.__unpack_id(id) | 804 | id = self.__unpack_id(id) |
753 | return self.__api_request('GET', '/api/v1/lists/{0}'.format(id)) | 805 | return self.__api_request('GET', '/api/v1/lists/{0}'.format(id)) |
754 | 806 | ||
755 | @api_version("2.1.0", "2.1.0") | 807 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
756 | def list_accounts(self, id, max_id=None, since_id=None, limit=None): | 808 | def list_accounts(self, id, max_id=None, since_id=None, limit=None): |
757 | """ | 809 | """ |
758 | Get the accounts that are on the given list. A `limit` of 0 can | 810 | Get the accounts that are on the given list. A `limit` of 0 can |
@@ -774,7 +826,7 @@ class Mastodon: | |||
774 | ### | 826 | ### |
775 | # Reading data: Mutes and Blocks | 827 | # Reading data: Mutes and Blocks |
776 | ### | 828 | ### |
777 | @api_version("1.1.0", "2.1.0") | 829 | @api_version("1.1.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
778 | def mutes(self, max_id=None, since_id=None, limit=None): | 830 | def mutes(self, max_id=None, since_id=None, limit=None): |
779 | """ | 831 | """ |
780 | Fetch a list of users muted by the logged-in user. | 832 | Fetch a list of users muted by the logged-in user. |
@@ -790,7 +842,7 @@ class Mastodon: | |||
790 | params = self.__generate_params(locals()) | 842 | params = self.__generate_params(locals()) |
791 | return self.__api_request('GET', '/api/v1/mutes', params) | 843 | return self.__api_request('GET', '/api/v1/mutes', params) |
792 | 844 | ||
793 | @api_version("1.0.0", "2.1.0") | 845 | @api_version("1.0.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
794 | def blocks(self, max_id=None, since_id=None, limit=None): | 846 | def blocks(self, max_id=None, since_id=None, limit=None): |
795 | """ | 847 | """ |
796 | Fetch a list of users blocked by the logged-in user. | 848 | Fetch a list of users blocked by the logged-in user. |
@@ -809,7 +861,7 @@ class Mastodon: | |||
809 | ### | 861 | ### |
810 | # Reading data: Reports | 862 | # Reading data: Reports |
811 | ### | 863 | ### |
812 | @api_version("1.1.0", "1.1.0") | 864 | @api_version("1.1.0", "1.1.0", __DICT_VERSION_REPORT) |
813 | def reports(self): | 865 | def reports(self): |
814 | """ | 866 | """ |
815 | Fetch a list of reports made by the logged-in user. | 867 | Fetch a list of reports made by the logged-in user. |
@@ -824,7 +876,7 @@ class Mastodon: | |||
824 | ### | 876 | ### |
825 | # Reading data: Favourites | 877 | # Reading data: Favourites |
826 | ### | 878 | ### |
827 | @api_version("1.0.0", "2.0.0") | 879 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
828 | def favourites(self, max_id=None, since_id=None, limit=None): | 880 | def favourites(self, max_id=None, since_id=None, limit=None): |
829 | """ | 881 | """ |
830 | Fetch the logged-in user's favourited statuses. | 882 | Fetch the logged-in user's favourited statuses. |
@@ -843,7 +895,7 @@ class Mastodon: | |||
843 | ### | 895 | ### |
844 | # Reading data: Follow requests | 896 | # Reading data: Follow requests |
845 | ### | 897 | ### |
846 | @api_version("1.0.0", "2.1.0") | 898 | @api_version("1.0.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
847 | def follow_requests(self, max_id=None, since_id=None, limit=None): | 899 | def follow_requests(self, max_id=None, since_id=None, limit=None): |
848 | """ | 900 | """ |
849 | Fetch the logged-in user's incoming follow requests. | 901 | Fetch the logged-in user's incoming follow requests. |
@@ -862,7 +914,7 @@ class Mastodon: | |||
862 | ### | 914 | ### |
863 | # Reading data: Domain blocks | 915 | # Reading data: Domain blocks |
864 | ### | 916 | ### |
865 | @api_version("1.4.0", "1.4.0") | 917 | @api_version("1.4.0", "1.4.0", "1.4.0") |
866 | def domain_blocks(self, max_id=None, since_id=None, limit=None): | 918 | def domain_blocks(self, max_id=None, since_id=None, limit=None): |
867 | """ | 919 | """ |
868 | Fetch the logged-in user's blocked domains. | 920 | Fetch the logged-in user's blocked domains. |
@@ -881,7 +933,7 @@ class Mastodon: | |||
881 | ### | 933 | ### |
882 | # Reading data: Emoji | 934 | # Reading data: Emoji |
883 | ### | 935 | ### |
884 | @api_version("2.1.0", "2.1.0") | 936 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_EMOJI) |
885 | def custom_emojis(self): | 937 | def custom_emojis(self): |
886 | """ | 938 | """ |
887 | Fetch the list of custom emoji the instance has installed. | 939 | Fetch the list of custom emoji the instance has installed. |
@@ -896,7 +948,7 @@ class Mastodon: | |||
896 | ### | 948 | ### |
897 | # Writing data: Statuses | 949 | # Writing data: Statuses |
898 | ### | 950 | ### |
899 | @api_version("1.0.0", "2.0.0") | 951 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
900 | def status_post(self, status, in_reply_to_id=None, media_ids=None, | 952 | def status_post(self, status, in_reply_to_id=None, media_ids=None, |
901 | sensitive=False, visibility=None, spoiler_text=None): | 953 | sensitive=False, visibility=None, spoiler_text=None): |
902 | """ | 954 | """ |
@@ -967,7 +1019,7 @@ class Mastodon: | |||
967 | params = self.__generate_params(params_initial) | 1019 | params = self.__generate_params(params_initial) |
968 | return self.__api_request('POST', '/api/v1/statuses', params) | 1020 | return self.__api_request('POST', '/api/v1/statuses', params) |
969 | 1021 | ||
970 | @api_version("1.0.0", "2.0.0") | 1022 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
971 | def toot(self, status): | 1023 | def toot(self, status): |
972 | """ | 1024 | """ |
973 | Synonym for `status_post()`_ that only takes the status text as input. | 1025 | Synonym for `status_post()`_ that only takes the status text as input. |
@@ -978,7 +1030,7 @@ class Mastodon: | |||
978 | """ | 1030 | """ |
979 | return self.status_post(status) | 1031 | return self.status_post(status) |
980 | 1032 | ||
981 | @api_version("1.0.0", "1.0.0") | 1033 | @api_version("1.0.0", "1.0.0", "1.0.0") |
982 | def status_delete(self, id): | 1034 | def status_delete(self, id): |
983 | """ | 1035 | """ |
984 | Delete a status | 1036 | Delete a status |
@@ -987,7 +1039,7 @@ class Mastodon: | |||
987 | url = '/api/v1/statuses/{0}'.format(str(id)) | 1039 | url = '/api/v1/statuses/{0}'.format(str(id)) |
988 | self.__api_request('DELETE', url) | 1040 | self.__api_request('DELETE', url) |
989 | 1041 | ||
990 | @api_version("1.0.0", "2.0.0") | 1042 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
991 | def status_reblog(self, id): | 1043 | def status_reblog(self, id): |
992 | """ | 1044 | """ |
993 | Reblog a status. | 1045 | Reblog a status. |
@@ -998,7 +1050,7 @@ class Mastodon: | |||
998 | url = '/api/v1/statuses/{0}/reblog'.format(str(id)) | 1050 | url = '/api/v1/statuses/{0}/reblog'.format(str(id)) |
999 | return self.__api_request('POST', url) | 1051 | return self.__api_request('POST', url) |
1000 | 1052 | ||
1001 | @api_version("1.0.0", "2.0.0") | 1053 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
1002 | def status_unreblog(self, id): | 1054 | def status_unreblog(self, id): |
1003 | """ | 1055 | """ |
1004 | Un-reblog a status. | 1056 | Un-reblog a status. |
@@ -1009,7 +1061,7 @@ class Mastodon: | |||
1009 | url = '/api/v1/statuses/{0}/unreblog'.format(str(id)) | 1061 | url = '/api/v1/statuses/{0}/unreblog'.format(str(id)) |
1010 | return self.__api_request('POST', url) | 1062 | return self.__api_request('POST', url) |
1011 | 1063 | ||
1012 | @api_version("1.0.0", "2.0.0") | 1064 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
1013 | def status_favourite(self, id): | 1065 | def status_favourite(self, id): |
1014 | """ | 1066 | """ |
1015 | Favourite a status. | 1067 | Favourite a status. |
@@ -1020,7 +1072,7 @@ class Mastodon: | |||
1020 | url = '/api/v1/statuses/{0}/favourite'.format(str(id)) | 1072 | url = '/api/v1/statuses/{0}/favourite'.format(str(id)) |
1021 | return self.__api_request('POST', url) | 1073 | return self.__api_request('POST', url) |
1022 | 1074 | ||
1023 | @api_version("1.0.0", "2.0.0") | 1075 | @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) |
1024 | def status_unfavourite(self, id): | 1076 | def status_unfavourite(self, id): |
1025 | """ | 1077 | """ |
1026 | Un-favourite a status. | 1078 | Un-favourite a status. |
@@ -1031,7 +1083,7 @@ class Mastodon: | |||
1031 | url = '/api/v1/statuses/{0}/unfavourite'.format(str(id)) | 1083 | url = '/api/v1/statuses/{0}/unfavourite'.format(str(id)) |
1032 | return self.__api_request('POST', url) | 1084 | return self.__api_request('POST', url) |
1033 | 1085 | ||
1034 | @api_version("1.4.0", "2.0.0") | 1086 | @api_version("1.4.0", "2.0.0", __DICT_VERSION_STATUS) |
1035 | def status_mute(self, id): | 1087 | def status_mute(self, id): |
1036 | """ | 1088 | """ |
1037 | Mute notifications for a status. | 1089 | Mute notifications for a status. |
@@ -1042,7 +1094,7 @@ class Mastodon: | |||
1042 | url = '/api/v1/statuses/{0}/mute'.format(str(id)) | 1094 | url = '/api/v1/statuses/{0}/mute'.format(str(id)) |
1043 | return self.__api_request('POST', url) | 1095 | return self.__api_request('POST', url) |
1044 | 1096 | ||
1045 | @api_version("1.4.0", "2.0.0") | 1097 | @api_version("1.4.0", "2.0.0", __DICT_VERSION_STATUS) |
1046 | def status_unmute(self, id): | 1098 | def status_unmute(self, id): |
1047 | """ | 1099 | """ |
1048 | Unmute notifications for a status. | 1100 | Unmute notifications for a status. |
@@ -1056,7 +1108,7 @@ class Mastodon: | |||
1056 | ### | 1108 | ### |
1057 | # Writing data: Notifications | 1109 | # Writing data: Notifications |
1058 | ### | 1110 | ### |
1059 | @api_version("1.0.0", "1.0.0") | 1111 | @api_version("1.0.0", "1.0.0", "1.0.0") |
1060 | def notifications_clear(self): | 1112 | def notifications_clear(self): |
1061 | """ | 1113 | """ |
1062 | Clear out a users notifications | 1114 | Clear out a users notifications |
@@ -1064,7 +1116,7 @@ class Mastodon: | |||
1064 | self.__api_request('POST', '/api/v1/notifications/clear') | 1116 | self.__api_request('POST', '/api/v1/notifications/clear') |
1065 | 1117 | ||
1066 | 1118 | ||
1067 | @api_version("1.3.0", "1.3.0") | 1119 | @api_version("1.3.0", "1.3.0", "1.3.0") |
1068 | def notifications_dismiss(self, id): | 1120 | def notifications_dismiss(self, id): |
1069 | """ | 1121 | """ |
1070 | Deletes a single notification | 1122 | Deletes a single notification |
@@ -1076,7 +1128,7 @@ class Mastodon: | |||
1076 | ### | 1128 | ### |
1077 | # Writing data: Accounts | 1129 | # Writing data: Accounts |
1078 | ### | 1130 | ### |
1079 | @api_version("1.0.0", "1.4.0") | 1131 | @api_version("1.0.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) |
1080 | def account_follow(self, id): | 1132 | def account_follow(self, id): |
1081 | """ | 1133 | """ |
1082 | Follow a user. | 1134 | Follow a user. |
@@ -1087,7 +1139,7 @@ class Mastodon: | |||
1087 | url = '/api/v1/accounts/{0}/follow'.format(str(id)) | 1139 | url = '/api/v1/accounts/{0}/follow'.format(str(id)) |
1088 | return self.__api_request('POST', url) | 1140 | return self.__api_request('POST', url) |
1089 | 1141 | ||
1090 | @api_version("1.0.0", "2.1.0") | 1142 | @api_version("1.0.0", "2.1.0", __DICT_VERSION_ACCOUNT) |
1091 | def follows(self, uri): | 1143 | def follows(self, uri): |
1092 | """ | 1144 | """ |
1093 | Follow a remote user by uri (username@domain). | 1145 | Follow a remote user by uri (username@domain). |
@@ -1097,7 +1149,7 @@ class Mastodon: | |||
1097 | params = self.__generate_params(locals()) | 1149 | params = self.__generate_params(locals()) |
1098 | return self.__api_request('POST', '/api/v1/follows', params) | 1150 | return self.__api_request('POST', '/api/v1/follows', params) |
1099 | 1151 | ||
1100 | @api_version("1.0.0", "1.4.0") | 1152 | @api_version("1.0.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) |
1101 | def account_unfollow(self, id): | 1153 | def account_unfollow(self, id): |
1102 | """ | 1154 | """ |
1103 | Unfollow a user. | 1155 | Unfollow a user. |
@@ -1108,7 +1160,7 @@ class Mastodon: | |||
1108 | url = '/api/v1/accounts/{0}/unfollow'.format(str(id)) | 1160 | url = '/api/v1/accounts/{0}/unfollow'.format(str(id)) |
1109 | return self.__api_request('POST', url) | 1161 | return self.__api_request('POST', url) |
1110 | 1162 | ||
1111 | @api_version("1.0.0", "1.4.0") | 1163 | @api_version("1.0.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) |
1112 | def account_block(self, id): | 1164 | def account_block(self, id): |
1113 | """ | 1165 | """ |
1114 | Block a user. | 1166 | Block a user. |
@@ -1119,7 +1171,7 @@ class Mastodon: | |||
1119 | url = '/api/v1/accounts/{0}/block'.format(str(id)) | 1171 | url = '/api/v1/accounts/{0}/block'.format(str(id)) |
1120 | return self.__api_request('POST', url) | 1172 | return self.__api_request('POST', url) |
1121 | 1173 | ||
1122 | @api_version("1.0.0", "1.4.0") | 1174 | @api_version("1.0.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) |
1123 | def account_unblock(self, id): | 1175 | def account_unblock(self, id): |
1124 | """ | 1176 | """ |
1125 | Unblock a user. | 1177 | Unblock a user. |
@@ -1130,7 +1182,7 @@ class Mastodon: | |||
1130 | url = '/api/v1/accounts/{0}/unblock'.format(str(id)) | 1182 | url = '/api/v1/accounts/{0}/unblock'.format(str(id)) |
1131 | return self.__api_request('POST', url) | 1183 | return self.__api_request('POST', url) |
1132 | 1184 | ||
1133 | @api_version("1.1.0", "1.4.0") | 1185 | @api_version("1.1.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) |
1134 | def account_mute(self, id): | 1186 | def account_mute(self, id): |
1135 | """ | 1187 | """ |
1136 | Mute a user. | 1188 | Mute a user. |
@@ -1141,7 +1193,7 @@ class Mastodon: | |||
1141 | url = '/api/v1/accounts/{0}/mute'.format(str(id)) | 1193 | url = '/api/v1/accounts/{0}/mute'.format(str(id)) |
1142 | return self.__api_request('POST', url) | 1194 | return self.__api_request('POST', url) |
1143 | 1195 | ||
1144 | @api_version("1.1.0", "1.4.0") | 1196 | @api_version("1.1.0", "1.4.0", __DICT_VERSION_RELATIONSHIP) |
1145 | def account_unmute(self, id): | 1197 | def account_unmute(self, id): |
1146 | """ | 1198 | """ |
1147 | Unmute a user. | 1199 | Unmute a user. |
@@ -1152,7 +1204,7 @@ class Mastodon: | |||
1152 | url = '/api/v1/accounts/{0}/unmute'.format(str(id)) | 1204 | url = '/api/v1/accounts/{0}/unmute'.format(str(id)) |
1153 | return self.__api_request('POST', url) | 1205 | return self.__api_request('POST', url) |
1154 | 1206 | ||
1155 | @api_version("1.1.1", "2.3.0") | 1207 | @api_version("1.1.1", "2.3.0", __DICT_VERSION_ACCOUNT) |
1156 | def account_update_credentials(self, display_name=None, note=None, | 1208 | def account_update_credentials(self, display_name=None, note=None, |
1157 | avatar=None, avatar_mime_type=None, | 1209 | avatar=None, avatar_mime_type=None, |
1158 | header=None, header_mime_type=None, locked=None): | 1210 | header=None, header_mime_type=None, locked=None): |
@@ -1206,7 +1258,7 @@ class Mastodon: | |||
1206 | ### | 1258 | ### |
1207 | # Writing data: Lists | 1259 | # Writing data: Lists |
1208 | ### | 1260 | ### |
1209 | @api_version("2.1.0", "2.1.0") | 1261 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_LIST) |
1210 | def list_create(self, title): | 1262 | def list_create(self, title): |
1211 | """ | 1263 | """ |
1212 | Create a new list with the given `title`. | 1264 | Create a new list with the given `title`. |
@@ -1216,7 +1268,7 @@ class Mastodon: | |||
1216 | params = self.__generate_params(locals()) | 1268 | params = self.__generate_params(locals()) |
1217 | return self.__api_request('POST', '/api/v1/lists', params) | 1269 | return self.__api_request('POST', '/api/v1/lists', params) |
1218 | 1270 | ||
1219 | @api_version("2.1.0", "2.1.0") | 1271 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_LIST) |
1220 | def list_update(self, id, title): | 1272 | def list_update(self, id, title): |
1221 | """ | 1273 | """ |
1222 | Update info about a list, where "info" is really the lists `title`. | 1274 | Update info about a list, where "info" is really the lists `title`. |
@@ -1227,7 +1279,7 @@ class Mastodon: | |||
1227 | params = self.__generate_params(locals(), ['id']) | 1279 | params = self.__generate_params(locals(), ['id']) |
1228 | return self.__api_request('PUT', '/api/v1/lists/{0}'.format(id), params) | 1280 | return self.__api_request('PUT', '/api/v1/lists/{0}'.format(id), params) |
1229 | 1281 | ||
1230 | @api_version("2.1.0", "2.1.0") | 1282 | @api_version("2.1.0", "2.1.0", "2.1.0") |
1231 | def list_delete(self, id): | 1283 | def list_delete(self, id): |
1232 | """ | 1284 | """ |
1233 | Delete a list. | 1285 | Delete a list. |
@@ -1235,7 +1287,7 @@ class Mastodon: | |||
1235 | id = self.__unpack_id(id) | 1287 | id = self.__unpack_id(id) |
1236 | self.__api_request('DELETE', '/api/v1/lists/{0}'.format(id)) | 1288 | self.__api_request('DELETE', '/api/v1/lists/{0}'.format(id)) |
1237 | 1289 | ||
1238 | @api_version("2.1.0", "2.1.0") | 1290 | @api_version("2.1.0", "2.1.0", "2.1.0") |
1239 | def list_accounts_add(self, id, account_ids): | 1291 | def list_accounts_add(self, id, account_ids): |
1240 | """ | 1292 | """ |
1241 | Add the account(s) given in `account_ids` to the list. | 1293 | Add the account(s) given in `account_ids` to the list. |
@@ -1249,7 +1301,7 @@ class Mastodon: | |||
1249 | params = self.__generate_params(locals(), ['id']) | 1301 | params = self.__generate_params(locals(), ['id']) |
1250 | self.__api_request('POST', '/api/v1/lists/{0}/accounts'.format(id), params) | 1302 | self.__api_request('POST', '/api/v1/lists/{0}/accounts'.format(id), params) |
1251 | 1303 | ||
1252 | @api_version("2.1.0", "2.1.0") | 1304 | @api_version("2.1.0", "2.1.0", "2.1.0") |
1253 | def list_accounts_delete(self, id, account_ids): | 1305 | def list_accounts_delete(self, id, account_ids): |
1254 | """ | 1306 | """ |
1255 | Remove the account(s) given in `account_ids` from the list. | 1307 | Remove the account(s) given in `account_ids` from the list. |
@@ -1266,7 +1318,7 @@ class Mastodon: | |||
1266 | ### | 1318 | ### |
1267 | # Writing data: Reports | 1319 | # Writing data: Reports |
1268 | ### | 1320 | ### |
1269 | @api_version("1.1.0", "1.1.0") | 1321 | @api_version("1.1.0", "1.1.0", __DICT_VERSION_REPORT) |
1270 | def report(self, account_id, status_ids, comment): | 1322 | def report(self, account_id, status_ids, comment): |
1271 | """ | 1323 | """ |
1272 | Report statuses to the instances administrators. | 1324 | Report statuses to the instances administrators. |
@@ -1287,7 +1339,7 @@ class Mastodon: | |||
1287 | ### | 1339 | ### |
1288 | # Writing data: Follow requests | 1340 | # Writing data: Follow requests |
1289 | ### | 1341 | ### |
1290 | @api_version("1.0.0", "1.0.0") | 1342 | @api_version("1.0.0", "1.0.0", "1.0.0") |
1291 | def follow_request_authorize(self, id): | 1343 | def follow_request_authorize(self, id): |
1292 | """ | 1344 | """ |
1293 | Accept an incoming follow request. | 1345 | Accept an incoming follow request. |
@@ -1296,7 +1348,7 @@ class Mastodon: | |||
1296 | url = '/api/v1/follow_requests/{0}/authorize'.format(str(id)) | 1348 | url = '/api/v1/follow_requests/{0}/authorize'.format(str(id)) |
1297 | self.__api_request('POST', url) | 1349 | self.__api_request('POST', url) |
1298 | 1350 | ||
1299 | @api_version("1.0.0", "1.0.0") | 1351 | @api_version("1.0.0", "1.0.0", "1.0.0") |
1300 | def follow_request_reject(self, id): | 1352 | def follow_request_reject(self, id): |
1301 | """ | 1353 | """ |
1302 | Reject an incoming follow request. | 1354 | Reject an incoming follow request. |
@@ -1308,7 +1360,7 @@ class Mastodon: | |||
1308 | ### | 1360 | ### |
1309 | # Writing data: Media | 1361 | # Writing data: Media |
1310 | ### | 1362 | ### |
1311 | @api_version("1.0.0", "2.3.0") | 1363 | @api_version("1.0.0", "2.3.0", __DICT_VERSION_MEDIA) |
1312 | def media_post(self, media_file, mime_type=None, description=None, focus=None): | 1364 | def media_post(self, media_file, mime_type=None, description=None, focus=None): |
1313 | """ | 1365 | """ |
1314 | Post an image. `media_file` can either be image data or | 1366 | Post an image. `media_file` can either be image data or |
@@ -1349,7 +1401,7 @@ class Mastodon: | |||
1349 | ### | 1401 | ### |
1350 | # Writing data: Domain blocks | 1402 | # Writing data: Domain blocks |
1351 | ### | 1403 | ### |
1352 | @api_version("1.4.0", "1.4.0") | 1404 | @api_version("1.4.0", "1.4.0", "1.4.0") |
1353 | def domain_block(self, domain=None): | 1405 | def domain_block(self, domain=None): |
1354 | """ | 1406 | """ |
1355 | Add a block for all statuses originating from the specified domain for the logged-in user. | 1407 | Add a block for all statuses originating from the specified domain for the logged-in user. |
@@ -1357,7 +1409,7 @@ class Mastodon: | |||
1357 | params = self.__generate_params(locals()) | 1409 | params = self.__generate_params(locals()) |
1358 | self.__api_request('POST', '/api/v1/domain_blocks', params) | 1410 | self.__api_request('POST', '/api/v1/domain_blocks', params) |
1359 | 1411 | ||
1360 | @api_version("1.4.0", "1.4.0") | 1412 | @api_version("1.4.0", "1.4.0", "1.4.0") |
1361 | def domain_unblock(self, domain=None): | 1413 | def domain_unblock(self, domain=None): |
1362 | """ | 1414 | """ |
1363 | Remove a domain block for the logged-in user. | 1415 | Remove a domain block for the logged-in user. |
@@ -1438,7 +1490,7 @@ class Mastodon: | |||
1438 | ### | 1490 | ### |
1439 | # Streaming | 1491 | # Streaming |
1440 | ### | 1492 | ### |
1441 | @api_version("1.1.0", "1.4.2") | 1493 | @api_version("1.1.0", "1.4.2", __DICT_VERSION_STATUS) |
1442 | def stream_user(self, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): | 1494 | def stream_user(self, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): |
1443 | """ | 1495 | """ |
1444 | Streams events that are relevant to the authorized user, i.e. home | 1496 | Streams events that are relevant to the authorized user, i.e. home |
@@ -1446,21 +1498,21 @@ class Mastodon: | |||
1446 | """ | 1498 | """ |
1447 | return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) | 1499 | return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) |
1448 | 1500 | ||
1449 | @api_version("1.1.0", "1.4.2") | 1501 | @api_version("1.1.0", "1.4.2", __DICT_VERSION_STATUS) |
1450 | def stream_public(self, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): | 1502 | def stream_public(self, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): |
1451 | """ | 1503 | """ |
1452 | Streams public events. | 1504 | Streams public events. |
1453 | """ | 1505 | """ |
1454 | return self.__stream('/api/v1/streaming/public', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) | 1506 | return self.__stream('/api/v1/streaming/public', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) |
1455 | 1507 | ||
1456 | @api_version("1.1.0", "1.4.2") | 1508 | @api_version("1.1.0", "1.4.2", __DICT_VERSION_STATUS) |
1457 | def stream_local(self, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): | 1509 | def stream_local(self, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): |
1458 | """ | 1510 | """ |
1459 | Streams local public events. | 1511 | Streams local public events. |
1460 | """ | 1512 | """ |
1461 | return self.__stream('/api/v1/streaming/public/local', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) | 1513 | return self.__stream('/api/v1/streaming/public/local', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) |
1462 | 1514 | ||
1463 | @api_version("1.1.0", "1.4.2") | 1515 | @api_version("1.1.0", "1.4.2", __DICT_VERSION_STATUS) |
1464 | def stream_hashtag(self, tag, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): | 1516 | def stream_hashtag(self, tag, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): |
1465 | """ | 1517 | """ |
1466 | Stream for all public statuses for the hashtag 'tag' seen by the connected | 1518 | Stream for all public statuses for the hashtag 'tag' seen by the connected |
@@ -1470,7 +1522,7 @@ class Mastodon: | |||
1470 | raise MastodonIllegalArgumentError("Tag parameter should omit leading #") | 1522 | raise MastodonIllegalArgumentError("Tag parameter should omit leading #") |
1471 | return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) | 1523 | return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) |
1472 | 1524 | ||
1473 | @api_version("2.1.0", "2.1.0") | 1525 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_STATUS) |
1474 | def stream_list(self, id, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): | 1526 | def stream_list(self, id, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): |
1475 | """ | 1527 | """ |
1476 | Stream events for the current user, restricted to accounts on the given | 1528 | Stream events for the current user, restricted to accounts on the given |