A python to scratch API connector. Can fetch data from the API and send it back in cloud variables.

Overview

Scratch2py

Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of scratchclient by Raihan142857

Installation

Use your terminal and run these command to install Scratch2py and websocket Then, import the module into your python file like this:

pip install scratch2py
pip uninstall websocket-client
pip install websocket-client
import scratch2py
s2py = scratch2py.s2py('username', 'password')
# Imports s2py and initializes a new s2py object. Enter your Scratch MIT credentials to create a connection with the API.

Usage

How to use S2py

Projects

Using the module for projects

s2py.getStats('id', 'stat')
# Gets the stats of a project. First input is the project ID, the second one is what stat you want (Loves, faves, views or remixes)
s2py.getProjectComments('id')
# Gets the comments of a project based on the project ID. Data returned in JSON.
s2py.postProjectComments('Project id','content','parent id(Optional)','commentee id(optional)')
# Posts a project based on the project id and content. Parent ID is the Id of the comment for replying. Commentee ID is your user ID.

Studios

Using the module for a studio

s2py.getStudioComments('id')
# Gets the comments of a studio based on the ID.
s2py.postStudioComments('studio id','content','parent id','commentee id')
# Posts a comment on a studio. (See s2py.postProjectComments for param ^)
s2py.followStudio('studio id')
# Follows a studio based on the ID.
s2py.unfollowStudio('Studio id')
# Unfollows a studio based on the ID.
s2py.inviteCurator('studio id','username')
# Invites someone to a studio.

User

Using the module for getting user data

s2py.getUserStatus('user')
# Gets the 'about me' section of a users.
s2py.getUserBio('user')
# Gets the 'What I'm Working On' section of a users profile.
s2py.getUserFollowerCount('user')
# Gets the number of followers for a user
s2py.getUserMessagesCount('user')
# Gets the number of messages someone has.
s2py.checkUserExists('user')
# Checks if a user exists. Returns true or false
s2py.getProjects('user')
# Gets the titles and project IDs of a user.
s2py.love('project id')
# Loves a project based on the ID.
s2py.unlove('project id')
# Unloves a project based on the ID.
s2py.favorite('project id')
# Favorites a project based on the ID.
s2py.unfavorite('project id')
# Unfavorites a project based on the ID.
s2py.followUser('name')
# Follows a user based on the username.
s2py.unfollowUser('name')
# Unfollows a user based on the username.
s2py.toggleCommenting()
# Toggles comments for your profile.
s2py.postProfileComment('User','content', 'parent_id(optional)','commentee_id(optional)')
# See s2py.postStudioComment for param info. Enter the username and the content to post a comment on a profile.
s2py.getMessages()
# Gets your messages and returns the JSON.

Forums

s2py.followPost(postid)
# Follows a post based on the post ID.
s2py.unfollowPost(postid)
# Unfollows a post based on the post ID.

Cloud

Using the module for cloud.

s2py.cloudConnect('Project ID')
# Starts a cloud connection to a specific project
s2py.setCloudVar('CloudVar', 'Value')
# Sets a value to a cloud variable. Don't add the cloud symbol.
s2py.readCloudVar('variable name', 'Limit(optional)')
# Gets the value of a cloud variable. Limit is when the program should stop looking for the value. Limit is 1000 by default.
s2py.encode('value')
# Encodes a value. Scratch version available on my Scratch profile
s2py.decode('value')
# Decodes a value. To be used to communicate to and from a Scratch project.

The End

That's it! Contact my on my Scratch profile

