@@ -12,13 +12,14 @@ def __init__(self, dluploader=None, token=None):
12
12
self .api_url = "https://api.gofile.io/"
13
13
self .dluploader = dluploader
14
14
self .token = token
15
+
15
16
16
17
@staticmethod
17
18
async def is_goapi (token ):
18
19
if token is None :
19
20
return
20
21
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 :
22
23
if (await resp .json ())["status" ] == "ok" :
23
24
return True
24
25
return False
@@ -31,14 +32,14 @@ async def __resp_handler(self, response):
31
32
32
33
async def __getServer (self ):
33
34
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 :
35
36
return await self .__resp_handler (await resp .json ())
36
37
37
38
async def __getAccount (self , check_account = False ):
38
39
if self .token is None :
39
40
raise Exception ()
40
41
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"
42
43
async with ClientSession () as session :
43
44
resp = await (await session .get (url = api_url )).json ()
44
45
if check_account :
@@ -73,11 +74,11 @@ async def upload_file(self, path: str, folderId: str = "", description: str = ""
73
74
if password and len (password ) < 4 :
74
75
raise ValueError ("Password Length must be greater than 4" )
75
76
76
- server = (await self .__getServer ())["server " ]
77
+ server = (await self .__getServer ())["servers" ][ 0 ][ "name " ]
77
78
token = self .token if self .token else ""
78
79
req_dict = {}
79
80
if token :
80
- req_dict ["token" ] = token
81
+ req_dict ["token" ] = token . split ( ':' )[ 1 ]
81
82
if folderId :
82
83
req_dict ["folderId" ] = folderId
83
84
if description :
@@ -94,7 +95,7 @@ async def upload_file(self, path: str, folderId: str = "", description: str = ""
94
95
new_path = ospath .join (ospath .dirname (path ), ospath .basename (path ).replace (' ' , '.' ))
95
96
await aiorename (path , new_path )
96
97
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 )
98
99
return await self .__resp_handler (upload_file )
99
100
100
101
async def upload (self , file_path ):
@@ -115,11 +116,11 @@ async def create_folder(self, parentFolderId, folderName):
115
116
raise Exception ()
116
117
117
118
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" ,
119
120
data = {
120
121
"parentFolderId" : parentFolderId ,
121
122
"folderName" : folderName ,
122
- "token" : self .token
123
+ "token" : self .token . split ( ':' )[ 1 ]
123
124
}
124
125
) as resp :
125
126
return await self .__resp_handler (await resp .json ())
@@ -131,12 +132,11 @@ async def __setOptions(self, contentId, option, value):
131
132
if not option in ["public" , "password" , "description" , "expire" , "tags" ]:
132
133
raise Exception (f"Invalid GoFile Option Specified : { option } " )
133
134
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 " ,
135
136
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
140
140
}
141
141
) as resp :
142
142
return await self .__resp_handler (await resp .json ())
@@ -146,18 +146,18 @@ async def get_content(self, contentId):
146
146
raise Exception ()
147
147
148
148
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 :
150
150
return await self .__resp_handler (await resp .json ())
151
151
152
152
async def copy_content (self , contentsId , folderIdDest ):
153
153
if self .token is None :
154
154
raise Exception ()
155
155
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 " ,
157
157
data = {
158
- "token" : self .token ,
158
+ "token" : self .token . split ( ':' )[ 1 ] ,
159
159
"contentsId" : contentsId ,
160
- "folderIdDest " : folderIdDest
160
+ "folderId " : folderIdDest
161
161
}
162
162
) as resp :
163
163
return await self .__resp_handler (await resp .json ())
@@ -166,10 +166,9 @@ async def delete_content(self, contentId):
166
166
if self .token is None :
167
167
raise Exception ()
168
168
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 } " ,
170
170
data = {
171
- "contentId" : contentId ,
172
- "token" : self .token
171
+ "token" : self .token .split (':' )[1 ]
173
172
}
174
173
) as resp :
175
174
return await self .__resp_handler (await resp .json ())
0 commit comments