forked from nyaadevs/nyaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_uploader.py
55 lines (41 loc) · 971 Bytes
/
api_uploader.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
52
53
54
55
# api_uploader.py
# Uploads a single file
# I will create another script for batch uploading
import json
import requests
url = "http://127.0.0.1:5500/api/upload"
# Required for Auth
username = ""
password = ""
# Required
torrent_name = ""
# Required
main_cat = ""
# Required
sub_cat = ""
# May be blank
information = ""
# May be blank
description = ""
# flags = [Hidden, Remake, Complete, Anonymous]
# 0 for NOT SET / 1 for SET
# Required
flags = [0, 0, 0, 0]
metadata={
"username": username,
"password": password,
"display_name": torrent_name,
"main_cat": main_cat,
"sub_cat": sub_cat,
"information": information,
"description": description,
"flags": flags
}
# Required
file_name = ""
files = {
'json': (json.dumps(metadata)),
'torrent': ('{0}'.format(file_name), open(file_name, 'rb'), 'application/octet-stream')}
response = requests.post(url, files=files)
json_response = response.json()
print(json_response)