summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-09-14 19:51:16 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-09-14 19:51:16 +0200
commita1f172454d58a6ed8cf94223580e47a84ae2d3d0 (patch)
tree02161a672524b4e038785e21ccb75a3343612494
parent9b0c69bcd3d05e3097ec4197ba7ef8f3a350a45d (diff)
fb.py: display_history: Handle multipastes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xfb.py36
1 files changed, 32 insertions, 4 deletions
diff --git a/fb.py b/fb.py
index 58e80f7..2d057e2 100755
--- a/fb.py
+++ b/fb.py
@@ -530,12 +530,40 @@ class FBClient:
def display_history(self):
+ timeFormat = '%a, %d %b %Y %H:%M:%S +0000'
resp = self.curlw.send_post("/file/history")
- items = resp["items"]
- timeFormat = locale.nl_langinfo(locale.D_T_FMT)
+
+ multipasteItems = resp['multipaste_items']
+ if not multipasteItems:
+ multipasteItems = {}
+
+ items = resp['items']
+ if not items:
+ items = {}
+
+ items = list(items.values())
+ multipasteItems = list(multipasteItems.values())
+
+ for item in multipasteItems:
+ item['id'] = item['url_id']
+ item['filename'] = '%s file(s)' % (len(item['items']))
+ item['mimetype'] = ''
+ item['hash'] = ''
+ # sum filesize of all items
+ item['filesize'] = str(sum([int(resp['items'][i]['filesize']) for i in item['items'].keys()]))
+ items.append(item)
+
+ items.sort(key=lambda s: s['date'])
+
itemsTable = [['ID', 'Filename', 'Mimetype', 'Date', 'Hash', 'Size']]
- # TODO: sort items by date or something. currently they are in random order
- itemsTable += [[i['id'], i['filename'], i['mimetype'], datetime.datetime.fromtimestamp(int(i['date'])).strftime(timeFormat), i['hash'], i['filesize']] for i in items.values()]
+ itemsTable += [[
+ i['id'],
+ i['filename'],
+ i['mimetype'],
+ datetime.datetime.fromtimestamp(int(i['date'])).strftime(timeFormat),
+ i['hash'],
+ i['filesize'
+ ]] for i in items]
print_table(itemsTable)
def display_version(self):