def download_hmdb51_dataset(
    dataset_dir, scratch_dir=None, fold=1, cleanup=True
):
    """Downloads and extracts the HMDB51 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)

    # Parse splits info
    split_end = "_test_split%d.txt" % fold
    split_map = {
        os.path.basename(path)[: -len(split_end)]: path
        for path in etau.list_files(splits_dir, abs_paths=True)
        if path.endswith(split_end)
    }

    # Reorganize files into splits
    logger.info("Reorganizing videos into splits via fold %d...", fold)
    with fou.ProgressBar() as pb:
        for label, split_path in pb(split_map.items()):
            train_filenames, test_filenames = _load_split_info(split_path)

            # Train split
            for filename in train_filenames:
                inpath = os.path.join(videos_dir, label, filename)
                outpath = os.path.join(dataset_dir, "train", label, filename)
                etau.move_file(inpath, outpath)

            # Test split
            for filename in test_filenames:
                inpath = os.path.join(videos_dir, label, filename)
                outpath = os.path.join(dataset_dir, "test", label, filename)
                etau.move_file(inpath, outpath)

            # Other
            indir = os.path.join(videos_dir, label)
            outdir = os.path.join(dataset_dir, "other", label)
            etau.move_dir(indir, outdir)

    if cleanup:
        etau.delete_dir(scratch_dir)
Downloads and extracts the HMDB51 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/hmdb51.py