scratchattach 2.1.9__tar.gz → 2.1.10__tar.gz
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.
- {scratchattach-2.1.9 → scratchattach-2.1.10}/LICENSE +21 -21
- {scratchattach-2.1.9 → scratchattach-2.1.10}/PKG-INFO +155 -146
- {scratchattach-2.1.9 → scratchattach-2.1.10}/README.md +125 -125
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/__init__.py +29 -25
- scratchattach-2.1.10/scratchattach/cloud/__init__.py +2 -0
- scratchattach-2.1.10/scratchattach/cloud/_base.py +454 -0
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/cloud/cloud.py +171 -168
- scratchattach-2.1.10/scratchattach/editor/__init__.py +21 -0
- scratchattach-2.1.10/scratchattach/editor/asset.py +199 -0
- scratchattach-2.1.10/scratchattach/editor/backpack_json.py +117 -0
- scratchattach-2.1.10/scratchattach/editor/base.py +142 -0
- scratchattach-2.1.10/scratchattach/editor/block.py +507 -0
- scratchattach-2.1.10/scratchattach/editor/blockshape.py +353 -0
- scratchattach-2.1.10/scratchattach/editor/build_defaulting.py +47 -0
- scratchattach-2.1.10/scratchattach/editor/comment.py +74 -0
- scratchattach-2.1.10/scratchattach/editor/commons.py +243 -0
- scratchattach-2.1.10/scratchattach/editor/extension.py +43 -0
- scratchattach-2.1.10/scratchattach/editor/field.py +90 -0
- scratchattach-2.1.10/scratchattach/editor/inputs.py +132 -0
- scratchattach-2.1.10/scratchattach/editor/meta.py +106 -0
- scratchattach-2.1.10/scratchattach/editor/monitor.py +175 -0
- scratchattach-2.1.10/scratchattach/editor/mutation.py +317 -0
- scratchattach-2.1.10/scratchattach/editor/pallete.py +91 -0
- scratchattach-2.1.10/scratchattach/editor/prim.py +170 -0
- scratchattach-2.1.10/scratchattach/editor/project.py +273 -0
- scratchattach-2.1.10/scratchattach/editor/sbuild.py +2837 -0
- scratchattach-2.1.10/scratchattach/editor/sprite.py +586 -0
- scratchattach-2.1.10/scratchattach/editor/twconfig.py +113 -0
- scratchattach-2.1.10/scratchattach/editor/vlb.py +134 -0
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/_base.py +99 -92
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/cloud_events.py +110 -103
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/cloud_recorder.py +26 -21
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/cloud_requests.py +460 -452
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/cloud_server.py +246 -244
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/cloud_storage.py +135 -134
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/combine.py +29 -27
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/filterbot.py +160 -159
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/eventhandlers/message_events.py +41 -40
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/other/other_apis.py +284 -212
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/other/project_json_capabilities.py +475 -546
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/site/_base.py +65 -46
- scratchattach-2.1.10/scratchattach/site/activity.py +414 -0
- scratchattach-2.1.10/scratchattach/site/backpack_asset.py +118 -0
- scratchattach-2.1.10/scratchattach/site/browser_cookies.py +55 -0
- scratchattach-2.1.10/scratchattach/site/classroom.py +430 -0
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/site/cloud_activity.py +107 -103
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/site/comment.py +220 -190
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/site/forum.py +400 -399
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/site/project.py +804 -787
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/site/session.py +1144 -867
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/site/studio.py +611 -609
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/site/user.py +834 -837
- scratchattach-2.1.10/scratchattach/utils/commons.py +243 -0
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/utils/encoder.py +157 -156
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/utils/enums.py +197 -190
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/utils/exceptions.py +233 -206
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach/utils/requests.py +67 -59
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach.egg-info/PKG-INFO +155 -146
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach.egg-info/SOURCES.txt +25 -1
- {scratchattach-2.1.9 → scratchattach-2.1.10}/setup.cfg +4 -4
- {scratchattach-2.1.9 → scratchattach-2.1.10}/setup.py +2 -2
- scratchattach-2.1.10/tests/test_import.py +4 -0
- scratchattach-2.1.9/scratchattach/cloud/_base.py +0 -282
- scratchattach-2.1.9/scratchattach/site/activity.py +0 -122
- scratchattach-2.1.9/scratchattach/site/backpack_asset.py +0 -84
- scratchattach-2.1.9/scratchattach/site/classroom.py +0 -142
- scratchattach-2.1.9/scratchattach/utils/__init__.py +0 -0
- scratchattach-2.1.9/scratchattach/utils/commons.py +0 -148
- {scratchattach-2.1.9/scratchattach/cloud → scratchattach-2.1.10/scratchattach/eventhandlers}/__init__.py +0 -0
- {scratchattach-2.1.9/scratchattach/eventhandlers → scratchattach-2.1.10/scratchattach/other}/__init__.py +0 -0
- {scratchattach-2.1.9/scratchattach/other → scratchattach-2.1.10/scratchattach/site}/__init__.py +0 -0
- {scratchattach-2.1.9/scratchattach/site → scratchattach-2.1.10/scratchattach/utils}/__init__.py +0 -0
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach.egg-info/dependency_links.txt +0 -0
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach.egg-info/requires.txt +0 -0
- {scratchattach-2.1.9 → scratchattach-2.1.10}/scratchattach.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 TimMcCool (github user)
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 TimMcCool (github user)
|
|
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.
|
|
@@ -1,146 +1,155 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: scratchattach
|
|
3
|
-
Version: 2.1.
|
|
4
|
-
Summary: A Scratch API Wrapper
|
|
5
|
-
Home-page: https://scratchattach.tim1de.net
|
|
6
|
-
Author: TimMcCool
|
|
7
|
-
Author-email:
|
|
8
|
-
Keywords: scratch api,scratchattach,scratch api python,scratch python,scratch for python,scratch,scratch cloud,scratch cloud variables,scratch bot
|
|
9
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
-
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Operating System :: Unix
|
|
13
|
-
Classifier: Operating System :: MacOS :: MacOS X
|
|
14
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
License-File: LICENSE
|
|
17
|
-
Requires-Dist: websocket-client
|
|
18
|
-
Requires-Dist: requests
|
|
19
|
-
Requires-Dist: bs4
|
|
20
|
-
Requires-Dist: SimpleWebSocketServer
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- [
|
|
51
|
-
- [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
- [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```python
|
|
109
|
-
import scratchattach as sa
|
|
110
|
-
|
|
111
|
-
session = sa.
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**Cloud
|
|
124
|
-
|
|
125
|
-
```py
|
|
126
|
-
cloud = session.connect_cloud(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
events
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scratchattach
|
|
3
|
+
Version: 2.1.10
|
|
4
|
+
Summary: A Scratch API Wrapper
|
|
5
|
+
Home-page: https://scratchattach.tim1de.net
|
|
6
|
+
Author: TimMcCool
|
|
7
|
+
Author-email:
|
|
8
|
+
Keywords: scratch api,scratchattach,scratch api python,scratch python,scratch for python,scratch,scratch cloud,scratch cloud variables,scratch bot
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: Unix
|
|
13
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: websocket-client
|
|
18
|
+
Requires-Dist: requests
|
|
19
|
+
Requires-Dist: bs4
|
|
20
|
+
Requires-Dist: SimpleWebSocketServer
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: classifier
|
|
23
|
+
Dynamic: description
|
|
24
|
+
Dynamic: description-content-type
|
|
25
|
+
Dynamic: home-page
|
|
26
|
+
Dynamic: keywords
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
Dynamic: requires-dist
|
|
29
|
+
Dynamic: summary
|
|
30
|
+
|
|
31
|
+
**scratchattach is a Scratch API wrapper with support for almost all site features.** Created by [TimMcCool](https://scratch.mit.edu/users/TimMcCool/).
|
|
32
|
+
|
|
33
|
+
The library allows setting cloud variables, following users, updating your profile, and
|
|
34
|
+
so much more! Additionally, it provides frameworks that simplify sending data through cloud variables.
|
|
35
|
+
|
|
36
|
+
<p align="left" style="margin:10px">
|
|
37
|
+
<img width="160" src="https://raw.githubusercontent.com/TimMcCool/scratchattach/refs/heads/main/logos/logo.svg">
|
|
38
|
+
|
|
39
|
+
[](https://pypi.python.org/pypi/scratchattach/)
|
|
40
|
+
[](https://pypi.python.org/pypi/scratchattach/)
|
|
41
|
+
[](https://pypi.python.org/pypi/scratchattach/)
|
|
42
|
+
[](https://github.com/TimMcCool/scratchattach/blob/master/LICENSE)
|
|
43
|
+
[](https://scratchattach.readthedocs.io/en/latest/?badge=latest)
|
|
44
|
+
|
|
45
|
+
# Documentation
|
|
46
|
+
|
|
47
|
+
- **[Documentation](https://github.com/TimMcCool/scratchattach/wiki/Documentation)**
|
|
48
|
+
|
|
49
|
+
- [Cloud Variables](https://github.com/TimMcCool/scratchattach/wiki/Documentation#cloud-variables)
|
|
50
|
+
- [Cloud Requests](https://github.com/TimMcCool/scratchattach/wiki/Cloud-Requests)
|
|
51
|
+
- [Cloud Storage](https://github.com/TimMcCool/scratchattach/wiki/Cloud-Storage)
|
|
52
|
+
- [Filterbot](https://github.com/TimMcCool/scratchattach/wiki/Filterbot)
|
|
53
|
+
- [Self-hosting a TW cloud websocket](https://github.com/TimMcCool/scratchattach/wiki/Documentation#hosting-a-cloud-server)
|
|
54
|
+
|
|
55
|
+
# Helpful resources
|
|
56
|
+
|
|
57
|
+
- [Get your session id](https://github.com/TimMcCool/scratchattach/wiki/Get-your-session-id)
|
|
58
|
+
|
|
59
|
+
- [Examples](https://github.com/TimMcCool/scratchattach/wiki/Examples)
|
|
60
|
+
- [Hosting](https://github.com/TimMcCool/scratchattach/wiki/Hosting)
|
|
61
|
+
|
|
62
|
+
Report bugs by opening an issue on this repository. If you need help or guideance, leave a comment in the [official forum topic](https://scratch.mit.edu/discuss/topic/603418/
|
|
63
|
+
). Projects made using scratchattach can be added to [this Scratch studio](https://scratch.mit.edu/studios/31478892/).
|
|
64
|
+
|
|
65
|
+
# Helpful for contributors
|
|
66
|
+
|
|
67
|
+
- **[Structure of the library](https://github.com/TimMcCool/scratchattach/wiki/Structure-of-the-library)**
|
|
68
|
+
|
|
69
|
+
- [Extended documentation (WIP)](https://scratchattach.readthedocs.io/en/latest/)
|
|
70
|
+
|
|
71
|
+
- [Change log](https://github.com/TimMcCool/scratchattach/blob/main/CHANGELOG.md)
|
|
72
|
+
|
|
73
|
+
Contribute code by opening a pull request on this repository.
|
|
74
|
+
|
|
75
|
+
# ️Example usage
|
|
76
|
+
|
|
77
|
+
Set a cloud variable:
|
|
78
|
+
|
|
79
|
+
```py
|
|
80
|
+
import scratchattach as sa
|
|
81
|
+
|
|
82
|
+
session = sa.login("username", "password")
|
|
83
|
+
cloud = session.connect_cloud("project_id")
|
|
84
|
+
|
|
85
|
+
cloud.set_var("variable", value)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**[More examples](https://github.com/TimMcCool/scratchattach/wiki/Examples)**
|
|
89
|
+
|
|
90
|
+
# Getting started
|
|
91
|
+
|
|
92
|
+
**Installation:**
|
|
93
|
+
|
|
94
|
+
Run the following command in your command prompt / shell:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
pip install -U scratchattach
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
If this doesn't work, try running:
|
|
101
|
+
```
|
|
102
|
+
python -m pip install -U scratchattach
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
**Logging in with username / password:**
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
import scratchattach as sa
|
|
110
|
+
|
|
111
|
+
session = sa.login("username", "password")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`login()` returns a `Session` object that saves your login and can be used to connect objects like users, projects, clouds etc.
|
|
115
|
+
|
|
116
|
+
**Logging in with a sessionId:** *You can get your session id from your browser's cookies. [More information](https://github.com/TimMcCool/scratchattach/wiki/Get-your-session-id)*
|
|
117
|
+
```python
|
|
118
|
+
import scratchattach as sa
|
|
119
|
+
|
|
120
|
+
session = sa.login_by_id("sessionId", username="username") #The username field is case sensitive
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Cloud variables:**
|
|
124
|
+
|
|
125
|
+
```py
|
|
126
|
+
cloud = session.connect_cloud("project_id") # connect to the cloud
|
|
127
|
+
|
|
128
|
+
value = cloud.get_var("variable")
|
|
129
|
+
cloud.set_var("variable", "value") # the variable name is specified without the cloud emoji
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Cloud events:**
|
|
133
|
+
|
|
134
|
+
```py
|
|
135
|
+
cloud = session.connect_cloud('project_id')
|
|
136
|
+
events = cloud.events()
|
|
137
|
+
|
|
138
|
+
@events.event
|
|
139
|
+
def on_set(activity):
|
|
140
|
+
print("variable", activity.var, "was set to", activity.value)
|
|
141
|
+
events.start()
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Follow users, love their projects and comment:**
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
user = session.connect_user('username')
|
|
148
|
+
user.follow()
|
|
149
|
+
|
|
150
|
+
project = user.projects()[0]
|
|
151
|
+
project.love()
|
|
152
|
+
project.post_comment('Great project!')
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**All scratchattach features are documented in the [documentation](https://github.com/TimMcCool/scratchattach/wiki/Documentation).**
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
**scratchattach is a Scratch API wrapper with support for almost all site features.** Created by [TimMcCool](https://scratch.mit.edu/users/TimMcCool/).
|
|
2
|
-
|
|
3
|
-
The library allows setting cloud variables, following users, updating your profile, and
|
|
4
|
-
so much more! Additionally, it provides frameworks that simplify sending data through cloud variables.
|
|
5
|
-
|
|
6
|
-
<p align="left" style="margin:10px">
|
|
7
|
-
<img width="160" src="https://raw.githubusercontent.com/TimMcCool/scratchattach/refs/heads/main/logos/logo.svg">
|
|
8
|
-
|
|
9
|
-
[](https://pypi.python.org/pypi/scratchattach/)
|
|
10
|
-
[](https://pypi.python.org/pypi/scratchattach/)
|
|
11
|
-
[](https://pypi.python.org/pypi/scratchattach/)
|
|
12
|
-
[](https://github.com/TimMcCool/scratchattach/blob/master/LICENSE)
|
|
13
|
-
[](https://scratchattach.readthedocs.io/en/latest/?badge=latest)
|
|
14
|
-
|
|
15
|
-
# Documentation
|
|
16
|
-
|
|
17
|
-
- **[Documentation](https://github.com/TimMcCool/scratchattach/wiki/Documentation)**
|
|
18
|
-
|
|
19
|
-
- [Cloud Variables](https://github.com/TimMcCool/scratchattach/wiki/Documentation#cloud-variables)
|
|
20
|
-
- [Cloud Requests](https://github.com/TimMcCool/scratchattach/wiki/Cloud-Requests)
|
|
21
|
-
- [Cloud Storage](https://github.com/TimMcCool/scratchattach/wiki/Cloud-Storage)
|
|
22
|
-
- [Filterbot](https://github.com/TimMcCool/scratchattach/wiki/Filterbot)
|
|
23
|
-
- [Self-hosting a TW cloud websocket](https://github.com/TimMcCool/scratchattach/wiki/Documentation#hosting-a-cloud-server)
|
|
24
|
-
|
|
25
|
-
# Helpful resources
|
|
26
|
-
|
|
27
|
-
- [Get your session id](https://github.com/TimMcCool/scratchattach/wiki/Get-your-session-id)
|
|
28
|
-
|
|
29
|
-
- [Examples](https://github.com/TimMcCool/scratchattach/wiki/Examples)
|
|
30
|
-
- [Hosting](https://github.com/TimMcCool/scratchattach/wiki/Hosting)
|
|
31
|
-
|
|
32
|
-
Report bugs by opening an issue on this repository. If you need help or guideance, leave a comment in the [official forum topic](https://scratch.mit.edu/discuss/topic/603418/
|
|
33
|
-
). Projects made using scratchattach can be added to [this Scratch studio](https://scratch.mit.edu/studios/31478892/).
|
|
34
|
-
|
|
35
|
-
# Helpful for contributors
|
|
36
|
-
|
|
37
|
-
- **[Structure of the library](https://github.com/TimMcCool/scratchattach/wiki/Structure-of-the-library)**
|
|
38
|
-
|
|
39
|
-
- [Extended documentation (WIP)](https://scratchattach.readthedocs.io/en/latest/)
|
|
40
|
-
|
|
41
|
-
- [Change log](https://github.com/TimMcCool/scratchattach/blob/main/CHANGELOG.md)
|
|
42
|
-
|
|
43
|
-
Contribute code by opening a pull request on this repository.
|
|
44
|
-
|
|
45
|
-
# ️Example usage
|
|
46
|
-
|
|
47
|
-
Set a cloud variable:
|
|
48
|
-
|
|
49
|
-
```py
|
|
50
|
-
import scratchattach as sa
|
|
51
|
-
|
|
52
|
-
session = sa.login("username", "password")
|
|
53
|
-
cloud = session.connect_cloud("project_id")
|
|
54
|
-
|
|
55
|
-
cloud.set_var("variable", value)
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**[More examples](https://github.com/TimMcCool/scratchattach/wiki/Examples)**
|
|
59
|
-
|
|
60
|
-
# Getting started
|
|
61
|
-
|
|
62
|
-
**Installation:**
|
|
63
|
-
|
|
64
|
-
Run the following command in your command prompt / shell:
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
pip install -U scratchattach
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
If this doesn't work, try running:
|
|
71
|
-
```
|
|
72
|
-
python -m pip install -U scratchattach
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
**Logging in with username / password:**
|
|
77
|
-
|
|
78
|
-
```python
|
|
79
|
-
import scratchattach as sa
|
|
80
|
-
|
|
81
|
-
session = sa.login("username", "password")
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
`login()` returns a `Session` object that saves your login and can be used to connect objects like users, projects, clouds etc.
|
|
85
|
-
|
|
86
|
-
**Logging in with a sessionId:** *You can get your session id from your browser's cookies. [More information](https://github.com/TimMcCool/scratchattach/wiki/Get-your-session-id)*
|
|
87
|
-
```python
|
|
88
|
-
import scratchattach as sa
|
|
89
|
-
|
|
90
|
-
session = sa.login_by_id("sessionId", username="username") #The username field is case sensitive
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Cloud variables:**
|
|
94
|
-
|
|
95
|
-
```py
|
|
96
|
-
cloud = session.connect_cloud("project_id") # connect to the cloud
|
|
97
|
-
|
|
98
|
-
value = cloud.get_var("variable")
|
|
99
|
-
cloud.set_var("variable", "value") # the variable name is specified without the cloud emoji
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Cloud events:**
|
|
103
|
-
|
|
104
|
-
```py
|
|
105
|
-
cloud = session.connect_cloud('project_id')
|
|
106
|
-
events = cloud.events()
|
|
107
|
-
|
|
108
|
-
@events.event
|
|
109
|
-
def on_set(activity):
|
|
110
|
-
print("variable", activity.var, "was set to", activity.value)
|
|
111
|
-
events.start()
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Follow users, love their projects and comment:**
|
|
115
|
-
|
|
116
|
-
```python
|
|
117
|
-
user = session.connect_user('username')
|
|
118
|
-
user.follow()
|
|
119
|
-
|
|
120
|
-
project = user.projects()[0]
|
|
121
|
-
project.love()
|
|
122
|
-
project.post_comment('Great project!')
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
**All scratchattach features are documented in the [documentation](https://github.com/TimMcCool/scratchattach/wiki/Documentation).**
|
|
1
|
+
**scratchattach is a Scratch API wrapper with support for almost all site features.** Created by [TimMcCool](https://scratch.mit.edu/users/TimMcCool/).
|
|
2
|
+
|
|
3
|
+
The library allows setting cloud variables, following users, updating your profile, and
|
|
4
|
+
so much more! Additionally, it provides frameworks that simplify sending data through cloud variables.
|
|
5
|
+
|
|
6
|
+
<p align="left" style="margin:10px">
|
|
7
|
+
<img width="160" src="https://raw.githubusercontent.com/TimMcCool/scratchattach/refs/heads/main/logos/logo.svg">
|
|
8
|
+
|
|
9
|
+
[](https://pypi.python.org/pypi/scratchattach/)
|
|
10
|
+
[](https://pypi.python.org/pypi/scratchattach/)
|
|
11
|
+
[](https://pypi.python.org/pypi/scratchattach/)
|
|
12
|
+
[](https://github.com/TimMcCool/scratchattach/blob/master/LICENSE)
|
|
13
|
+
[](https://scratchattach.readthedocs.io/en/latest/?badge=latest)
|
|
14
|
+
|
|
15
|
+
# Documentation
|
|
16
|
+
|
|
17
|
+
- **[Documentation](https://github.com/TimMcCool/scratchattach/wiki/Documentation)**
|
|
18
|
+
|
|
19
|
+
- [Cloud Variables](https://github.com/TimMcCool/scratchattach/wiki/Documentation#cloud-variables)
|
|
20
|
+
- [Cloud Requests](https://github.com/TimMcCool/scratchattach/wiki/Cloud-Requests)
|
|
21
|
+
- [Cloud Storage](https://github.com/TimMcCool/scratchattach/wiki/Cloud-Storage)
|
|
22
|
+
- [Filterbot](https://github.com/TimMcCool/scratchattach/wiki/Filterbot)
|
|
23
|
+
- [Self-hosting a TW cloud websocket](https://github.com/TimMcCool/scratchattach/wiki/Documentation#hosting-a-cloud-server)
|
|
24
|
+
|
|
25
|
+
# Helpful resources
|
|
26
|
+
|
|
27
|
+
- [Get your session id](https://github.com/TimMcCool/scratchattach/wiki/Get-your-session-id)
|
|
28
|
+
|
|
29
|
+
- [Examples](https://github.com/TimMcCool/scratchattach/wiki/Examples)
|
|
30
|
+
- [Hosting](https://github.com/TimMcCool/scratchattach/wiki/Hosting)
|
|
31
|
+
|
|
32
|
+
Report bugs by opening an issue on this repository. If you need help or guideance, leave a comment in the [official forum topic](https://scratch.mit.edu/discuss/topic/603418/
|
|
33
|
+
). Projects made using scratchattach can be added to [this Scratch studio](https://scratch.mit.edu/studios/31478892/).
|
|
34
|
+
|
|
35
|
+
# Helpful for contributors
|
|
36
|
+
|
|
37
|
+
- **[Structure of the library](https://github.com/TimMcCool/scratchattach/wiki/Structure-of-the-library)**
|
|
38
|
+
|
|
39
|
+
- [Extended documentation (WIP)](https://scratchattach.readthedocs.io/en/latest/)
|
|
40
|
+
|
|
41
|
+
- [Change log](https://github.com/TimMcCool/scratchattach/blob/main/CHANGELOG.md)
|
|
42
|
+
|
|
43
|
+
Contribute code by opening a pull request on this repository.
|
|
44
|
+
|
|
45
|
+
# ️Example usage
|
|
46
|
+
|
|
47
|
+
Set a cloud variable:
|
|
48
|
+
|
|
49
|
+
```py
|
|
50
|
+
import scratchattach as sa
|
|
51
|
+
|
|
52
|
+
session = sa.login("username", "password")
|
|
53
|
+
cloud = session.connect_cloud("project_id")
|
|
54
|
+
|
|
55
|
+
cloud.set_var("variable", value)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**[More examples](https://github.com/TimMcCool/scratchattach/wiki/Examples)**
|
|
59
|
+
|
|
60
|
+
# Getting started
|
|
61
|
+
|
|
62
|
+
**Installation:**
|
|
63
|
+
|
|
64
|
+
Run the following command in your command prompt / shell:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
pip install -U scratchattach
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
If this doesn't work, try running:
|
|
71
|
+
```
|
|
72
|
+
python -m pip install -U scratchattach
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
**Logging in with username / password:**
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import scratchattach as sa
|
|
80
|
+
|
|
81
|
+
session = sa.login("username", "password")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`login()` returns a `Session` object that saves your login and can be used to connect objects like users, projects, clouds etc.
|
|
85
|
+
|
|
86
|
+
**Logging in with a sessionId:** *You can get your session id from your browser's cookies. [More information](https://github.com/TimMcCool/scratchattach/wiki/Get-your-session-id)*
|
|
87
|
+
```python
|
|
88
|
+
import scratchattach as sa
|
|
89
|
+
|
|
90
|
+
session = sa.login_by_id("sessionId", username="username") #The username field is case sensitive
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Cloud variables:**
|
|
94
|
+
|
|
95
|
+
```py
|
|
96
|
+
cloud = session.connect_cloud("project_id") # connect to the cloud
|
|
97
|
+
|
|
98
|
+
value = cloud.get_var("variable")
|
|
99
|
+
cloud.set_var("variable", "value") # the variable name is specified without the cloud emoji
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Cloud events:**
|
|
103
|
+
|
|
104
|
+
```py
|
|
105
|
+
cloud = session.connect_cloud('project_id')
|
|
106
|
+
events = cloud.events()
|
|
107
|
+
|
|
108
|
+
@events.event
|
|
109
|
+
def on_set(activity):
|
|
110
|
+
print("variable", activity.var, "was set to", activity.value)
|
|
111
|
+
events.start()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Follow users, love their projects and comment:**
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
user = session.connect_user('username')
|
|
118
|
+
user.follow()
|
|
119
|
+
|
|
120
|
+
project = user.projects()[0]
|
|
121
|
+
project.love()
|
|
122
|
+
project.post_comment('Great project!')
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**All scratchattach features are documented in the [documentation](https://github.com/TimMcCool/scratchattach/wiki/Documentation).**
|