Skip to content

Instantly share code, notes, and snippets.

@shohei
Created June 2, 2020 08:49
Show Gist options
  • Save shohei/c91553906592fd63e4f0e91b1376f1c3 to your computer and use it in GitHub Desktop.
Save shohei/c91553906592fd63e4f0e91b1376f1c3 to your computer and use it in GitHub Desktop.
Slack download
import json
import os
import random
with open('data.txt') as json_file:
data = json.load(json_file)
for p in data:
if "files" in p:
q = p['files'][0]
if "mimetype" in q:
mimetype = q["mimetype"]
if "image" in mimetype:
name = str(random.getrandbits(32))+"_"+q["name"]
url = q["url_private_download"]
cmd = "wget -O "+"'"+name+"'"+ " "+url
print(cmd)
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment