Skip to main content

A Python library for interacting with the scratch.mit.edu API

Project description

scratchcon

[!Note] Please suggest or make a pull request for any ideas you have

Requirements

pip install -r requrements.txt

How to use

First, run this command in your terminal (make sure you have a venv activated): python3 -m pip install scratchcon
Then create a python file and type:

import scratchcon as con

conn = con.conn.Connect()

This sets up the connection class, here are some things you can connect:

# Connect a project
conn.conect_project() # Enter the project ID as an integer

# Connect a studio
conn.connect_studio() # Enter a studio ID as an integer

# Connect a user
conn.connect_user() # Enter the username as a string

Here are some things you can do with the connect_project function:

project = con.project.Project()

project.get_title() # Returns the title of the project

project.get_description() # Returns the description of the project

project.get_instructions() # Returns the instructions of the project

project.get_author() # Returns the author of the project

project.get_author_id() # Returns the author's id

project.get_creation_date() # Returns the creation date of the project

project.get_share_date() # Returns the share date of the project

project.get_love_count() # Returns the love count of the project

project.get_view_count() # Returns the view count of the project

project.get_favorite_count() # Returns the favorite count of the project

project.get_remix_count() # Returns the remix count of the project

project.get_remixes() # Returns all the remixes of the project in a list

Here are some things you can do with the connect_studio function:

studio = con.studio.Studio()

studio.get_description() # Returns the description of the studio

studio.get_curators() # Returns a list of all the curators in the studio

studio.get_title() # Returns the title of the studio

studio.get_creation_date() # Returns the creation date of the studio

studio.get_project_amount() # Returns the amount of projects in the studio

studio.get_follower_amount() # Returns the amount of followers of the studio

studio.get_managers() # Returns a list of managers in the studio

studio.get_comment_amount() # Returns the amount of comments

studio.get_comments() # Returns a list of comments in the studio

studio.get_projects() # Returns a list of projects in the studio

studio.get_activity() # Returns a list of the activity in the studio

Here are some things you can do with the connect_user function

user = con.user.User()

user.get_status() # Returns the status of the user

user.get_message_count() # Returns the message count of the user

user.get_id() # Returns the ID of the user

user.get_bio() # Returns the bio of the user

user.get_country() # Returns the country of the user

user.get_username() # Returns the username of the user

user.get_join_date() # Returns the join date of the user

user.is_st() # Returns if the user is scratch team

scratchcon.actions

How to use

Type this into your python file

import scratchcon.actions as actions
actions.login.login("username", "password")

That logs into scratch, now here are some things you can connect:

# Project
actions.conn.connect_project() # Enter the project ID as an integer

# Studio
actions.conn.connect_studio() # Enter the Studio ID as an integer

# COMING SOON: User
actions.conn.connect_user() # Enter the username of the user

# Once connected you must use this function:
actions.actions.load() # This loads your set values 

Now here are some things you can do with the connect_project() method:

proj_actions = actions.actions.Project()

proj_actions.post_comment("message") # Post a comment

proj_actions.love() # Love the project

proj_actions.unlove() # Unlove the project

proj_actions.favorite() # Favorite the project

proj_actions.unfavorite() # Unfavorite the project

proj_actions.download("filename", "dir") # Download the project

Here are some things you can do with the connect_studio() method:

studio_actions = actions.actions.Studio()

studio_actions.follow() # Follow the studio

studio_actions.unfollow() # Unfollow the studio

studio_actions.post_comment("message") # Post a comment

studio_actions.remove("user") # Remove a user

studio_actions.add_project("project id") # Enter the project ID as an integer

studio_actions.invite("user") # Invite a user

studio_actions.promote("user") # Promote a user

scratchcon.utils

Authenticating a User

Type the following into your program:

import scratchcon.utils.auth as auth

project: int = 1234567890
authenticated, username = auth.authenticate_user(project_id=project)
print(f"{username} has authenticated")

And that's it, you have 2 minutes to comment the code on the project

Setting up a Filter Bot

Type the following into your program:

import scratchcon.utils.filterbot as filter
import scratchcon.actions as actions

project: int = 1234567890
actions.login.login("username", "password")

filterbot = filter.Filter(project, ["keywords that the bot will", "delete"])
# Don't feel like adding your own keywords? There are presets!
filterbot = filter.Filter(project, preset="mode")
# Replace "mode" with light, medium or hard
# Whenever you want to start it you just type
filterbot.start_filter()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scratchcon-1.3.4b0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

scratchcon-1.3.4b0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file scratchcon-1.3.4b0.tar.gz.

File metadata

  • Download URL: scratchcon-1.3.4b0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for scratchcon-1.3.4b0.tar.gz
Algorithm Hash digest
SHA256 cbe7be63a8ca12b79bfedfadff95f1672e659b59a9d3e26437dddfc5238220e7
MD5 3c7665dfd8e063cf0a0677fc4671238c
BLAKE2b-256 99fa397749a272f6093aee490b0d33a5a31c2d906735daad1a989476bc425b9e

See more details on using hashes here.

File details

Details for the file scratchcon-1.3.4b0-py3-none-any.whl.

File metadata

File hashes

Hashes for scratchcon-1.3.4b0-py3-none-any.whl
Algorithm Hash digest
SHA256 364766266c9bbc0895a66462ee6dc62aa389114a10b593e5ce07d5e9fc7e7655
MD5 8b8f8633f73c6ff2d7c688e6275cd0a9
BLAKE2b-256 78e101a6ffaf52536cca21befd2a0b09ae291404dd396571146ac369e1fd6850

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page