Skip to content

Commit acb5cf1

Browse files
committed
Initial
0 parents  commit acb5cf1

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__pycache__
2+
build
3+
dist
4+
Catboxer.spec

Catboxer.ico

66.6 KB
Binary file not shown.

Catboxer.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import os
2+
import sys
3+
import requests
4+
import pyperclip
5+
import zipfile
6+
import shutil
7+
8+
9+
#If program was opened by doubleclicking
10+
if(len(sys.argv)==1):
11+
print("Did you double click the file?")
12+
temp = input("Failed, Press ENTER to exit!")
13+
exit()
14+
15+
#Blacklisted exts by catbox
16+
blacklist = [".exe",".jar",".doc",".docx",".cpl",".scr"]
17+
ext = os.path.splitext(sys.argv[1])[1]
18+
19+
20+
try:
21+
#if a folder is to be uploaded, zip it
22+
if os.path.isdir(sys.argv[1]):
23+
print("Given path is a directory, proceeding to upload as zip")
24+
shutil.make_archive(sys.argv[1],'zip',sys.argv[1])
25+
#Check if folder is > 200MB
26+
if os.path.getsize(sys.argv[1]+".zip")>209715200:
27+
print("Only files less than 200MB are allowed")
28+
temp = input("Failed, Press ENTER to exit!")
29+
exit()
30+
apidata={
31+
'reqtype': (None, 'fileupload'),
32+
'fileToUpload': (sys.argv[1]+".zip", open(sys.argv[1]+".zip", 'rb')),
33+
}
34+
#If file with blacklisted ext is to be uploaded, zip it
35+
elif ext in blacklist:
36+
#Check if filesize>200MB
37+
if os.path.getsize(sys.argv[1])>209715200:
38+
print("Only files less than 200MB are allowed")
39+
temp = input("Failed, Press ENTER to exit!")
40+
exit()
41+
print("Given filetype not allowed by Catbox, so proceeding to zip and upload")
42+
with zipfile.ZipFile(os.path.basename(sys.argv[1])[:-4]+".zip", 'w') as zip:
43+
zip.write(os.path.basename(sys.argv[1]))
44+
apidata={
45+
'reqtype': (None, 'fileupload'),
46+
'fileToUpload': (sys.argv[1][:-4]+".zip", open(sys.argv[1][:-4]+".zip", 'rb')),
47+
}
48+
else:
49+
#Check if filesize>200MB
50+
if os.path.getsize(sys.argv[1])>209715200:
51+
print("Only files less than 200MB are allowed")
52+
temp = input("Failed, Press ENTER to exit!")
53+
exit()
54+
apidata={
55+
'reqtype': (None, 'fileupload'),
56+
'fileToUpload': (sys.argv[1], open(sys.argv[1], 'rb')),
57+
}
58+
59+
print("Uploading...")
60+
result = requests.post('https://catbox.moe/user/api.php', files=apidata).content.decode("utf-8")
61+
print(result)
62+
pyperclip.copy(result)
63+
spam = pyperclip.paste()
64+
temp = input("Copied to Clipboard, Press ENTER to exit!")
65+
66+
except Exception as e:
67+
print(e)
68+
temp = input("Failed, Press ENTER to exit!")

Readme.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Catboxer
2+
![Catbox logo](https://catbox.moe/pictures/logo.png)
3+
4+
5+
Upload files to Catbox (filehost) via Send to right click menu(Windows).
6+
7+
Written in python.
8+
9+
## Installation
10+
11+
Just paste the release file `Catboxer.exe` in the following location:
12+
`C:\Users\YourUserName\AppData\Roaming\Microsoft\Windows\SendTo\`
13+
14+
## Usage
15+
16+
* Right click on any file/folder.
17+
* Choose `Send to`.
18+
* Choose `Catboxer.exe`.
19+
20+
The url of the upload will be displayed as well as copied to the clipboard automatically.
21+
22+
## Limitations
23+
24+
Files of sizes above 200MB are not allowed.
25+
26+
## Credits
27+
28+
[Catbox](https://catbox.moe/)
29+
30+
## Building from Source
31+
32+
* Clone this repository
33+
* Run `pip install -r requirements.txt`
34+
* Run `pyinstller --onefile -i Catboxer.ico Catboxer.py`
35+
36+
37+

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
requests
2+
pyperclip
3+
zipfile
4+
pyinstaller

0 commit comments

Comments
 (0)