Skip to content

Commit

Permalink
Update v1.3.6
Browse files Browse the repository at this point in the history
- Added api methods of 2021-11-17 update
  • Loading branch information
Itz-fork committed Dec 9, 2021
1 parent 6b799f5 commit 2791192
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 34 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ print(g_a.upload(file="/home/itz-fork/photo.png"))
# About API
> Gofile is in BETA version and this API will evolve over time. Check regularly if changes have been made.
>
Current version is compatible with `2021-06-22`
Current version is compatible with `2021-11-17`

# Installation
Install via pypi
Expand Down Expand Up @@ -73,6 +73,12 @@ g_a.create_folder(parentFolderId="your_root_folder_id", folderName="Folder Name"
# Set folder options
g_a.set_folder_options(folderId="id_of_the_folder", option="your_option", value="your_value")

# Get content details
g_a.get_content(contentId="id_of_the_file_or_folder")

# Copy file or folder to another folder
g_a.copy_content(contentId="id_of_the_file_or_folder", folderIdDest="id_of_the_destination_folder")

# Delete file or folder
g_a.delete_content(contentId="id_of_the_file_or_folder")
```
Expand Down
2 changes: 1 addition & 1 deletion gofile2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from .gofile2 import Gofile
from .async_gofile2 import Async_Gofile

__version__ = "v1.3.5"
__version__ = "v1.3.6"
44 changes: 44 additions & 0 deletions gofile2/async_gofile2.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,50 @@ async def set_folder_options(self, folderId, option, value):
return await self._api_resp_handler(set_folder_resp)
except Exception as e:
raise JobFailed(f"Error Happend: {e} \n\nReport this at ----> https://github.com/Itz-fork/Gofile2/issues")

async def get_content(self, contentId):
"""
Get Content Function:
Get a specific content details
Arguments:
contentId - The ID of the file or folder
"""
if self.token is None:
raise InvalidToken("Token is required for this action but it's None")
async with self.r_session as session:
try:
get_content_resp = await session.get(url=f"{self.api_url}getContent?contentId={contentId}&token={self.token}")
get_content_resp = await get_content_resp.json()
return await self._api_resp_handler(get_content_resp)
except Exception as e:
raise JobFailed(f"Error Happend: {e} \n\nReport this at ----> https://github.com/Itz-fork/Gofile2/issues")

async def copy_content(self, contentsId, folderIdDest):
"""
Copy Content Function:
Copy one or multiple contents to another folder
Arguments:
contentsId - The ID(s) of the file or folder (Separate each one by comma if there are multiple IDs)
folderIdDest - Destinatination folder ID
"""
if self.token is None:
raise InvalidToken("Token is required for this action but it's None")
async with self.r_session as session:
try:
copy_content_resp = await session.put(
url=f"{self.api_url}copyContent",
data={
"token": self.token,
"contentsId": contentsId,
"folderIdDest": folderIdDest
}
)
copy_content_resp = await copy_content_resp.json()
return await self._api_resp_handler(copy_content_resp)
except Exception as e:
raise JobFailed(f"Error Happend: {e} \n\nReport this at ----> https://github.com/Itz-fork/Gofile2/issues")

async def delete_content(self, contentId):
"""
Expand Down
42 changes: 42 additions & 0 deletions gofile2/gofile2.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,48 @@ def set_folder_options(self, folderId, option, value):
except Exception as e:
raise JobFailed(f"Error Happend: {e} \n\nReport this at ----> https://github.com/Itz-fork/Gofile2/issues")

def get_content(self, contentId):
"""
Get Content Function:
Get a specific content details
Arguments:
contentId - The ID of the file or folder
"""
token = self.token
if token is None:
raise InvalidToken("Token is required for this action but it's None")
try:
get_content_resp = requests.get(url=f"{self.api_url}getContent?contentId={contentId}&token={token}").json()
return self._api_resp_handler(get_content_resp)
except Exception as e:
raise JobFailed(f"Error Happend: {e} \n\nReport this at ----> https://github.com/Itz-fork/Gofile2/issues")

def copy_content(self, contentsId, folderIdDest):
"""
Copy Content Function:
Copy one or multiple contents to another folder
Arguments:
contentsId - The ID(s) of the file or folder (Separate each one by comma if there are multiple IDs)
folderIdDest - Destinatination folder ID
"""
token = self.token
if token is None:
raise InvalidToken("Token is required for this action but it's None")
try:
copy_content_resp = requests.put(
url=f"{self.api_url}copyContent",
data={
"token": token,
"contentsId": contentsId,
"folderIdDest": folderIdDest
}
).json()
return self._api_resp_handler(copy_content_resp)
except Exception as e:
raise JobFailed(f"Error Happend: {e} \n\nReport this at ----> https://github.com/Itz-fork/Gofile2/issues")

def delete_content(self, contentId):
"""
Delete Content Function:
Expand Down
64 changes: 32 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,43 @@
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

if os.path.isfile('requirements.txt'):
with open('requirements.txt') as req:
reques = req.read().splitlines()
with open('requirements.txt') as req:
reques = req.read().splitlines()
else:
reques = [
'requests',
'aiohttp',
'fake-useragent'
]
reques = [
'requests',
'aiohttp',
'fake-useragent'
]

if os.path.isfile('README.md'):
with open(('README.md'), encoding='utf-8') as readmeh:
big_description = readmeh.read()
with open(('README.md'), encoding='utf-8') as readmeh:
big_description = readmeh.read()
else:
big_description = "Gofile2 is an API wrapper for Gofile API"
big_description = "Gofile2 is an API wrapper for Gofile API"

# Version
v = "v1.3.5"
v = "v1.3.6"

setup(name='gofile2',
version=v,
description='An API wrapper for Gofile API',
url='https://github.com/Itz-fork/Gofile2',
author='Itz-fork, Codec04',
author_email='[email protected]',
license='MIT',
packages=find_packages(),
download_url=f"https://github.com/Itz-fork/Gofile2/releases/tag/Gofile2-{v}",
keywords=['Gofile', 'Api-wrapper', 'Gofile2'],
long_description=big_description,
long_description_content_type='text/markdown',
install_requires=reques,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Education',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.9',
],
)
version=v,
description='An API wrapper for Gofile API',
url='https://github.com/Itz-fork/Gofile2',
author='Itz-fork, Codec04',
author_email='[email protected]',
license='MIT',
packages=find_packages(),
download_url=f"https://github.com/Itz-fork/Gofile2/releases/tag/Gofile2-{v}",
keywords=['Gofile', 'Api-wrapper', 'Gofile2'],
long_description=big_description,
long_description_content_type='text/markdown',
install_requires=reques,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Education',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.9',
],
)

0 comments on commit 2791192

Please sign in to comment.