add optional download_directory argument to get
This commit is contained in:
parent
f642cfe9dd
commit
4f0e8fce6e
1 changed files with 8 additions and 4 deletions
|
@ -868,26 +868,30 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
@requires(WALLET_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT,
|
@requires(WALLET_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT,
|
||||||
STREAM_MANAGER_COMPONENT,
|
STREAM_MANAGER_COMPONENT,
|
||||||
conditions=[WALLET_IS_UNLOCKED])
|
conditions=[WALLET_IS_UNLOCKED])
|
||||||
async def jsonrpc_get(self, uri, file_name=None, timeout=None, save_file=None):
|
async def jsonrpc_get(self, uri, file_name=None, download_directory=None, timeout=None, save_file=None):
|
||||||
"""
|
"""
|
||||||
Download stream from a LBRY name.
|
Download stream from a LBRY name.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
get <uri> [<file_name> | --file_name=<file_name>] [<timeout> | --timeout=<timeout>]
|
get <uri> [<file_name> | --file_name=<file_name>]
|
||||||
|
[<download_directory> | --download_directory=<download_directory>] [<timeout> | --timeout=<timeout>]
|
||||||
[--save_file=<save_file>]
|
[--save_file=<save_file>]
|
||||||
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--uri=<uri> : (str) uri of the content to download
|
--uri=<uri> : (str) uri of the content to download
|
||||||
--file_name=<file_name> : (str) specified name for the downloaded file, overrides the stream file name
|
--file_name=<file_name> : (str) specified name for the downloaded file, overrides the stream file name
|
||||||
|
--download_directory=<download_directory> : (str) full path to the directory to download into
|
||||||
--timeout=<timeout> : (int) download timeout in number of seconds
|
--timeout=<timeout> : (int) download timeout in number of seconds
|
||||||
--save_file=<save_file> : (bool) save the file to the downloads directory
|
--save_file=<save_file> : (bool) save the file to the downloads directory
|
||||||
|
|
||||||
Returns: {File}
|
Returns: {File}
|
||||||
"""
|
"""
|
||||||
|
if download_directory and not os.path.isdir(download_directory):
|
||||||
|
return {"error": f"specified download directory \"{download_directory}\" does not exist"}
|
||||||
try:
|
try:
|
||||||
stream = await self.stream_manager.download_stream_from_uri(
|
stream = await self.stream_manager.download_stream_from_uri(
|
||||||
uri, self.exchange_rate_manager, timeout, file_name, save_file=save_file
|
uri, self.exchange_rate_manager, timeout, file_name, download_directory, save_file=save_file
|
||||||
)
|
)
|
||||||
if not stream:
|
if not stream:
|
||||||
raise DownloadSDTimeout(uri)
|
raise DownloadSDTimeout(uri)
|
||||||
|
|
Loading…
Reference in a new issue