A command line (CLI) program for monitoring and downloading 8chan threads. Licensed under MIT.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

json_methods.py 761B

123456789101112131415161718192021222324252627
  1. def extract_filenames(json):
  2. def get_filename(reply_json):
  3. hashed_name = reply_json['tim'] + reply_json['ext']
  4. original_name = reply_json['filename'] + reply_json['ext']
  5. return [dict(hashed_name=hashed_name, original_name=original_name)]
  6. filenames = []
  7. for p in json['posts']:
  8. if 'filename' in p:
  9. filenames += get_filename(p)
  10. if 'extra_files' in p:
  11. for e in p['extra_files']:
  12. filenames += get_filename(e)
  13. return filenames
  14. def time_of_last_reply(json):
  15. t = int(json['posts'][-1]['last_modified'])
  16. return t
  17. def get_oldest_reply(replies):
  18. oldest_reply = min(replies, key=lambda x: int(x['last_modified']))
  19. return oldest_reply['no']