Skip to content

Instantly share code, notes, and snippets.

@taravancil
Last active August 23, 2021 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taravancil/8d7273def1cf519197bd7768401ec54a to your computer and use it in GitHub Desktop.
Save taravancil/8d7273def1cf519197bd7768401ec54a to your computer and use it in GitHub Desktop.
A bash script for downloading CDN assets for a Glitch project

Scrape Glitch Assets

Problem

When using glitch.com's Download Project tool (Tools > Import and Export > Download Project), the resulting archive does not include project assets that were uploaded to the Glitch CDN.

Solution

The download does however include a metadata file .glitch-assets that lists the project's CDN files.

This script downloads the files listed in a .glitch-assets file and writes them to a local directory.

Usage

# default looks for ./glitch-assets and writes downloaded files to current directory 
. scrape-glitch-assets.sh

# specify input file and output directory
. scrape-glitch-assets.sh /path/to/.glitch-assets -o /path/to/output/directory
#!/bin/bash
#
# Scrape assets listed in a .glitch-assets file and save them to a local directory.
glitch_assets_path='.glitch-assets'
output_dir='.'
while [[ $# -gt 0 ]]; do
case "$1" in
-o)
output_dir="$2"
shift
shift
;;
*)
glitch_assets_path="$1"
shift
;;
esac
done
while IFS= read -r line; do
url=$(echo "$line" | jq -r 'select(.url != null).url')
if [ "$url" ]
then
name=$(echo "$line" | jq -r '.name')
curl "$url" -o "$output_dir/$name"
fi
done < "$glitch_assets_path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment