From 80073d583058735ae034a5a508c8724efa39ff4d Mon Sep 17 00:00:00 2001 From: Alex Thomassen Date: Sat, 1 Jul 2023 23:00:52 +0000 Subject: [PATCH] Expand README, check if URLs are found before trying to iterate --- GfycatGrab.sh | 5 +++++ README.md | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/GfycatGrab.sh b/GfycatGrab.sh index 9c50a94..b9d8dad 100755 --- a/GfycatGrab.sh +++ b/GfycatGrab.sh @@ -11,6 +11,11 @@ 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"; diff --git a/README.md b/README.md index 48586a6..103c5b7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # GfycatGrab -Budget way of grabbing all Gfycats from your account. +Budget way of grabbing all Gfycats from your account. +I haven't tested this very much. Worked fine with my account, since I only have 83 GIFs saved total, so I only had to save one request from my browser. +In theory the script will scan every JSON file you have in the directory you run it in, and download every GIF in each JSON file (assuming you follow the steps). ## Requirements