Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed add_download_task_from_url #635

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/freebox_api/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,16 @@ async def get(
return await self._perform_request(self.session.get, end_url)

async def post(
self, end_url: str, payload: Optional[Dict[str, Any]] = None
self, end_url: str, payload: Optional[Dict[str, Any]] = None, json_transform: bool = True
) -> Dict[str, Any]:
"""
Send post request and return results
"""
data = json.dumps(payload) if payload else None
data: Optional[str|Any] = None
if json_transform:
data = json.dumps(payload) if payload else None
else:
data = payload if payload else None
return await self._perform_request(self.session.post, end_url, data=data) # type: ignore

async def put(
Expand Down
4 changes: 2 additions & 2 deletions src/freebox_api/api/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ async def add_download_task_from_url(
"""
Add download from url

download_url : `str`
download_url : `dict`
"""
return await self._access.post("downloads/add/", download_url)
return await self._access.post("downloads/add/", download_url, False)

async def add_download_task_from_file(
self, download_file: Dict[str, Any]
Expand Down