Mastodon.py 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Mastodon.py-2.0.0.dist-info/LICENSE +21 -0
- Mastodon.py-2.0.0.dist-info/METADATA +106 -0
- Mastodon.py-2.0.0.dist-info/RECORD +40 -0
- Mastodon.py-2.0.0.dist-info/WHEEL +5 -0
- Mastodon.py-2.0.0.dist-info/top_level.txt +1 -0
- mastodon/Mastodon.py +83 -0
- mastodon/__init__.py +6 -0
- mastodon/accounts.py +482 -0
- mastodon/admin.py +807 -0
- mastodon/authentication.py +434 -0
- mastodon/compat.py +47 -0
- mastodon/conversations.py +33 -0
- mastodon/defaults.py +65 -0
- mastodon/endorsements.py +17 -0
- mastodon/errors.py +90 -0
- mastodon/favourites.py +38 -0
- mastodon/filters.py +267 -0
- mastodon/hashtags.py +101 -0
- mastodon/instance.py +237 -0
- mastodon/internals.py +651 -0
- mastodon/lists.py +88 -0
- mastodon/media.py +123 -0
- mastodon/notifications.py +249 -0
- mastodon/polls.py +59 -0
- mastodon/preferences.py +80 -0
- mastodon/push.py +237 -0
- mastodon/py.typed +0 -0
- mastodon/relationships.py +93 -0
- mastodon/reports.py +62 -0
- mastodon/return_types.py +6987 -0
- mastodon/search.py +94 -0
- mastodon/statuses.py +587 -0
- mastodon/streaming.py +325 -0
- mastodon/streaming_endpoints.py +88 -0
- mastodon/suggestions.py +49 -0
- mastodon/timeline.py +107 -0
- mastodon/trends.py +80 -0
- mastodon/types_base.py +668 -0
- mastodon/utility.py +220 -0
- mastodon/versions.py +57 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Lorenz Diener / Mastodon.py contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: Mastodon.py
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Python wrapper for the Mastodon API
|
|
5
|
+
Author-email: Lorenz Diener <lorenzd+mastodonpypypi@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/halcy/Mastodon.py
|
|
8
|
+
Project-URL: Documentation, https://mastodonpy.readthedocs.io/
|
|
9
|
+
Keywords: mastodon,api,microblogging
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Topic :: Communications
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 2
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Description-Content-Type: text/x-rst
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: requests>=2.4.2
|
|
19
|
+
Requires-Dist: python-dateutil
|
|
20
|
+
Requires-Dist: python-magic-bin; platform_system == "Windows"
|
|
21
|
+
Requires-Dist: python-magic; platform_system != "Windows"
|
|
22
|
+
Requires-Dist: decorator>=4.0.0
|
|
23
|
+
Requires-Dist: blurhash>=1.1.4
|
|
24
|
+
Provides-Extra: webpush
|
|
25
|
+
Requires-Dist: http_ece>=1.0.5; extra == "webpush"
|
|
26
|
+
Requires-Dist: cryptography>=1.6.0; extra == "webpush"
|
|
27
|
+
Provides-Extra: blurhash
|
|
28
|
+
Requires-Dist: blurhash>=1.1.4; extra == "blurhash"
|
|
29
|
+
Provides-Extra: test
|
|
30
|
+
Requires-Dist: pytest; extra == "test"
|
|
31
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
32
|
+
Requires-Dist: vcrpy; extra == "test"
|
|
33
|
+
Requires-Dist: pytest-vcr; extra == "test"
|
|
34
|
+
Requires-Dist: pytest-mock; extra == "test"
|
|
35
|
+
Requires-Dist: requests-mock; extra == "test"
|
|
36
|
+
Requires-Dist: pytz; extra == "test"
|
|
37
|
+
Requires-Dist: pytest-retry; extra == "test"
|
|
38
|
+
Provides-Extra: test-old
|
|
39
|
+
Requires-Dist: pytest; extra == "test-old"
|
|
40
|
+
Requires-Dist: pytest-cov; extra == "test-old"
|
|
41
|
+
Requires-Dist: vcrpy; extra == "test-old"
|
|
42
|
+
Requires-Dist: pytest-vcr; extra == "test-old"
|
|
43
|
+
Requires-Dist: pytest-mock; extra == "test-old"
|
|
44
|
+
Requires-Dist: requests-mock; extra == "test-old"
|
|
45
|
+
Requires-Dist: pytz; extra == "test-old"
|
|
46
|
+
Provides-Extra: docs
|
|
47
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
48
|
+
|
|
49
|
+
Mastodon.py
|
|
50
|
+
===========
|
|
51
|
+
Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
|
|
52
|
+
Feature complete for public API as of Mastodon version 4.3.0 and easy to get started with:
|
|
53
|
+
|
|
54
|
+
.. code-block:: python
|
|
55
|
+
|
|
56
|
+
from mastodon import Mastodon
|
|
57
|
+
|
|
58
|
+
# Register your app! This only needs to be done once (per server, or when
|
|
59
|
+
# distributing rather than hosting an application, most likely per device and server).
|
|
60
|
+
# Uncomment the code and substitute in your information:
|
|
61
|
+
'''
|
|
62
|
+
Mastodon.create_app(
|
|
63
|
+
'pytooterapp',
|
|
64
|
+
api_base_url = 'https://mastodon.social',
|
|
65
|
+
to_file = 'pytooter_clientcred.secret'
|
|
66
|
+
)
|
|
67
|
+
'''
|
|
68
|
+
|
|
69
|
+
# Then, log in. This can be done every time your application starts, or you can use the persisted information:
|
|
70
|
+
mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',)
|
|
71
|
+
print(mastodon.auth_request_url())
|
|
72
|
+
|
|
73
|
+
# open the URL in the browser and paste the code you get
|
|
74
|
+
mastodon.log_in(
|
|
75
|
+
code=input("Enter the OAuth authorization code: "),
|
|
76
|
+
to_file="pytooter_usercred.secret"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# To post, create an actual API instance:
|
|
80
|
+
mastodon = Mastodon(access_token = 'pytooter_usercred.secret')
|
|
81
|
+
mastodon.toot('Tooting from Python using #mastodonpy !')
|
|
82
|
+
|
|
83
|
+
You can install Mastodon.py via pypi:
|
|
84
|
+
|
|
85
|
+
.. code-block:: Bash
|
|
86
|
+
|
|
87
|
+
pip install Mastodon.py
|
|
88
|
+
|
|
89
|
+
We currently try to support Python 3.7 and above, and try to at least not break Python 3 versions
|
|
90
|
+
below that. Python 2 support is no longer a goal.
|
|
91
|
+
|
|
92
|
+
Full documentation and basic usage examples can be found
|
|
93
|
+
at https://mastodonpy.readthedocs.io/en/stable/ . Some more extensive examples can be
|
|
94
|
+
found at https://github.com/halcy/MastodonpyExamples
|
|
95
|
+
|
|
96
|
+
Acknowledgements
|
|
97
|
+
----------------
|
|
98
|
+
Mastodon.py contains work by a large amount of contributors, many of which have
|
|
99
|
+
put significant work into making it a better library. You can find some information
|
|
100
|
+
about who helped with which particular feature or fix in the changelog.
|
|
101
|
+
|
|
102
|
+
.. image:: https://circleci.com/gh/halcy/Mastodon.py.svg?style=svg
|
|
103
|
+
:target: https://app.circleci.com/pipelines/github/halcy/Mastodon.py
|
|
104
|
+
.. image:: https://codecov.io/gh/halcy/Mastodon.py/branch/master/graph/badge.svg
|
|
105
|
+
:target: https://codecov.io/gh/halcy/Mastodon.py
|
|
106
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
mastodon/Mastodon.py,sha256=ni2Y6N5KarA8BVWye9sZBqziIoj_o_0sgLOb8m_dhoo,3278
|
|
2
|
+
mastodon/__init__.py,sha256=FYLlT0p-kYhiAwMT0zEUPPTlraPg2Jy8SKY45vVME4c,1060
|
|
3
|
+
mastodon/accounts.py,sha256=Ifq7U7BkzwQ365LfdAJfPdUbzwWE_pjewqehn5K7HWQ,22627
|
|
4
|
+
mastodon/admin.py,sha256=J0uzdzSJbXVB69-5isQmY0GzbMzO1yOzFNtJebdGqL4,43554
|
|
5
|
+
mastodon/authentication.py,sha256=cHWP10OmoaF9Qkc2SVJuAda5wJO-thd2h6V4guuifOY,23488
|
|
6
|
+
mastodon/compat.py,sha256=DsIZSAHlfM6ss7KzGeH2szNdxLYgDGCclk7CT2XLuoU,973
|
|
7
|
+
mastodon/conversations.py,sha256=I9ax0TOrMgES1dPp9Vf2vZ1n80n8RX4CiprRbM_8YHc,1268
|
|
8
|
+
mastodon/defaults.py,sha256=ExP3Nl29lM19nVktA3x0Uqfj825TbesUezQeQ7yTwpY,1862
|
|
9
|
+
mastodon/endorsements.py,sha256=AN70W9QV7Osb_7rkjdpRtoklpHa6ETyyjwnAWLQuM7U,538
|
|
10
|
+
mastodon/errors.py,sha256=0pAfRDojIkPa5n7FI4swIVVeGohrkaz3dik5vYgGaEE,2457
|
|
11
|
+
mastodon/favourites.py,sha256=iiIIOlMq1ZMqs0suUyhAQn6q98OjGi3m9dU6HuqZals,1562
|
|
12
|
+
mastodon/filters.py,sha256=p0SaykK3ARyi1mLl4SL_XRpmctiEbhJxsnb6PXiaDjc,11612
|
|
13
|
+
mastodon/hashtags.py,sha256=S5_xj5bz0zOrpJYFZyooUna8_sO8tXiFuQrKB92nVpA,3829
|
|
14
|
+
mastodon/instance.py,sha256=soANvLR-c_HwLGEcIMZXe1PEaayO0GZN9AYzMC27B8I,9897
|
|
15
|
+
mastodon/internals.py,sha256=gO3IcOAeWleBt_5ZULiKeVIhlmS2jAvceaadKqvHDh0,30276
|
|
16
|
+
mastodon/lists.py,sha256=PvsLT0yIaGI6a5XZG08gYMVAfaWcuW9TCPrFHML-4mw,3452
|
|
17
|
+
mastodon/media.py,sha256=CEk5aTZINV1tDHHwfa1XY2m0DWeX8WOUytXXX69QJM8,5796
|
|
18
|
+
mastodon/notifications.py,sha256=Y2UcWRqfgCg21vvO0lfQ3uYkNmQghsGLk07MBpFd8dc,13740
|
|
19
|
+
mastodon/polls.py,sha256=mi4P5u48DjJcXPWKRPgY75NjNjbDZjbKw3PUWx-9HUg,2373
|
|
20
|
+
mastodon/preferences.py,sha256=2Arai0Y2KlkPtmMPfW_ctaSKJ1LMcZYxN8iNGQxlwuI,3336
|
|
21
|
+
mastodon/push.py,sha256=houUcxeJfHvONAf_qrLzKm-Uzmn6lonqnGl1epQyirw,11118
|
|
22
|
+
mastodon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
mastodon/relationships.py,sha256=BVmB6AasUeCuXqbsjoKF8TU5Tb_zIFjoSMiVzz-eKHM,3841
|
|
24
|
+
mastodon/reports.py,sha256=kLqvtwNEkV84bEsKcoekLFfHMqJNyLZAm6gpmy52kfQ,2792
|
|
25
|
+
mastodon/return_types.py,sha256=SECoXKIss7y0feJyjm21IHzv-IQn9v72qRtYw5Gh2Sg,159770
|
|
26
|
+
mastodon/search.py,sha256=1Yo2aNlGfTAjB09sLdji23A-paLZnmQzMU3PXLm-usU,4567
|
|
27
|
+
mastodon/statuses.py,sha256=SA7XXGBfKNDJ3sHKKvOBGMYeO2XL-3keqaP1UgnQdJk,26571
|
|
28
|
+
mastodon/streaming.py,sha256=4eh7QFC3QFoNRqko8h2AvSrHyXI0YsV110NuY8pdxVw,13316
|
|
29
|
+
mastodon/streaming_endpoints.py,sha256=z5khMaO1D6ItD1Cq1oyp_HKdmIVMlxgCf1pV1udItHk,4903
|
|
30
|
+
mastodon/suggestions.py,sha256=VJhhwYqgUF5Zrcia9nexOm2iOeFOIu_kJFSM_qamg14,1790
|
|
31
|
+
mastodon/timeline.py,sha256=bXYOwgigULM-B2zE80XCyaHh5-fZcyKu8lH_x10bYug,6770
|
|
32
|
+
mastodon/trends.py,sha256=brrYdfGZgMLK9wItNQYz4Bm38uWpBPymAgPSLmUK_Tk,3499
|
|
33
|
+
mastodon/types_base.py,sha256=8Ecb1zCnDE78yJ_fOJ-z0XuBPKiHJYAN7idRWlj6ZxM,29943
|
|
34
|
+
mastodon/utility.py,sha256=v_RuQ9BpUlVOKTNXK-xFSqe1dPEsmkCxNLytXp_MKy8,9677
|
|
35
|
+
mastodon/versions.py,sha256=3pE1h1T4askdOHHhs8vaxtltv4iTcmbWoJfe7sDKU0c,3003
|
|
36
|
+
Mastodon.py-2.0.0.dist-info/LICENSE,sha256=ZvVSK9bgQICEW3jDhZvyPiv9oPe-GTbhzA1eVg6kplY,1097
|
|
37
|
+
Mastodon.py-2.0.0.dist-info/METADATA,sha256=XoGWLFLuQfYsNFOQJZtsht1cb39dKIlEwxAvA-uVUkM,4126
|
|
38
|
+
Mastodon.py-2.0.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
39
|
+
Mastodon.py-2.0.0.dist-info/top_level.txt,sha256=K8IaGiBQHg7qJT2rPGIJUy_w0GciduVxXA1S8RZFT0k,9
|
|
40
|
+
Mastodon.py-2.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mastodon
|
mastodon/Mastodon.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import base64
|
|
5
|
+
import os
|
|
6
|
+
import os.path
|
|
7
|
+
import time
|
|
8
|
+
import datetime
|
|
9
|
+
import collections
|
|
10
|
+
from contextlib import closing
|
|
11
|
+
import requests
|
|
12
|
+
from requests.models import urlencode
|
|
13
|
+
import dateutil
|
|
14
|
+
import dateutil.parser
|
|
15
|
+
import re
|
|
16
|
+
import copy
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
from mastodon.compat import IMPL_HAS_CRYPTO, IMPL_HAS_ECE, IMPL_HAS_BLURHASH
|
|
20
|
+
from mastodon.compat import cryptography, default_backend, ec, serialization
|
|
21
|
+
from mastodon.compat import http_ece
|
|
22
|
+
from mastodon.compat import blurhash
|
|
23
|
+
from mastodon.compat import urlparse
|
|
24
|
+
|
|
25
|
+
from mastodon.utility import parse_version_string, max_version, api_version
|
|
26
|
+
from mastodon.utility import Mastodon as MastoUtility
|
|
27
|
+
|
|
28
|
+
from mastodon.return_types import *
|
|
29
|
+
from mastodon.errors import *
|
|
30
|
+
|
|
31
|
+
from mastodon.defaults import _DEFAULT_TIMEOUT, _DEFAULT_SCOPES, _DEFAULT_STREAM_TIMEOUT, _DEFAULT_STREAM_RECONNECT_WAIT_SEC
|
|
32
|
+
from mastodon.defaults import _SCOPE_SETS
|
|
33
|
+
|
|
34
|
+
from mastodon.internals import Mastodon as Internals
|
|
35
|
+
from mastodon.authentication import Mastodon as MastoAuthentication
|
|
36
|
+
from mastodon.accounts import Mastodon as MastoAccounts
|
|
37
|
+
from mastodon.instance import Mastodon as MastoInstance
|
|
38
|
+
from mastodon.timeline import Mastodon as MastoTimeline
|
|
39
|
+
from mastodon.statuses import Mastodon as MastoStatuses
|
|
40
|
+
from mastodon.media import Mastodon as MastoMedia
|
|
41
|
+
from mastodon.polls import Mastodon as MastoPolls
|
|
42
|
+
from mastodon.notifications import Mastodon as MastoNotifications
|
|
43
|
+
from mastodon.conversations import Mastodon as MastoConversations
|
|
44
|
+
from mastodon.hashtags import Mastodon as MastoHashtags
|
|
45
|
+
from mastodon.filters import Mastodon as MastoFilters
|
|
46
|
+
from mastodon.suggestions import Mastodon as MastoSuggestions
|
|
47
|
+
from mastodon.endorsements import Mastodon as MastoEndorsements
|
|
48
|
+
from mastodon.relationships import Mastodon as MastoRelationships
|
|
49
|
+
from mastodon.lists import Mastodon as MastoLists
|
|
50
|
+
from mastodon.trends import Mastodon as MastoTrends
|
|
51
|
+
from mastodon.search import Mastodon as MastoSearch
|
|
52
|
+
from mastodon.favourites import Mastodon as MastoFavourites
|
|
53
|
+
from mastodon.reports import Mastodon as MastoReports
|
|
54
|
+
from mastodon.preferences import Mastodon as MastoPreferences
|
|
55
|
+
from mastodon.push import Mastodon as MastoPush
|
|
56
|
+
from mastodon.admin import Mastodon as MastoAdmin
|
|
57
|
+
from mastodon.streaming_endpoints import Mastodon as MastoStreaming
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
###
|
|
61
|
+
# The actual Mastodon class
|
|
62
|
+
#
|
|
63
|
+
# Almost all code is now imported from smaller files to make editing a bit more pleasant
|
|
64
|
+
###
|
|
65
|
+
class Mastodon(MastoUtility, MastoAuthentication, MastoAccounts, MastoInstance, MastoTimeline, MastoStatuses, MastoPolls, MastoNotifications, MastoHashtags,
|
|
66
|
+
MastoFilters, MastoSuggestions, MastoEndorsements, MastoRelationships, MastoLists, MastoTrends, MastoSearch, MastoFavourites, MastoReports,
|
|
67
|
+
MastoPreferences, MastoPush, MastoAdmin, MastoConversations, MastoMedia, MastoStreaming):
|
|
68
|
+
"""
|
|
69
|
+
Thorough and easy to use Mastodon
|
|
70
|
+
API wrapper in Python.
|
|
71
|
+
|
|
72
|
+
Main class, imports most things from modules
|
|
73
|
+
"""
|
|
74
|
+
# Support level
|
|
75
|
+
__SUPPORTED_MASTODON_VERSION = "4.3.0"
|
|
76
|
+
__MASTODON_PY_VERSION = "2.0.0"
|
|
77
|
+
|
|
78
|
+
@staticmethod
|
|
79
|
+
def get_supported_version() -> str:
|
|
80
|
+
"""
|
|
81
|
+
Retrieve the maximum version of Mastodon supported by this version of Mastodon.py
|
|
82
|
+
"""
|
|
83
|
+
return Mastodon.__SUPPORTED_MASTODON_VERSION
|
mastodon/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from mastodon.Mastodon import Mastodon, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError, MastodonServerError, MastodonInternalServerError, MastodonBadGatewayError, MastodonServiceUnavailableError, MastodonGatewayTimeoutError
|
|
2
|
+
from mastodon.streaming import StreamListener, CallbackStreamListener
|
|
3
|
+
from mastodon.types_base import AttribAccessDict
|
|
4
|
+
|
|
5
|
+
__all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError',
|
|
6
|
+
'MastodonServerError', 'MastodonInternalServerError', 'MastodonBadGatewayError', 'MastodonServiceUnavailableError', 'MastodonGatewayTimeoutError']
|