summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2019-02-06 16:38:29 +0100
committerFlorian Pritz <bluewind@xinu.at>2019-02-06 16:38:29 +0100
commitc29e58d29debb86a55d2eb38e7033928df769003 (patch)
treeb3b72659c72fe7d2ac898bc141daecd70e09cdaa
parenta439efc95c1299d274aea93524b22311ab7d8ce4 (diff)
Extract url_to_file method
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xfb.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/fb.py b/fb.py
index 03a7b92..67a55ad 100755
--- a/fb.py
+++ b/fb.py
@@ -681,12 +681,14 @@ class FBClient:
if arg.startswith(self.config['pastebin']):
return File(id=self.extractId(arg))
if re.match('https?://', arg):
- outfile = os.path.join(self.tempdir, os.path.basename(arg.strip("/")))
- self.curlw.dl_file(arg, outfile)
- return File(outfile)
+ return self.url_to_file(arg)
return File(arg)
+ def url_to_file(self, url):
+ outfile = os.path.join(self.tempdir, os.path.basename(url.strip("/")))
+ self.curlw.dl_file(url, outfile)
+ return File(outfile)
def extractId(self, arg):
arg = arg.replace(self.config['pastebin'], '')