123456789101112131415161718192021222324252627 |
- def extract_filenames(json):
- def get_filename(reply_json):
- hashed_name = reply_json['tim'] + reply_json['ext']
- original_name = reply_json['filename'] + reply_json['ext']
-
- return [dict(hashed_name=hashed_name, original_name=original_name)]
-
- filenames = []
- for p in json['posts']:
- if 'filename' in p:
- filenames += get_filename(p)
-
- if 'extra_files' in p:
- for e in p['extra_files']:
- filenames += get_filename(e)
-
- return filenames
-
-
- def time_of_last_reply(json):
- t = int(json['posts'][-1]['last_modified'])
- return t
-
-
- def get_oldest_reply(replies):
- oldest_reply = min(replies, key=lambda x: int(x['last_modified']))
- return oldest_reply['no']
|