From 7136d1c7eb6989226e162332d89c1806217bd2c8 Mon Sep 17 00:00:00 2001 From: Itz-fork Date: Tue, 28 Jun 2022 23:04:55 +0530 Subject: [PATCH] v1.4.2 - Renamed set_folder_options function to set_folder_option - Fixed wrong api endpoint in set_folder_option function - Updated docstrings --- README.md | 2 +- gofile2/__init__.py | 2 +- gofile2/async_gofile2.py | 10 +++++----- gofile2/gofile2.py | 21 +++++++++++---------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 16be0b0..d0e0d81 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ g_a.upload(file="path_to_your_file") 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") +g_a.set_folder_option(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") diff --git a/gofile2/__init__.py b/gofile2/__init__.py index 0546de6..1a5678e 100644 --- a/gofile2/__init__.py +++ b/gofile2/__init__.py @@ -5,4 +5,4 @@ from .gofile2 import Gofile from .async_gofile2 import Async_Gofile -__version__ = "v1.4.1" \ No newline at end of file +__version__ = "v1.4.2" \ No newline at end of file diff --git a/gofile2/async_gofile2.py b/gofile2/async_gofile2.py index 1fb3502..fa5b680 100644 --- a/gofile2/async_gofile2.py +++ b/gofile2/async_gofile2.py @@ -189,18 +189,18 @@ async def create_folder(self, parentFolderId, folderName): except Exception as e: raise JobFailed(e) - async def set_folder_options(self, folderId, option, value): + async def set_folder_option(self, folderId, option, value): """ - ### Set Folder Options Function: + ### Set Folder Option Function: Set an option on a folder ### Arguments: - `folderId` - The ID of the folder - - `option` - Option that you want to set. Can be "private", "password", "description", "expire" or "tags" + - `option` - Option that you want to set. Can be "public", "password", "description", "expire" or "tags" - `value` - The value of the option to be defined. - - For "private", can be "true" or "false". + - For "public", can be "true" or "false". - For "password", must be the password. - For "description", must be the description. - For "expire", must be the expiration date in the form of unix timestamp. @@ -213,7 +213,7 @@ async def set_folder_options(self, folderId, option, value): async with ClientSession() as session: try: set_folder_resp = await session.put( - url=f"{self.api_url}setFolderOptions", + url=f"{self.api_url}setFolderOption", data={ "token": self.token, "folderId": folderId, diff --git a/gofile2/gofile2.py b/gofile2/gofile2.py index 2e455b6..8f904be 100644 --- a/gofile2/gofile2.py +++ b/gofile2/gofile2.py @@ -3,9 +3,9 @@ # Project: Gofile2 import os -from requests import get, post, put, delete -from .errors import (InvalidPath, InvalidToken, JobFailed, ResponseError, - is_valid_token) +from requests import delete, get, post, put +from .errors import (InvalidOption, InvalidPath, InvalidToken, JobFailed, + ResponseError, is_valid_token) class Gofile: @@ -175,18 +175,18 @@ def create_folder(self, parentFolderId, folderName): raise JobFailed( f"Error Happend: {e} \n\nReport this at ----> https://github.com/Itz-fork/Gofile2/issues") - def set_folder_options(self, folderId, option, value): + def set_folder_option(self, folderId, option, value): """ - ### Set Folder Options Function: + ### Set Folder Option Function: Set an option on a folder ### Arguments: - `folderId` - The ID of the folder - - `option` - Option that you want to set. Can be "private", "password", "description", "expire" or "tags" + - `option` - Option that you want to set. Can be "public", "password", "description", "expire" or "tags" - `value` - The value of the option to be defined. - - For "private", can be "true" or "false". + - For "public", can be "true" or "false". - For "password", must be the password. - For "description", must be the description. - For "expire", must be the expiration date in the form of unix timestamp. @@ -194,11 +194,12 @@ def set_folder_options(self, folderId, option, value): """ token = self.token if token is None: - raise InvalidToken( - "Token is required for this action but it's None") + raise InvalidToken() + if not option in ["public", "password", "description", "expire", "tags"]: + raise InvalidOption(option) try: set_folder_resp = put( - url=f"{self.api_url}setFolderOptions", + url=f"{self.api_url}setFolderOption", data={ "token": token, "folderId": folderId,