You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

12 lines
539 B

import json, sys, base64
sys.stdout.reconfigure(encoding='utf-8')
d = json.load(open(sys.argv[1], encoding='utf-8'))
prefix = sys.argv[2] if len(sys.argv) > 2 else 'img'
for i, c in enumerate(d['result']['content']):
if c['type'] == 'text':
print(f'=== content[{i}] TEXT ===')
print(c['text'])
else:
fn = rf'd:\code\crm-backend-matt\tmp\{prefix}_{i}.png'
open(fn, 'wb').write(base64.b64decode(c['data']))
print(f'=== content[{i}] IMAGE -> {fn} ({len(c.get("data", "")) // 1024}KB b64) ===')