A command line (CLI) program for monitoring and downloading 8chan threads. Licensed under MIT.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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']