Sets fields. By default, ueses the api.scratch.mit.edu/projects/xxx/ PUT API. Keyword Arguments: use_site_api (bool): When enabled, the fields are set using the scratch.mit.edu/site-api API. This function allows setting more fields than Project.set_f
(self, fields_dict, *, use_site_api=False)
| 566 | ) |
| 567 | |
| 568 | def set_fields(self, fields_dict, *, use_site_api=False): |
| 569 | """ |
| 570 | Sets fields. By default, ueses the api.scratch.mit.edu/projects/xxx/ PUT API. |
| 571 | |
| 572 | Keyword Arguments: |
| 573 | use_site_api (bool): |
| 574 | When enabled, the fields are set using the scratch.mit.edu/site-api API. |
| 575 | This function allows setting more fields than Project.set_fields. |
| 576 | For example, you can also share / unshare the project by setting the "shared" field. |
| 577 | According to the Scratch team, this API is deprecated. As of 2024 it's still fully functional though. |
| 578 | """ |
| 579 | self._assert_permission() |
| 580 | if use_site_api: |
| 581 | r = requests.put( |
| 582 | f"https://scratch.mit.edu/site-api/projects/all/{self.id}", |
| 583 | headers=self._headers, |
| 584 | cookies=self._cookies, |
| 585 | json=fields_dict, |
| 586 | ).json() |
| 587 | else: |
| 588 | r = requests.put( |
| 589 | f"https://api.scratch.mit.edu/projects/{self.id}", |
| 590 | headers=self._headers, |
| 591 | cookies=self._cookies, |
| 592 | json=fields_dict, |
| 593 | ).json() |
| 594 | return self._update_from_dict(r) |
| 595 | |
| 596 | def turn_off_commenting(self): |
| 597 | """ |
no test coverage detected