Update download

-Po not supported by busybox grep
This commit is contained in:
Cameron Thompson
2024-09-07 14:39:24 -04:00
parent 0e93104d53
commit 3117d70408

View File

@@ -91,8 +91,8 @@ download_github_directory() {
# Parse and download each file
echo "Parsing and downloading files..."
echo "$contents" | grep '"type": "file"' | while read -r line; do
file_path=$(echo "$line" | grep -Po '"path": "\K[^"]+')
download_url=$(echo "$line" | grep -Po '"download_url": "\K[^"]+')
file_path=$(echo "$line" | sed -n 's/.*"path": "\([^"]*\)".*/\1/p')
download_url=$(echo "$line" | sed -n 's/.*"download_url": "\([^"]*\)".*/\1/p')
if [ -n "$file_path" ] && [ -n "$download_url" ]; then
file_name=$(basename "$file_path")
@@ -106,7 +106,7 @@ download_github_directory() {
# Parse and handle subdirectories
echo "Parsing and handling directories..."
echo "$contents" | grep '"type": "dir"' | while read -r line; do
sub_dir=$(echo "$line" | grep -Po '"path": "\K[^"]+')
sub_dir=$(echo "$line" | sed -n 's/.*"path": "\([^"]*\)".*/\1/p')
if [ -n "$sub_dir" ]; then
echo "Recursively handling directory: $sub_dir"
download_github_directory "https://github.com/$owner_repo/tree/$branch/$sub_dir" "$output_dir"