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)
Very Sempil Bot Auto Filter bot

SAMANTHA_BOT Very Sempil Bot Auto Filter bot ##[ # π‚π‹πˆπ‚πŠ ππ„π‹πŽπ– πˆπŒπ€π†π„ π“πŽ πƒπ„ππ‹πŽπ˜ πŸ‘‡ πŸ‘‡ πŸ‘‡ Auto Filter Manuel Filter IMDB Admin Co

DARK WEBLOAD 3 Jun 27, 2022
Automate coin farming for dankmemer. Unlimited accounts at once. Uses a proxy

dankmemer-farm Simple script to farm Dankmemer coins with multiple accounts at once. Requires: Proxies, Discord Tokens Disclaimer I don't take respons

Scobra 12 Dec 20, 2022
A python client for the Software-Challenge Germany.

sc-client-python A python client for the Software-Challenge Germany. Creating a new project (Optional) Install virtualenv virtualenv is a tool that cr

rpkak 3 Jan 22, 2022
A simple telegram bot that resolves video urls using yt-dlp

URL to Video Telegram Bot A simple telegram bot that resolves video urls using yt-dlp Copyright (C) 2021 VΓ­tor Vasconcellos This program is free softw

VΓ­tor 1 Nov 18, 2021
Threat Intel Platform for T-POTs

T-Pot 20.06 runs on Debian (Stable), is based heavily on docker, docker-compose

Deutsche Telekom Security GmbH 4.3k Jan 07, 2023
🦊 Powerfull Discord Nitro Generator

🦊 Follow me here 🦊 Discord | YouTube | Github β˜• Usage πŸ’» Downloading git clone https://github.com/KanekiWeb/Nitro-Generator/new/main pip insta

Kaneki 104 Jan 02, 2023
A nuker for Roblox accounts.

Roblox-Nuker A nuker for Roblox accounts. Made by Ice Bear#0167 Usage I would recommend running in replit (https://replit.com) as it is deprecated in

7 May 10, 2022
Automatically send commands to send Twitch followers to any Twitch account.

Automatically send commands to send Twitch followers to any Twitch account. You just need to be in a Twitch follow bot Discord server!

Thomas Keig 6 Nov 27, 2022
1 Feb 18, 2022
Spacecrypto-bot - SpaceCrypto Bot Auto Clicker

SpaceCrypto Auto Clicker Bot TambΓ©m fiz um para Luna Rush ( https://github.com/w

Walter Discher Cechinel 5 Feb 22, 2022
C Y B Ξ R UserBot is a project that simplifies the use of Telegram.

C Y B Ξ R USΞRBOT πŸ‡¦πŸ‡Ώ C Y B Ξ R UserBot is a project that simplifies the use of Telegram. All rights reserved. Automatic Setup Android: open Termux p

FVREED 4 Dec 07, 2022
Bin Checker with Aiogram, Telegram

Bin Checker with Aiogram, Telegram

JEFF 1 Aug 16, 2022
Super simple anti-spam Discord bot

AutoAntiRaidBot Super simple anti-spam Discord bot. Will automatically kick any member with an account made under 1 day ago, and will ban any member w

Kainoa Kanter 6 Jun 27, 2022
Media Replay Engine (MRE) is a framework to build automated video clipping and replay (highlight) generation pipelines for live and video-on-demand content.

Media Replay Engine (MRE) is a framework for building automated video clipping and replay (highlight) generation pipelines using AWS services for live

Amazon Web Services - Labs 30 Nov 29, 2022
Finds Jobs on LinkedIn using web-scraping

Find Jobs on LinkedIn πŸ“” This program finds jobs by scraping on LinkedIn πŸ‘¨β€πŸ’» Relies on User Input. Accepts: Country, City, State πŸ“‘ Data about jobs

Matt 44 Dec 27, 2022
Automatically gets clips from twitch streams and uploads them to a YouTube channel.

Twitch Stream Highlights to YT Automatic Uploader (AutoBot Clipper) This script can be used to automatically extract highlights (or clips) from a twit

Teja Swaroop 57 Dec 12, 2022
Python wrapper for Interactive Brokers Client Portal Web API

EasyIB: Unofficial Wrapper for Interactive Brokers API EasyIB is an unofficial python wrapper for Interactive Brokers Client Portal Web API. Features

39 Dec 13, 2022
Bot Auto Chess.com

Bot Auto Chess.com Is a suggestion for chess moves on the chess.com platform. The available features are: chess suggestions and moves automatically. i

Tn. Ninja 34 Jan 01, 2023
Netflix Movies and TV Series Downloader Tool including CDM L1 which you guys can Donwload 4K Movies

NFRipper2.0 I could not shared all the code here Because its has lots of files inisde it https://new.gdtot.me/file/86651844 - Downoad File From Here.

Kiran 15 May 06, 2022
A Rich renderable for viewing Multiple Sequence Alignments in the terminal.

rich-msa A simple module to render colorful Multiple Sequence Alignment with rich in the terminal. πŸ”§ Installing Install the rich-msa package directly

Martin Larralde 64 Dec 04, 2022