GfycatGrab/GfycatGrab.sh

24 lines
590 B
Bash
Executable File

#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )";
FALLBACK_DATA_DIR="${SCRIPT_DIR}/data";
if [[ -z "${GFYCAT_DIR}" ]]; then
echo "GFYCAT_DIR not set, using: ${FALLBACK_DATA_DIR}";
GFYCAT_DIR="${FALLBACK_DATA_DIR}";
fi
for json in $(ls *.json);
do
urls="$(cat $json | jq -r '.gfycats[] | .mp4Url')";
if [[ -z "${urls}" ]]; then
echo "No urls found in ${json}";
continue;
fi
for url in $urls;
do
echo "Downloading $url";
curl --output-dir "${GFYCAT_DIR}" -O -C - "${url}";
done
done