Comments
  • Move functions to __init__.py and more

    Move functions to __init__.py and more

    What changed:

    • [x] Moved code to __init__.py, removing the need for main.py
    • [x] How modules are imported in __init__.py
    • [x] Installation section of README.md

    These are enhancements more than added functionality. Also, may I suggest using Codacy to find ways to clean up any potentially messy code?

    opened by themysticsavages 7
  • Encrypt decimal number.

    Encrypt decimal number.

    I'm trying to encrypt a number but I'm getting this error:

    Traceback (most recent call last): File "/Users/Me/Desktop/Coding_Files/Python Projects/WeatherApp/app2.py", line 58, in <module> project.setCloudVar("request", s2py.encode(weather[y])) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scratch2py/__init__.py", line 85, in encode text = text.lower() AttributeError: 'float' object has no attribute 'lower'

    I understand this is because I'm trying to encrypt a decimal number known as a float but I'm not sure what to do about it or if this can be fixed in scratch2py.

    bug 
    opened by ajsya 6
  • Don't use global

    Don't use global

    Inside scratch2py/main.py the Scratch2Py sets chars to be global. In the init function you could set chars using self.chars = "...". Inside the rest of the code, change chars to self.chars

    opened by ninjamar 6
  • Clean up imports and fix docs

    Clean up imports and fix docs

    I removed modules imported more than once in main.py, as well as removing exception catching for WebSocket initialization. In addition to that, I used the requirements.txt for installation in README.md.

    While it looks like I may be doing this again, the commits I made previously did not merge. That's why I'm doing it again.

    opened by themysticsavages 6
  • Create an option to ask questions on your Scratch account

    Create an option to ask questions on your Scratch account

    I've created a file that displays a link to your (@The-Cloud-Dev ) Scratch profile, which shows up when creating a new issue. You can read more about issue templates here.

    opened by FuchsCrafter 4
  • Permission issues with the log module on Linux

    Permission issues with the log module on Linux

    So recently, there is an issue with the log output, that denies the programm to access the logfile if executed as a non-administrative user. Im still searching for a solution on my own and will inform you if I found a solution. For now, I can just run the script as a root. I understand that this bug is maybe not caused by Scratch2Py and may not affect Windows or MacOS.

    opened by FuchsCrafter 4
  • The name

    The name

    Do you think my project (Scratch2Python) would get confused with your project? If you think so, I'll ask the Scratch forums for a better name for the full release.

    opened by Secret-chest 3
  • Did some things

    Did some things

    • Added type hinting
    • Added docstrings to every function (excluding underscore functions)
    • Improved some functions like user.getProjects()
    • small changes to readme
    • some functions now raise exceptions when an error occurs instead of returning a string

    Some other functions could be improved like using list comprehension instead of a for loop but i left those alone :)

    opened by themysticsavages 3
  • Problematic connections to clouddata.turbowarp.org

    Problematic connections to clouddata.turbowarp.org

    Recently there's been a lot of messages in clouddata.turbowarp.org's logs about connections being closed with Error: Unknown message method: get (code 4000). I don't know exactly why a bunch of those have started appearing, but a GitHub code search has led me to this repository.

    https://github.com/The-Cloud-Dev/scratch2py/blob/50fe60cad38c3955d6a3bf68138a50721429f41e/scratch2py/init.py#L791-L804

    get is not a valid method. Connections that send that to clouddata.turbowarp.org will be closed because the server doesn't know how to handle it. The proper way to get a variable is to open a single connection and listen to the messages that the server sends you to record the most recent value on your own. That way you can look up the most recent value whenever you want without asking the server. If your current code works, then that's only a lucky coincidence because of other bugs in your code. There is a high probability that it will break in the future.

    I suspect that this broken logic in this library may be responsible for nearly 400,000 (four hundred thousand) unnecessary short lived connections to clouddata.turbowarp.org per day. I do not appreciate this level of spam and may consider outright blocking users that continue to make these connections, which may or may not affect you and/or users of this library.

    opened by GarboMuffin 3
  • The vercel app has an 404 error

    The vercel app has an 404 error

    Nothing much to say here

    Oh and @themysticsavages the vercel app is 404 rn

    Originally posted by @FuchsCrafter in https://github.com/The-Cloud-Dev/scratch2py/issues/9#issuecomment-1001005669

    opened by FuchsCrafter 2
  • Add the cloud class

    Add the cloud class

    I've added the cloud class, so you can manage multiple Cloud acces at once. This is also easier to understand/read. Old: s2py.cloudConnect("PID") cloudData = s2py.readCloudVar("variableName") New: cloudProject = s2py.cloud("PID") cloudData = cloudProject.readCloudVar("variableName")

    ATTENTION! MERGING THIS CAN CAUSE INCOMPITABILITY!

    opened by FuchsCrafter 2
  • Add a wiki!

    Add a wiki!

    What about adding a wiki? The documentation can go there and you can browse the documentation on the sidebar. You can also search in a Github wiki.

    • [ ] Add a wiki
    • [ ] set up the main wiki page
    documentation 
    opened by FuchsCrafter 20
Releases(V0.7.1)
Reddit cli to slack at work

Reddit CLI (v1.0) Introduction Why Reddit CLI? Coworker who sees me looking at something in a browser: "Glad you're not busy; I need you to do this, t

3 Jun 22, 2021
A Bot that Forwards Tweets to Telegram using Airtable as a database.

