fix(tools): 🐛 handle zip archive paths in batch audio fetch
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
ae5d21aefe
commit
aaf9db24a3
3 changed files with 61 additions and 14 deletions
10
.project/designs/app/.gitignore
vendored
Normal file
10
.project/designs/app/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Vite cache + build output (regenerable, not source).
|
||||
node_modules/
|
||||
.vite/
|
||||
dist/
|
||||
|
||||
# Stray emitted JS — sources are .ts/.tsx; tsc must run with --noEmit.
|
||||
# These files broke the dev server's import resolution once already
|
||||
# (Vite picked .js over .tsx siblings). Keep them out of the tree.
|
||||
src/**/*.js
|
||||
src/**/*.js.map
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true,
|
||||
"resolveJsonModule": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
|
|
|
|||
|
|
@ -56,26 +56,62 @@ while IFS=$'\t' read -r output_path source_url licence attribution edits; do
|
|||
mkdir -p "$(dirname "$full_path")"
|
||||
|
||||
stem="$(basename "$output_path" .ogg)"
|
||||
src_ext="${source_url##*.}"
|
||||
case "$src_ext" in
|
||||
wav|ogg|mp3|flac) ;;
|
||||
*) src_ext="bin" ;;
|
||||
esac
|
||||
staged="$STAGING/${stem}.${src_ext}"
|
||||
|
||||
# Convert github.com blob URLs to raw URLs automatically (still allow
|
||||
# raw URLs and other hosts unchanged).
|
||||
# Source URL may be one of:
|
||||
# 1. direct file URL ending in .wav/.ogg/.mp3/.flac
|
||||
# 2. github.com blob URL (auto-converted to raw)
|
||||
# 3. ZIP archive with an inner path: "<zip_url>#<inner/path/inside.wav>"
|
||||
fetch_url="$source_url"
|
||||
case "$source_url" in
|
||||
inner_path=""
|
||||
if [[ "$source_url" == *"#"* ]]; then
|
||||
fetch_url="${source_url%%#*}"
|
||||
inner_path="${source_url#*#}"
|
||||
fi
|
||||
case "$fetch_url" in
|
||||
https://github.com/*/blob/*)
|
||||
fetch_url="$(echo "$source_url" | sed -e 's|github.com|raw.githubusercontent.com|' -e 's|/blob/|/|')"
|
||||
fetch_url="$(echo "$fetch_url" | sed -e 's|github.com|raw.githubusercontent.com|' -e 's|/blob/|/|')"
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! curl -sfL -o "$staged" "$fetch_url"; then
|
||||
echo " ✗ download failed: $fetch_url" >&2
|
||||
fail=$((fail + 1))
|
||||
continue
|
||||
if [ -n "$inner_path" ]; then
|
||||
# ZIP path: cache the archive once per URL, extract a single
|
||||
# member into staging.
|
||||
zip_hash="$(printf '%s' "$fetch_url" | shasum | cut -c1-8)"
|
||||
zip_cache="$STAGING/_zip_${zip_hash}.zip"
|
||||
zip_extract_dir="$STAGING/_zip_${zip_hash}"
|
||||
if [ ! -f "$zip_cache" ]; then
|
||||
if ! curl -sfL -o "$zip_cache" "$fetch_url"; then
|
||||
echo " ✗ ZIP download failed: $fetch_url" >&2
|
||||
fail=$((fail + 1))
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
if [ ! -d "$zip_extract_dir" ]; then
|
||||
mkdir -p "$zip_extract_dir"
|
||||
if ! unzip -q -o "$zip_cache" -d "$zip_extract_dir"; then
|
||||
echo " ✗ ZIP extract failed: $zip_cache" >&2
|
||||
fail=$((fail + 1))
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
staged="$zip_extract_dir/$inner_path"
|
||||
if [ ! -f "$staged" ]; then
|
||||
echo " ✗ ZIP missing inner file: $inner_path" >&2
|
||||
fail=$((fail + 1))
|
||||
continue
|
||||
fi
|
||||
else
|
||||
src_ext="${fetch_url##*.}"
|
||||
case "$src_ext" in
|
||||
wav|ogg|mp3|flac) ;;
|
||||
*) src_ext="bin" ;;
|
||||
esac
|
||||
staged="$STAGING/${stem}.${src_ext}"
|
||||
if ! curl -sfL -o "$staged" "$fetch_url"; then
|
||||
echo " ✗ download failed: $fetch_url" >&2
|
||||
fail=$((fail + 1))
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
# loudnorm two-pass would be more accurate, but for SFX one-pass is fine
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue