summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfb13
1 files changed, 12 insertions, 1 deletions
diff --git a/fb b/fb
index d4f1b24..22a5d78 100755
--- a/fb
+++ b/fb
@@ -16,9 +16,11 @@ or nopaste stdin
from optparse import OptionParser
from subprocess import Popen, PIPE
+from urllib2 import urlopen
import os
import sys
import netrc
+import re
def password():
''' netrc: machine paste.xinu.at password PASSWORD'''
@@ -55,6 +57,9 @@ def delete(id):
['http://paste.xinu.at/file/delete/'+id]]
),).communicate()[0]
+def get(id):
+ print urlopen('http://paste.xinu.at/d/%s' % id).read()
+
def merge(seq):
merged = []
for s in seq:
@@ -85,6 +90,8 @@ def main():
help='delete IDs', default=False)
p.add_option('-e', '--extension', action='store', dest='extension',
help='extension for tempfiles when pipeing (e.g. "diff")', default='')
+ p.add_option('-g', '--get', action='store_true', dest='get',
+ help='Download File IDs and output to stdout (use with care!)', default=False)
options, args = p.parse_args()
tmpfiles = []
@@ -96,7 +103,11 @@ def main():
delete(arg)
continue
- if arg.find('http://') != -1:
+ if options.get:
+ get(arg)
+ continue
+
+ if re.match('[a-z]+://.+', arg):
os.chdir(tmpdir)
tmpfiles.append(tmpdir)
Popen(['wget', '-q', arg]).communicate()[0]