#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script downloads sample datasets for the examples.
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
HAVE_FFMPEG=false
HAVE_PYTHON=false

# Check if we have ffmpeg
if command -v ffmpeg > /dev/null; then
  HAVE_FFMPEG=true
fi

# Check if we have python3
if command -v python3 > /dev/null; then
  HAVE_PYTHON=true
fi

# Creates the data directory
DATA_DIR=${SCRIPT_DIR}/../data
mkdir ${DATA_DIR}

# Download the endoscopy sample data
endoscopy_version="20230128"
endoscopy_md5="9732a54944589f7ca4f1337e8adf0838"

${SCRIPT_DIR}/../lib/cmake/holoscan/download_ngc_data \
    --url https://api.ngc.nvidia.com/v2/resources/nvidia/clara-holoscan/holoscan_endoscopy_sample_data/versions/${endoscopy_version}/zip \
    --download_dir ${DATA_DIR} \
    --download_name endoscopy \
    --md5 ${endoscopy_md5}