Twitter Telegram Forward A Bot that Forwards Tweets to Telegram using Airtable as a Database. Features: Handles multiple twitter and telegram channels

George Bakev 3 Dec 21, 2022
An Async Bot/API wrapper for Twitch made in Python.

TwitchIO is an asynchronous Python wrapper around the Twitch API and IRC, with a powerful command extension for creating Twitch Chat Bots. TwitchIO co

TwitchIO 590 Jan 03, 2023
Simple software that can send WhatsApp message to a single or multiple users (including unsaved number**)

wp-automation Info: this is a simple automation software that sends WhatsApp message to single or multiple users. Key feature: -Sends message to multi

3 Jan 31, 2022
An Unofficial TikTok API Wrapper In Python

This is an unofficial api wrapper for TikTok.com in python. With this api you are able to call most trending and fetch specific user information as well as much more.

David Teather 2.9k Jan 08, 2023
Schedule Twitter updates with easy

coo: schedule Twitter updates with easy Coo is an easy to use Python library for scheduling Twitter updates. To use it, you need to first apply for a

wilfredinni 46 Nov 03, 2022
Project to list all resources in an AWS account with tags.

AWS-ListAll Project to list all resources in an AWS account with tags. This script works on any system Get started: Install python3 and pip3 along wit

Connor Shubham Verlekar 3 Jan 30, 2022
Stinky ID - A stable pluggable Telegram userbot + Voice & Video Call music bot, based on Telethon

Ultroid - UserBot A stable pluggable Telegram userbot + Voice & Video Call music

Riyan.rz 1 Jan 03, 2022
A muti pairs martingle trading bot for Binance exchange.

multi_pairs_martingle_bot English Documentation A muti pairs martingle trading bot for Binance exchange. Configuration { "platform": "binance_futur

51bitquant 62 Nov 16, 2022
Fully automated Chegg Discord bot for "homework help"

cheggbog Fully automated Chegg Discord bot for "homework help". Working Sept 15, 2021 Overview Recently, Chegg has made it extremely difficult to auto

Bryce Hackel 8 Dec 23, 2022
a harbinger of events or things.

Herald: Intrusion Detection System using IR and ML Herald - noun; a harbinger of events or things. Overview Herald is an intrusion detection system us

Muhammad Muzzammil 4 Jun 07, 2021
Python based Discord Bot with a simple music player

C32 Discord Bot Discord bot that plays music Table Of Contents About the Project Built With Acknowledgements About The Project Play music using the !p

Christopher Burwell 2 Oct 17, 2021
A Powerful telegram giveawayz bot based on the python-telegram-bot API

GiveawayZ Bot A Powerful telegram giveawayz bot based on the python-telegram-bot API. Powered by Team Zyntax and Team DFX Developed by @Zycho-Dev A pr

Zycho #AFK 5 Jul 31, 2022
GUI Pancakeswap V2 and Uniswap V3 trading client (and bot) MOST ADVANCE TRADING BOT SUPPORT WINDOWS LINUX MAC (BUY TOKEN ON LAUNCH)

GUI Pancakeswap 2 and Uniswap 3 SNIPER BOT 🏆 🥇 (MOST ADVANCE TRADING BOT SUPPORT WINDOWS LINUX MAC) (AUTO BUY TOKEN ON LAUNCH AFTER ADD LIQUIDITY) S

HYDRA 16 Dec 22, 2021
Confirm that files have been uploaded to Backblaze Cloud Backup successfully

Backblaze Backup Checker This Python script compares metadata captured from files within source folders against data parsed from Backblaze Cloud Backu

18 Jul 29, 2022
5 Oct 19, 2022
A custom discord bot maker in python

custom-discord-bot-maker Sorry for using Translator. Each description may be inaccurate. how to use 1. Make new application at https://discord.com/dev

2 Nov 29, 2021
A discord bot with a leveling system (similar to mee6).

Discord.py A discord bot with a leveling system (like mee6) Pre-requisites Knowing how to get create an app/bot via discord's developer portal. Websit

26 Dec 11, 2022
A simple Python wrapper for the archive.is capturing service

archiveis A simple Python wrapper for the archive.is capturing service. Installation pipenv install archiveis Python Usage Import it. import archi

Ben Welsh 157 Dec 28, 2022
Pluggable Telethon - Telegram UserBot

A stable pluggable Telegram userbot, based on Telethon.

Team Ultroid 2.3k Dec 30, 2022