-
Notifications
You must be signed in to change notification settings - Fork 1
/
scropy.py
53 lines (42 loc) · 1.5 KB
/
scropy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import clipboard
import requests
import datetime
import sys
# Set a local location to save screenshots
directory = os.path.expanduser("~/screenshots/")
# Set an owner name, blank for no owner
owner = ""
# Set a password, blank for no password
password = ""
url = "https://frogbox.es/whff/upload.php?raw"
if not os.path.exists(directory):
os.makedirs(directory)
def supload():
filename = "Screenshot_" + datetime.datetime.now().strftime("%m-%d-%y_%I.%M.%S%p") + ".png"
path = os.path.join(directory, filename)
os.system("scrot -s " + path)
file = {'file': (filename, open(path, 'rb'), 'image/png')}
payload = {'owner': owner, 'password':password}
r = requests.post(url, files=file, data=payload)
clipboard.copy("https://i.frogbox.es/" + r.text + ".png")
os.system("notify-send \"Screenshot uploaded!\"")
def tupload():
filename = "Clipboard_" + datetime.datetime.now().strftime("%m-%d-%y_%I.%M.%S%p") + ".txt"
path = os.path.join(directory, filename)
text = clipboard.paste()
f = open(path, 'w')
f.write(text)
f.close()
file = {'file': (filename, open(path, 'r'), 'text/plain')}
payload = {'owner': owner, 'password':password}
r = requests.post(url, files=file, data=payload)
clipboard.copy("https://i.frogbox.es/" + r.text + ".txt")
os.system("notify-send \"Clip uploaded!\"")
if sys.argv[1] == "-s":
supload()
elif sys.argv[1] == "-t":
tupload()
else:
print "-s [screenshot] / -t [text clipboard]"
sys.exit(0)