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)
Decrypt PSSE layer of PSM Games (on PC)

psse-decrypt Decrypt PSSE layer of PSM Games (on PC) Works on Unity and PSM games, and meets all requirements of: https://github.com/vita-nuova/bounti

Bluzume 32 Oct 11, 2022
Python SDK for IEX Cloud

iexfinance Python SDK for IEX Cloud. Architecture mirrors that of the IEX Cloud API (and its documentation). An easy-to-use toolkit to obtain data for

Addison Lynch 640 Jan 07, 2023
Telegram bot for making Heroku app.json by @AbirHasan2005

Heroku-app.json A Telegram bot for making Heroku app.json by @AbirHasan2005. Demo Bot Host Bot Deploy to Heroku Click Below Button to Deploy to Heroku

Abir Hasan 46 Nov 13, 2022
Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

Phish.AI 168 May 17, 2022
Python binding to the OneTimeSecret API

Thin Python binding for onetimesecret.com API. Unicode-safe. Description of API itself you can find here: https://onetimesecret.com/docs/api Usage:

Vladislav Stepanov 10 Jun 12, 2022
Instagram story report with python

instagram-story-report Mass reports a victim stories. Made for fun, but can be used for chaos Single session and multi session support Login, choose a

Joshua Solo 8 May 08, 2022
WhatsApp API Python ChatBot

WhatsApp Api Python - Esta documentação tem como objetivo exemplificar o uso do Moorse Whatsapp API na linguagem Python.

Douglas Alves 2 Jan 06, 2022
This bot will automatically like and follow users that post under a specified hashtag

Instagram-bot This bot will automatically like and follow users that post under a specified hashtag Dependencies Java JDK Selenium Updated version of

Makana Edwards 1 Nov 04, 2021
Activate exitlag trial accounts

Exitlag Account Activator Activate exitlag trial accounts (unlimited trial accounts) ⭐ If you want to support me, follow me on github and star the pro

Benjamin 173 Nov 10, 2022
StringSessionGenerator - A Telegram bot to generate pyrogram and telethon string session

⭐️ String Session Generator ⭐️ Genrate String Session Using this bot. Made by TeamUltronX 🔥 String Session Demo Bot: Environment Variables Mandatory

TheUltronX 1 Dec 31, 2021
The smart farm is an idea that designing Smart Farm by IoT

The smart farm is an idea that designing Smart Farm by IoT. Using Raspberry Pi 4 detect the data from different sensors(Raindrop sensor and DHT22 sensor), and push the data to Azure IoT central.

Jiage 1 Jan 11, 2022
8300-account-nuker - A simple accoutn nuker or can use it full closing dm and leaving server

8300 ACCOUNT NUKER VERISON: its just simple accoutn nuker or can use it full clo

†† 5 Jan 26, 2022
Automatically changes your discord status

Automatically changes your discord status, Be careful as this may get you rate limited and banned

octo 5 Sep 20, 2022
discord vc exploit to lightly lag vcs

discord-vc-reconnector discord vc exploit to lag vcs how to use open the py file, then open devtools on discord, go to network and join a vc, dont sta

Tesco 30 Aug 09, 2022
Light weight Scripts and Apps for checking availability of Covid Vaccines in India. Notifies when vaccine becomes avialable in your area.

vaccine-checker Light weight Scripts and Apps for checking availability of Covid Vaccines in India. Notifies when vaccine becomes avialable in your ar

Abishek V Ashok 8 Jun 16, 2021
WIOpy - Walmart Affiliate API Python wrapper

WalmartIO Python Wrapper - WIOpy A python wrapper for the Walmart io API. Only s

6 Nov 14, 2022
Telegram bot for searching videos in your PDisk account by @AbirHasan2005

PDisk-Videos-Search A Telegram bot for searching videos in your PDisk account by @AbirHasan2005. Configs API_ID - Get from @TeleORG_Bot API_HASH - Get

Abir Hasan 39 Oct 21, 2022
A code that can make an account bump your discord server 24/7!

BumpCord A code that can make an account bump your discord server 24/7! The main.py is the main file. keep_alive.py prevents your repl from going to s

Phantom 28 Aug 20, 2022
Python client and module for BGP Ranking

Python client and module for BGP Ranking THis project will make querying BGP Ranking easier. Installation pip install pybgpranking Usage Command line

D4 project 3 Dec 16, 2021
Experimental bridges between Telegram calls and other platforms.

Bridges by Calls Music Experimental bridges between Telegram calls and other platforms. Current bridges Bridge 1 (YouTube, Twitch, Facebook, etc...) B

Calls Music 14 Oct 08, 2022