Skip to content

Commit 161b4ea

Browse files
committed
Added: functions getUpload and DealStatus
1 parent 3928984 commit 161b4ea

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import requests
2+
from typing import List
3+
from .config import Config
4+
from . import types as t
5+
6+
7+
def get_deal_status(cid: str) -> List[t.DealData]:
8+
try:
9+
url = f"{Config.lighthouse_api_v2}/api/lighthouse/deal_status?cid={cid}"
10+
response = requests.get(url)
11+
response.raise_for_status()
12+
return response.json()
13+
except requests.HTTPError as error:
14+
raise Exception(error.response.text)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import requests
2+
from .config import Config
3+
from . import types as t
4+
5+
6+
def bytes_to_size(bytes_size):
7+
units = ['B', 'KB', 'MB', 'GB', 'TB']
8+
index = 0
9+
while bytes_size >= 1024 and index < len(units) - 1:
10+
bytes_size /= 1024
11+
index += 1
12+
return f"{round(bytes_size, 2)} {units[index]}"
13+
14+
15+
def get_uploads(publicKey: str, pageNo: int = 1) -> t.UploadsResponseType:
16+
try:
17+
url = f"{Config.lighthouse_api_v2}/api/user/files_uploaded?publicKey={publicKey}&pageNo={pageNo}"
18+
response = requests.get(url)
19+
response.raise_for_status()
20+
return response.json()
21+
except requests.HTTPError as error:
22+
raise Exception(error.response.text)

0 commit comments

Comments
 (0)