Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script for downloading all files from a Quill team export
# Run this script to download all of the files that were uploaded to public channels in your Team.
# Usage: cd my-files-dir && python -f /Users/myusername/Downloads/
import zipfile
import getopt
import sys
import re
import json
import os.path
import os
opts, unparsedArgs = getopt.getopt(sys.argv[1:], "f:")
zipFileName = None
for o, a in opts:
if o == "-f":
zipFileName = a
if zipFileName == None:
print("The `-f` argument is required")
zf = zipfile.ZipFile(zipFileName)
files = zf.namelist()
lines = []
threadChannelNameToThreadID = {}
for file in files:
matched = re.match("(.*)-thread-messages-[0-9]*.json", file)
if matched:
with as f:
jsonMessages = json.loads("utf-8"))["messages"]
while jsonMessages:
jsonMessage = jsonMessages.pop(0)
file = jsonMessage.get("file")
if file:
link = file.get("link")
if link:
filename = os.path.basename(link).split('?')[0]
print("Downloading " + link + " to filename " + filename)
os.system("wget \"" + link + "\" -O " + filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment