From a6c872adae936b0443e38c33f1010a227bdb0578 Mon Sep 17 00:00:00 2001 From: CactiChameleon9 <51231053+CactiChameleon9@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:38:26 +0000 Subject: [PATCH] Clean up according to shellcheck --- scrape-all.sh | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/scrape-all.sh b/scrape-all.sh index 324303b..e2f94e4 100755 --- a/scrape-all.sh +++ b/scrape-all.sh @@ -15,20 +15,22 @@ update_cache() { } get_number_of_search_pages() { - local results=$(curl "https://www.bbcgoodfood.com/api/search-frontend/search?limit=1&${search_args}" -s | jq '.searchResults.totalItems') + local results + results=$(curl "https://www.bbcgoodfood.com/api/search-frontend/search?limit=1&${search_args}" -s | jq '.searchResults.totalItems') - if [[ $(($results % recipies_per_search)) == 0 ]]; then - echo $(($results / $recipies_per_search)) + if [[ $((results % recipies_per_search)) == 0 ]]; then + echo $((results / recipies_per_search)) else - echo $(($results / $recipies_per_search + 1)) + echo $((results / recipies_per_search + 1)) fi } get_main_ingredients() { + local data if [[ -z "$1" ]]; then - local data=$cache + data=$cache else - local data=$(curl $1 -s) + data=$(curl "$1" -s) fi echo "$data" | htmlq -p | grep '.*' | sed 's/^.*//' | sed 's/<\/a>.*//' | sed 's/,//' @@ -36,10 +38,11 @@ get_main_ingredients() { } get_page_json() { # Unused - but could be helpful for expanding this out layer + local data if [[ -z "$1" ]]; then - local data=$cache + data=$cache else - local data=$(curl $1 -s) + data=$(curl "$1" -s) fi echo "$data" | htmlq -p | grep '