From 56aea98c351afd9f26f56ddb8791e9319fb26be2 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 6 Feb 2019 16:57:03 +0100 Subject: Support changing filename when repasting Signed-off-by: Florian Pritz --- fb.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fb.py b/fb.py index d38f580..d6de696 100755 --- a/fb.py +++ b/fb.py @@ -611,7 +611,10 @@ class FBClient: upload_files.append(file) if len(upload_files) == 1 and not upload_files[0].should_upload(): - upload_files[0] = self.url_to_file(self.config['pastebin']+'/'+upload_files[0].id) + filename = None + if self.args.name != FBClient.DEFAULT_NAME: + filename = self.args.name + upload_files[0] = self.url_to_file(self.config['pastebin']+'/'+upload_files[0].id, filename) resp = self.curlw.upload_files(upload_files) @@ -689,8 +692,10 @@ class FBClient: return File(arg) - def url_to_file(self, url): - outfile = os.path.join(self.tempdir, os.path.basename(url.strip("/"))) + def url_to_file(self, url, filename=None): + if filename is None: + filename = os.path.basename(url.strip("/")) + outfile = os.path.join(self.tempdir, filename) self.curlw.dl_file(url, outfile) return File(outfile) -- cgit v1.2.3-24-g4f1b