#!/usr/bin/env python## parse users.json file from exported data and then download the profile pictures## Edelberto Mania <edelberto.mania@xogito.com>## https://xogito.atlassian.net/browse/ITSM-1109## 20230518importrequests,json,shutilusers={}withopen("users.json","r")asslack:users=json.loads(slack.read())foruserinusers:if'image_original'inuser['profile']:pic_url=user['profile']['image_original']else:pic_url=user['profile']['image_512']ext=pic_url.split('.')[-1]r=requests.get(pic_url,stream=True)ifr.status_code==200:r.raw.decode_content=Truetry:filename=user['profile']['email']exceptKeyError:filename=user['profile']['real_name']withopen('{}.{}'.format(filename.lstrip('/'),ext),'wb')asf:shutil.copyfileobj(r.raw,f)print("success: {}.{}".format(filename,ext))else:print("failed: {}.{}".format(filename,ext))
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.