Skip to content

Commit 423ca46

Browse files
authored
Update gofile.py
1 parent e01f31a commit 423ca46

File tree

1 file changed

+19
-20
lines changed
  • bot/helper/mirror_utils/upload_utils/ddlserver

1 file changed

+19
-20
lines changed

bot/helper/mirror_utils/upload_utils/ddlserver/gofile.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ def __init__(self, dluploader=None, token=None):
1212
self.api_url = "https://api.gofile.io/"
1313
self.dluploader = dluploader
1414
self.token = token
15+
1516

1617
@staticmethod
1718
async def is_goapi(token):
1819
if token is None:
1920
return
2021
async with ClientSession() as session:
21-
async with session.get(f"https://api.gofile.io/getAccountDetails?token={token}&allDetails=true") as resp:
22+
async with session.get(f"https://api.gofile.io/accounts/{token.split(':')[0]}?token={token.split(':')[1]}&allDetails=true") as resp:
2223
if (await resp.json())["status"] == "ok":
2324
return True
2425
return False
@@ -31,14 +32,14 @@ async def __resp_handler(self, response):
3132

3233
async def __getServer(self):
3334
async with ClientSession() as session:
34-
async with session.get(f"{self.api_url}getServer") as resp:
35+
async with session.get(f"{self.api_url}servers") as resp:
3536
return await self.__resp_handler(await resp.json())
3637

3738
async def __getAccount(self, check_account=False):
3839
if self.token is None:
3940
raise Exception()
4041

41-
api_url = f"{self.api_url}getAccountDetails?token={self.token}&allDetails=true"
42+
api_url = f"{self.api_url}accounts/{self.token.split(':')[0]}?token={self.token.split(':')[1]}&allDetails=true"
4243
async with ClientSession() as session:
4344
resp = await (await session.get(url=api_url)).json()
4445
if check_account:
@@ -73,11 +74,11 @@ async def upload_file(self, path: str, folderId: str = "", description: str = ""
7374
if password and len(password) < 4:
7475
raise ValueError("Password Length must be greater than 4")
7576

76-
server = (await self.__getServer())["server"]
77+
server = (await self.__getServer())["servers"][0]["name"]
7778
token = self.token if self.token else ""
7879
req_dict = {}
7980
if token:
80-
req_dict["token"] = token
81+
req_dict["token"] = token.split(':')[1]
8182
if folderId:
8283
req_dict["folderId"] = folderId
8384
if description:
@@ -94,7 +95,7 @@ async def upload_file(self, path: str, folderId: str = "", description: str = ""
9495
new_path = ospath.join(ospath.dirname(path), ospath.basename(path).replace(' ', '.'))
9596
await aiorename(path, new_path)
9697
self.dluploader.last_uploaded = 0
97-
upload_file = await self.dluploader.upload_aiohttp(f"https://{server}.gofile.io/uploadFile", new_path, "file", req_dict)
98+
upload_file = await self.dluploader.upload_aiohttp(f"https://{server}.gofile.io/contents/uploadfile", new_path, "file", req_dict)
9899
return await self.__resp_handler(upload_file)
99100

100101
async def upload(self, file_path):
@@ -115,11 +116,11 @@ async def create_folder(self, parentFolderId, folderName):
115116
raise Exception()
116117

117118
async with ClientSession() as session:
118-
async with session.put(url=f"{self.api_url}createFolder",
119+
async with session.put(url=f"{self.api_url}contents/createFolder",
119120
data={
120121
"parentFolderId": parentFolderId,
121122
"folderName": folderName,
122-
"token": self.token
123+
"token": self.token.split(':')[1]
123124
}
124125
) as resp:
125126
return await self.__resp_handler(await resp.json())
@@ -131,12 +132,11 @@ async def __setOptions(self, contentId, option, value):
131132
if not option in ["public", "password", "description", "expire", "tags"]:
132133
raise Exception(f"Invalid GoFile Option Specified : {option}")
133134
async with ClientSession() as session:
134-
async with session.put(url=f"{self.api_url}setOption",
135+
async with session.put(url=f"{self.api_url}contents/{contentId}/update",
135136
data={
136-
"token": self.token,
137-
"contentId": contentId,
138-
"option": option,
139-
"value": value
137+
"token": self.token.split(':')[1],
138+
"attribute": option,
139+
"attributevalue": value
140140
}
141141
) as resp:
142142
return await self.__resp_handler(await resp.json())
@@ -146,18 +146,18 @@ async def get_content(self, contentId):
146146
raise Exception()
147147

148148
async with ClientSession() as session:
149-
async with session.get(url=f"{self.api_url}getContent?contentId={contentId}&token={self.token}") as resp:
149+
async with session.get(url=f"{self.api_url}contents/{contentId}&token={self.token}") as resp:
150150
return await self.__resp_handler(await resp.json())
151151

152152
async def copy_content(self, contentsId, folderIdDest):
153153
if self.token is None:
154154
raise Exception()
155155
async with ClientSession() as session:
156-
async with session.put(url=f"{self.api_url}copyContent",
156+
async with session.put(url=f"{self.api_url}contents/copy",
157157
data={
158-
"token": self.token,
158+
"token": self.token.split(':')[1],
159159
"contentsId": contentsId,
160-
"folderIdDest": folderIdDest
160+
"folderId": folderIdDest
161161
}
162162
) as resp:
163163
return await self.__resp_handler(await resp.json())
@@ -166,10 +166,9 @@ async def delete_content(self, contentId):
166166
if self.token is None:
167167
raise Exception()
168168
async with ClientSession() as session:
169-
async with session.delete(url=f"{self.api_url}deleteContent",
169+
async with session.delete(url=f"{self.api_url}contents/{contentId}",
170170
data={
171-
"contentId": contentId,
172-
"token": self.token
171+
"token": self.token.split(':')[1]
173172
}
174173
) as resp:
175174
return await self.__resp_handler(await resp.json())

0 commit comments

Comments
 (0)