-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstreamtape-api.py
135 lines (97 loc) · 4.45 KB
/
streamtape-api.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import requests
import hashlib
# Account
def account_info(login, key):
url = f'https://api.streamtape.com/account/info?login={login}&key={key}'
data = requests.get(url).json()
return data
# Stream
def get_download_ticket(file_id, login, key):
url = f'https://api.streamtape.com/file/dlticket?file={file_id}&login={login}&key={key}'
data = requests.get(url).json()
return data
def get_download_link(file_id, download_ticket):
url = f'https://api.streamtape.com/file/dl?file={file_id}&ticket={download_ticket}'
data = requests.get(url).json()
return data
def check_file(file_id, login, key):
url = f'https://api.streamtape.com/file/info?file={file_id}&login={login}&key={key}'
data = requests.get(url).json()
return data
# Upload
def upload(folder_id, login, key, file_path):
sha256_hash = hashlib.sha256()
with open(file_path, "rb") as f:
for byte_block in iter(lambda: f.read(4096), b""):
sha256_hash.update(byte_block)
sha256 = sha256_hash.hexdigest()
url = f'https://api.streamtape.com/file/ul?login={login}&key={key}&folder={folder_id}&sha256={sha256}'
data = requests.get(url).json()
upload_url = data['result']['url']
file = {'file': open(file_path, 'rb')}
upload_request = requests.post(upload_url, files=file)
upload_response = upload_request.json()
return upload_response
# Remote upload
def add_remote_upload(login, key, file_url, folder_id, name):
url = f'https://api.streamtape.com/remotedl/add?login={login}' \
f'&key={key}&url={file_url}&folder={folder_id}amp;name={name}'
data = requests.get(url).json()
return data
def remove_remote_upload(login, key, upload_id):
# To remove all the uploads, enter 'all' instead of an actual upload ID
url = f'https://api.streamtape.com/remotedl/remove?login={login}&key={key}&id={upload_id}'
data = requests.get(url).json()
return data
def check_remote_upload_status(login, key, upload_id):
url = f'https://api.streamtape.com/remotedl/status?login={login}&key={key}&id={upload_id}'
data = requests.get(url).json()
return data
# File / folder management
def folder_content(login, key):
url = f'https://api.streamtape.com/file/listfolder?login={login}&key={key}'
data = requests.get(url).json()
return data
def subfolder_content(login, key, folder_id):
url = f'https://api.streamtape.com/file/listfolder?login={login}&key={key}&folder={folder_id}'
data = requests.get(url).json()
return data
def create_folder(login, key, folder_name, parent_folder_id):
url = f'https://api.streamtape.com/file/createfolder?login={login}&key={key}&name={folder_name}' \
f'&pid={parent_folder_id}'
data = requests.get(url).json()
return data
def rename_folder(login, key, folder_id, new_name):
url = f'https://api.streamtape.com/file/renamefolder?login={login}&key={key}&folder={folder_id}&name={new_name}'
data = requests.get(url).json()
return data
def delete_folder(login, key, folder_id):
url = f'https://api.streamtape.com/file/deletefolder?login={login}&key={key}&folder={folder_id}'
data = requests.get(url).json()
return data
def rename_file(login, key, file_id, new_name):
url = f'https://api.streamtape.com/file/rename?login={login}&key={key}&file={file_id}&name={new_name}'
data = requests.get(url).json()
return data
def move_file(login, key, file_id, destination_folder_id):
url = f'https://api.streamtape.com/file/rename?login={login}&key={key}&file={file_id}' \
f'&folder={destination_folder_id}'
data = requests.get(url).json()
return data
def delete_file(login, key, file_id):
url = f'https://api.streamtape.com/file/delete?login={login}&key={key}&file={file_id}'
data = requests.get(url).json()
return data
# Converting files
def running_conversions(login, key):
url = f'https://api.streamtape.com/file/runningconverts?login={login}&key={key}'
data = requests.get(url).json()
return data
def failed_conversions(login, key):
url = f'https://api.streamtape.com/file/failedconverts?login={login}&key={key}'
data = requests.get(url).json()
return data
def get_thumbnail(login, key, file_id):
url = f'https://api.streamtape.com/file/getsplash?login={login}&key={key}&file={file_id}'
data = requests.get(url).json()
return data