From a7d94f4514e1ff2b82f118bc9a41196d7149d0ed Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 18 Apr 2019 14:39:28 -0400 Subject: [PATCH] add file_save --- lbrynet/extras/daemon/Daemon.py | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index 658ec3822..a32ad6519 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -1616,6 +1616,45 @@ class Daemon(metaclass=JSONRPCServerType): result = True return result + @requires(STREAM_MANAGER_COMPONENT) + async def jsonrpc_file_save(self, file_name=None, download_directory=None, **kwargs): + """ + Output a download to a file + + Usage: + file_save [--file_name=] [--download_directory=] [--sd_hash=] + [--stream_hash=] [--rowid=] [--claim_id=] [--txid=] + [--nout=] [--claim_name=] [--channel_claim_id=] + [--channel_name=] + + Options: + --file_name= : (str) delete by file name in downloads folder + --download_directory= : (str) delete by file name in downloads folder + --sd_hash= : (str) delete by file sd hash + --stream_hash= : (str) delete by file stream hash + --rowid= : (int) delete by file row id + --claim_id= : (str) delete by file claim id + --txid= : (str) delete by file claim txid + --nout= : (int) delete by file claim nout + --claim_name= : (str) delete by file claim name + --channel_claim_id= : (str) delete by file channel claim id + --channel_name= : (str) delete by file channel claim name + + Returns: {File} + """ + + streams = self.stream_manager.get_filtered_streams(**kwargs) + + if len(streams) > 1: + log.warning("There are %i matching files, use narrower filters to select one", len(streams)) + return False + if not streams: + log.warning("There is no file to save") + return False + stream = streams[0] + await stream.save_file(file_name, download_directory) + return stream + CLAIM_DOC = """ List and search all types of claims. """