Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import pyperclip
- import requests
- from termcolor import colored
- from tkinter import filedialog, Tk
- CSRF_TOKEN = "dQw4w9WgXcQ"
- SESSION_ID = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
- def get_image():
- root = Tk()
- root.withdraw()
- image = filedialog.askopenfilenames(title = "Upload")
- return image[0]
- image = get_image()
- file_data = open(image, "rb")
- def md5(fname):
- hash_md5 = hashlib.md5()
- with open(fname, "rb") as f:
- for chunk in iter(lambda: f.read(4096), b""):
- hash_md5.update(chunk)
- return hash_md5.hexdigest()
- def get_extension(file):
- i = None
- for i in range(0, len(image) + 1):
- if image[i] == ".":
- break
- return image[i:]
- extension = get_extension(image)
- hash = md5(image)
- requests.post(
- f"https://assets.scratch.mit.edu/{hash}{extension}",
- data = file_data,
- cookies = {
- "scratchcsrftoken": CSRF_TOKEN,
- "scratchsessionsid": SESSION_ID
- }
- )
- link = f"https://assets.scratch.mit.edu/get_image/.%2E/{hash}{extension}"
- link_with_bbcode = f"[img]https://assets.scratch.mit.edu/get_image/.%2E/{hash}{extension}[/img]"
- print(colored(link, "green") + "\n" + colored(link_with_bbcode, "green"))
- pyperclip.copy(link)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement