Instantly share code, notes, and snippets.

Embed
What would you like to do?
A script to download documentation of Jari Williamsson's Finale PDK framework and his JWLua plugin
#!/bin/bash
set -e
if ! [ -x "$(command -v wget)" ]; then
echo "Need wget to download documentation. Depending on your os, try any of the following:"
echo " apt-get install wget"
echo " brew install wget"
echo " yum install wget"
exit 1
fi
echo Downloading framework documentation...
wget -q -r --no-parent -l 2 http://www.finaletips.nu/frameworkref/
echo Downloading wiki...
# We use --restrict-file-names=windows because we'd otherwise get "?" in file names which causes problems
wget -q -r -l 2 \
--convert-links --restrict-file-names=windows \
--accept-regex "doku.php\?id=jw_?lua[^&]*$|exe/css\.php\?|\.jpe?g$|\.png$|\.gif$" \
"http://www.jwmusic.nu/jwplugins/wiki/doku.php?id=jw_lua"
echo Moving to version specific folder...
# Create a folder for this specific version and move all documentation there
# We also create a symbolic link named "current" so our browser history
if ! [ -x "$(command -v hxnormalize)" ] || ! [ -x "$(command -v hxselect)" ]; then
echo "Need hxnormalize and hxselect to extract version information. Depending on your os, try any of the following:"
echo " apt-get install html-xml-utils"
echo " brew install html-xml-utils"
echo " yum install html-xml-utils"
exit 1
fi
version=$(hxnormalize -x "www.finaletips.nu/frameworkref/index.html" | hxselect -c "#projectnumber")
if [[ "$version" =~ "^[a-z0-9.]+$" ]]
then
echo "Unexpected version info found: '$version'"
echo "Can't create version folder"
exit 1
fi
mkdir -p "$version"
rm -r -f "$version"/*
mv www.finaletips.nu "$version"
mv www.jwmusic.nu "$version"
rm -f current
ln -s "$version" current
echo Done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment