def download_ucf101_dataset(
    dataset_dir, scratch_dir=None, fold=1, cleanup=True
):
    """Downloads and extracts the UCF101 dataset.

    Any existing files are not re-downloaded.

    Args:
        dataset_dir: the directory to output the final dataset
        scratch_dir (None): a scratch directory to use to store temporary files
        fold (1): the test/train fold to use to arrange the files on disk. The
            supported values are ``(1, 2, 3)``
        cleanup (True): whether to cleanup the scratch directory after
            extraction
    """
    if scratch_dir is None:
        scratch_dir = os.path.join(dataset_dir, "scratch")

    if fold not in (1, 2, 3):
        raise ValueError("fold must be (1, 2, 3); found %s" % fold)

    # Download dataset
    videos_dir = _download_videos(scratch_dir)
    splits_dir = _download_splits(scratch_dir)

    # Reorganize files into splits
    logger.info("Reorganizing videos into splits via fold %d...", fold)

    # Test split
    logger.info("Creating test split...")
    test_split_path = os.path.join(splits_dir, "testlist%02d.txt" % fold)
    test_filenames = _load_split_info(test_split_path)
    with fou.ProgressBar() as pb:
        for test_filename in pb(test_filenames):
            inpath = os.path.join(videos_dir, test_filename)
            outpath = os.path.join(dataset_dir, "test", test_filename)
            etau.move_file(inpath, outpath)

    # Train split
    logger.info("Creating train split...")
    train_split_path = os.path.join(splits_dir, "trainlist%02d.txt" % fold)
    train_filenames = _load_split_info(train_split_path)
    with fou.ProgressBar() as pb:
        for train_filename in pb(train_filenames):
            inpath = os.path.join(videos_dir, train_filename)
            outpath = os.path.join(dataset_dir, "train", train_filename)
            etau.move_file(inpath, outpath)

    if cleanup:
        etau.delete_dir(scratch_dir)
Downloads and extracts the UCF101 dataset.

    Any existing files are not re-downloaded.

    Args:
        dataset_dir: the directory to output the final dataset
        scratch_dir (None): a scratch directory to use to store temporary files
        fold (1): the test/train fold to use to arrange the files on disk. The
            supported values are ``(1, 2, 3)``
        cleanup (True): whether to cleanup the scratch directory after
            extraction
    
fiftyone/utils/ucf101.py