Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scratchattach/other/other_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from ..utils import commons
from ..utils.requests import Requests as requests
import json

# --- Front page ---

Expand Down Expand Up @@ -99,4 +100,4 @@ def aprilfools_get_counter() -> int:
return requests.get("https://api.scratch.mit.edu/surprise")["surprise"]

def aprilfools_increment_counter() -> int:
return requests.post("https://api.scratch.mit.edu/surprise")["surprise"]
return requests.post("https://api.scratch.mit.edu/surprise")["surprise"]
4 changes: 2 additions & 2 deletions scratchattach/site/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def download(self, *, filename=None, dir=""):
f"https://projects.scratch.mit.edu/{self.id}?token={self.project_token}",
timeout=10,
)
filename = filename.replace(".sb3", "")
open(f"{dir}{filename}.sb3", "wb").write(response.content)
filename = filename.replace(".json", "")
open(f"{dir}{filename}.json", "wb").write(response.content)
except Exception:
raise (
exceptions.FetchError(
Expand Down
8 changes: 4 additions & 4 deletions scratchattach/site/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def create_project(self, *, title=None, project_json=empty_project_json, parent_

Warning:
Don't spam this method - it WILL get you banned from Scratch.
To prevendfvt accidental spam, a rate limit (5 projects per minute) is implemented for this function.
To prevent accidental spam, a rate limit (5 projects per minute) is implemented for this function.
"""
global CREATE_PROJECT_USES
if len(CREATE_PROJECT_USES) < 5:
Expand Down Expand Up @@ -536,7 +536,7 @@ def _make_linked_object(self, identificator_name, identificator, Class, NotFound
return commons._get_object(identificator_name, identificator, Class, NotFoundException, self)


def connect_user(self, username):
def connect_user(self, username) -> 'user.User':
"""
Gets a user using this session, connects the session to the User object to allow authenticated actions

Expand Down Expand Up @@ -717,7 +717,7 @@ def connect_filterbot(self, *, log_deletions=True):

# ------ #

def login_by_id(session_id, *, username=None, password=None, xtoken=None):
def login_by_id(session_id, *, username=None, password=None, xtoken=None) -> Session:
"""
Creates a session / log in to the Scratch website with the specified session id.
Structured similarly to Session._connect_object method.
Expand Down Expand Up @@ -754,7 +754,7 @@ def login_by_id(session_id, *, username=None, password=None, xtoken=None):
print(f"Warning: Logged in by id, but couldn't fetch session info. This won't affect any other features.")
return _session

def login(username, password, *, timeout=10):
def login(username, password, *, timeout=10) -> Session:
"""
Creates a session / log in to the Scratch website with the specified username and password.

Expand Down