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)
Owner
null
A robust, low-level connector for the Discord API

Bauxite Bauxite is a robust, low-level connector for the Discord API. What is Bauxite for? Bauxite is made for two main purposes: Creating higher-leve

null 1 Dec 4, 2021
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
Telegram PHub Bot using ARQ Api and Pyrogram. This Bot can Download and Send PHub HQ videos in Telegram using ARQ API.

Tg_PHub_Bot Telegram PHub Bot using ARQ Api and Pyrogram. This Bot can Download and Send PHub HQ videos in Telegram using ARQ API. OS Support All linu

TheProgrammerCat 13 Oct 21, 2022
:snake: A simple library to fetch data from the iTunes Store API made for Python >= 3.5

itunespy itunespy is a simple library to fetch data from the iTunes Store API made for Python 3.5 and beyond. Important: Since version 1.6 itunespy no

Fran González 56 Dec 22, 2022
A simple Discord bot that can fetch definitions and post them in chat.

A simple Discord bot that can fetch definitions and post them in chat. If you are connected to a voice channel, the bot will also read out the definition to you.

Tycho Bellers 4 Sep 29, 2022
The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id

Bot Hadith-API on Telegram The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id Built With Python Asynchronous HTTP protocol client

xMan 12 Feb 19, 2022
Cloud-native, data onboarding architecture for the Google Cloud Public Datasets program

Public Datasets Pipelines Cloud-native, data pipeline architecture for onboarding datasets to the Google Cloud Public Datasets Program. Overview Requi

Google Cloud Platform 109 Dec 30, 2022
Fetch fund data from avanza.se using Python and some web scraping with bs4

Py(A)vanza Fetch fund data from avanza.se using Python and some web scraping with bs4. The default way is to display the data in the terminal, apply -

dunderrrrrr 1 Jan 27, 2022
A python library built on the API of the coderHub.sa, which helps you to fetch the challenges and more

coderHub A python library built on the API of the coderHub.sa, which helps you to fetch the challenges and more Installation • Features • Usage • Lice

TheAwiteb 5 Nov 4, 2022
Picot - A discord bot made to fetch images from Pexels and unsplash API and provide raw images directly in channels

Picot A discord bot made to fetch images from Pexels and unsplash API and provid

Ayush Chandwani 5 Jan 12, 2022
A Simple modular tool to fetch and parse data related to the stock market.

?? stonks-o-fetcher A Simple modular tool to fetch and parse data related to the stock market. Getting started For the moment the only source is this

Daniele 23 May 31, 2021
Prisma Cloud utility scripts, and a Python SDK for Prisma Cloud APIs.

pcs-toolbox Prisma Cloud utility scripts, and a Python SDK for Prisma Cloud APIs. Table of Contents Support Setup Configuration Script Usage CSPM Scri

Palo Alto Networks 34 Dec 15, 2022
A python telegram bot to fetch the details of an ipadress with help of ip-api

ipfetcher A python(Pyrogram) oriented telegram bot to fetch the details of an ipadress developed by @riz4d with the API of https://ip-api.com Deployme

Mohamed Rizad 5 Mar 12, 2022
Maubot azuracast - A maubot to fetch data from your radio station

Maubot Azuracast A maubot to fetch data from your radio station Setup Configure

null 3 Mar 14, 2022
Python client for using Prefect Cloud with Saturn Cloud

prefect-saturn prefect-saturn is a Python package that makes it easy to run Prefect Cloud flows on a Dask cluster with Saturn Cloud. For a detailed tu

Saturn Cloud 15 Dec 7, 2022
💻 A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline!

LocalStack - A fully functional local AWS cloud stack LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications. Cur

LocalStack 45.3k Jan 2, 2023
A simple discord bot written in python which can surf subreddits, send a random meme, jokes and also weather of a given place

A simple Discord Bot A simple discord bot written in python which can surf subreddits, send a random meme, jokes and also weather of a given place. We

null 1 Jan 24, 2022
ALIEN: idA Local varIables rEcogNizer

ALIEN: idA Local varIables rEcogNizer ALIEN is an IDA Pro plugin that allows the user to get more information about ida local variables with the help

null 16 Nov 26, 2022
Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of Scratch2py

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of Scratch2py Installation Run this command i

null 2 Jan 13, 2022