import tempfile
import zipfile


def extract_zip_to_temp_dir(filename):
    """Extracts zipfile into a new temporary folder."""
    temp_dir = tempfile.mkdtemp()
    unzipper = zipfile.ZipFile(filename)
    files_to_extract = [f for f in unzipper.namelist() if '__MACOSX' not in f]
    unzipper.extractall(temp_dir, files_to_extract)
    unzipper.close()

    return temp_dir