daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest May 17th, 2018 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from slacker import Slacker
  2. import itertools
  3. from hurry.filesize import size
  4.  
  5. slack = Slacker('<API KEY>')
  6.  
  7. pages = slack.files.list(page=1).body['paging']['pages']
  8.  
  9. all_the_files = list(itertools.chain(*[slack.files.list(page=i).body['files'] for i in range(1,pages + 1)]))
  10.  
  11. biggest_first = sorted(all_the_files, key=lambda f: f['size'], reverse=True)
  12.  
  13. files = biggest_first[:10]
  14. for file in files:
  15.     ftitle = file[u'title']
  16.     fsize = file[u'size']
  17.     furl = file[u'permalink']
  18.     print("%s: %s - %s" % (ftitle, size(fsize), furl))
  19.  
  20.   # To delete e.g.
  21.   # slack.files.delete(file['id'])
RAW Paste Data
Top