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)
Busty - A bot for the Busty Discord server

Busty Discord bot used for the Busty server. Install You'll need at least Python

Andrew Morgan 7 Dec 05, 2022
:cloud: Python API for ThePirateBay.

Unofficial Python API for ThePirateBay. Build Status Test Coverage Version Downloads (30 days) Installation $ pip install ThePirateBay Note that ThePi

Karan Goel 334 Oct 21, 2022
Music cog for discord bots. Supports YouTube, YoutubeMusic, SoundCloud and Spotify.

dismusic Music cog for discord bots. Supports YouTube, YoutubeMusic, SoundCloud and Spotify. Installation python3 -m pip install dismusic Usage from d

Md Shahriyar Alam 59 Jan 08, 2023
Python implementation of Spotify's authorization flow.

Spotify API Apps 🎷 🎶 🎼 This repository consists of many strange codes that make you think why the hell this guy doing this. Well... I got some reas

5 Dec 17, 2021
A quick way to verify your Climate Hack.AI (2022) submission locally!

Climate Hack.AI (2022) Submission Validator This repository contains code that allows you to quickly validate your Climate Hack.AI (2022) submission l

Jeremy 3 Mar 03, 2022
KaydyPurge - Python Purge Script for Discord made by Kaydy Cain#0001

How to Install Open terminal Execute "git clone https://github.com/apolo1337/Kay

apolo 5 Jan 27, 2022
An anime themed telegram group management bot based on sqlalchemy database running on python3.

Kazuko Robot A Telegram Python bot running on python3 forked with saitama and DiasyX with a sqlalchemy database and an entirely themed persona to make

heyaaman 22 Dec 07, 2022
A Python app to serve Conveyor room requests and run approvals through Slack

✨ CONVEYOR FOR SLACK ✨ This is a friendly little Python app that will allow you to integrate your instance of Conveyor with your Slack workspace. In o

Vivienne 4 Sep 27, 2021
Portal Backend for Yuta management

Portal Backend for Yuta management Prerequisites Python 3.10 or above. pip, pdm installed. Quickstart Install the required packages: pdm install Runn

Loc Mai 1 Dec 20, 2021
Python Script to download hundreds of images from 'Google Images'. It is a ready-to-run code!

Google Images Download Python Script for 'searching' and 'downloading' hundreds of Google images to the local hard disk! Documentation Documentation H

Hardik Vasa 8.2k Jan 05, 2023
可基于【腾讯云函数】/【GitHub Actions】/【Docker】的每日签到脚本(支持多账号使用)签到列表: |爱奇艺|全民K歌|腾讯视频|有道云笔记|网易云音乐|一加手机社区官方论坛|百度贴吧|Bilibili|V2EX|咔叽网单|什么值得买|AcFun|天翼云盘|WPS|吾爱破解|芒果TV|联通营业厅|Fa米家|小米运动|百度搜索资源平台|每日天气预报|每日一句|哔咔漫画|和彩云|智友邦|微博|CSDN|王者营地|

每日签到集合 基于【腾讯云函数】/【GitHub Actions】/【Docker】的每日签到脚本 支持多账号使用 特别声明: 本仓库发布的脚本及其中涉及的任何解锁和解密分析脚本,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。

87 Nov 12, 2022
EduuRobot Telegram bot source code.

EduuRobot A multipurpose Telegram Bot made with Pyrogram and asynchronous programming. Requirements Python 3.6+ An Unix-like operating system (Running

Amano Team 119 Dec 23, 2022
Detects members having unicode names. Public bot: @scarletwitchprobot

✨ Scarletwitch bot ✨ Detects unicode names members in a tg chat & provides a option to take action on that user ! Public bot: @scarletwitchprobot Supp

ÁÑÑÍHÌLÅTØR SPÄRK 18 Nov 12, 2022
A Dm Bot, also knows as Mass DM bot which can send one message to All of the Users in a Specific Server!

Discord DM Bot discord.py 1.7.2 python 3.9.5 asyncio 3.4.3 Installation Cloud Host Tutorial uploaded in YouTube, watch it by clicking here. Local Host

hpriyam8 7 Mar 24, 2022
Rapid Sms Bomber For Indian Number.

Bombzilla Rapid Sms Bomber For Indian Number. Installation git clone https://github.com/sarv99/Bombzilla cd Bombzilla chmod +x setup.sh ./setup.sh Af

Saurav Jangid 1 Jan 12, 2022
Wonderful Phoenix-Bot

Phoenix Bot Discord Phoenix Bot is inspired by Natewong1313's Bird Bot project yet due to lack of activity by their team. We have decided to revive th

Senior Developer 0 Aug 12, 2021
A cracking tool of Xiaomi Dr AI (Archytas / Archimedes)

Archytas Tool 我们强烈抵制闲鱼平台上未经授权的刷机服务! 我对本人之前在程序中为防止违规刷机服务添加未生效的格机代码感到抱歉,在此声明此过激行为与 Crack Mi Dr AI Team 无关,并将程序开源。 A cracking tool of Xiaomi Dr AI (Archy

rponeawa 5 Oct 25, 2022
聚合空间测绘搜索(Fofa,Zoomeye,Quake,Shodan,Censys,BinaryEdge)

#Search-Tools Search-Tools集合比较常见的网络空间探测引擎 Fofa,Zoomeye,Quake,Shodan,Censys,BinaryEdge 简单说明 ICO搜索目前只有Fofa,Shodan,Quake支持 代理设置是防止在API请求过于频繁,或者在实战中,好多红队打

311 Dec 16, 2022
ESOLinuxAddonManager - Very simple addon manager for Elder Scrolls Online running on Linux.

ESOLinuxAddonManager Very simple addon manager for Elder Scrolls Online running on Linux. Well, more a downloader for now. Currently it's quite ugly b

Akseli 25 Aug 28, 2022
A program that generates discord.py code

discord-py-generator A program that generates discord.py code Setup in cmds.txt file add your user id, client id and bot token you can change the bot

3 Dec 15, 2022