Skip to content

Commit

Permalink
Update create_task function
Browse files Browse the repository at this point in the history
Fix N4S4#136 and update function name
  • Loading branch information
EddieKuo723 committed Jan 4, 2025
1 parent 5d4b6a7 commit 0f0bca9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions synology_api/downloadstation.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,12 @@ def tasks_source(self, task_id) -> bytes:

return self.request_data(api_name, api_path, req_param, response_json=False).content

def create_task(self, uri, additional_param: Optional[dict[str, object]] = None) -> dict[str, object] | str:
api_name = 'SYNO.DownloadStation' + self.download_st_version + '.Task'
def create_task(self, url, destination) -> dict[str, object] | str:
api_name = 'SYNO.DownloadStation2.Task'
info = self.download_list[api_name]
api_path = info['path']
req_param = {'version': info['maxVersion'], 'method': 'create', 'uri': uri}

if type(additional_param) is dict:
for key in additional_param.keys():
req_param[key] = additional_param[key]
req_param = {'version': info['maxVersion'], 'method': 'create', 'type': 'url',
'create_list': 'true', 'destination':f'"{destination}"', 'url': f'["{url}"]'}

return self.request_data(api_name, api_path, req_param)

Expand Down Expand Up @@ -229,7 +226,7 @@ def refresh_rss_site(self, rss_id: Optional[str] = None) -> dict[str, object] |
param = {'version': info['maxVersion'], 'method': 'refresh', 'id': rss_id}

if rss_id is None:
return 'Enter a valid ID check if you have any with get_rss_list()'
return 'Enter a valid ID check if you have any with get_rss_info_list()'
elif type(rss_id) is list:
rss_id = ','.join(rss_id)
param['id'] = rss_id
Expand All @@ -247,7 +244,7 @@ def rss_feed_list(self,
param = {'version': info['maxVersion'], 'method': 'list', 'id': rss_id}

if rss_id is None:
return 'Enter a valid ID check if you have any with get_rss_list()'
return 'Enter a valid ID check if you have any with get_rss_info_list()'
elif type(rss_id) is list:
rss_id = ','.join(rss_id)
param['id'] = rss_id
Expand Down

0 comments on commit 0f0bca9

Please sign in to comment.