Skip to content

Instantly share code, notes, and snippets.

@EricRabil
Last active April 17, 2017 01:10
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 EricRabil/c529daddd09124fb6d274df463d59d63 to your computer and use it in GitHub Desktop.
Save EricRabil/c529daddd09124fb6d274df463d59d63 to your computer and use it in GitHub Desktop.
Spotify Development Kit Helper - Simplifies de/recompilation of Spotify components
#!/bin/bash
# spdk - A script to pack/unpack spotify mini-apps
# Constants
UNPACK_ARG="unpack"
UNPACKALL_ARG="unpackall"
PACK_ARG="pack"
LIST_ARG="list"
BAD_ARGS="Usage: spdk [unpack|unpackall|pack] [application name]"
APP_DIR="/Applications/Spotify.app/Contents/Resources/Apps"
SDK_DIR="${HOME}/SpotifyDevelopmentKit"
BACKUP_DIR="${SDK_DIR}/Backups"
SPA_FILES=$(ls -p $APP_DIR | grep -v /);
timestamp() {
date +"%T"
}
if [ ! -d $SDK_DIR ]; then
mkdir $SDK_DIR
fi
if [ ! -d $BACKUP_DIR ]; then
mkdir $BACKUP_DIR
fi
if [ "$1" = $UNPACK_ARG ]; then
if [ "$2" != "" ]; then
if [ ! -f "${APP_DIR}/${2}.spa" ]; then
echo "${2}.spa does not exist in ${APP_DIR}/"
exit 1
elif [ -d "${SDK_DIR}/${2}" ]; then
echo "${SDK_DIR}/${2} exists - Overwrite? [Y/n]"
read operation
if [ $operation = "n" ] || [ $operation = "N" ]; then
echo "Goodbye!"
exit 1
fi
rm -rf "${SDK_DIR}/${2}"
fi
mkdir "${SDK_DIR}/${2}"
echo "Unpacking ${2}.spa..."
unzip -q "${APP_DIR}/${2}.spa" -d "${SDK_DIR}/${2}"
echo "Done! Check ${SDK_DIR}/${2} for your unpacked app"
else
echo $BAD_ARGS
exit 1
fi
elif [ "$1" = $UNPACKALL_ARG ]; then
for fileUntreated in $SPA_FILES
do
file=${fileUntreated//.spa/}
if [ -d "${SDK_DIR}/${file}" ]; then
echo "${SDK_DIR}/${file} exists - Overwrite? [Y/n]"
read operation
operation="${operation:=Y}"
if [ $operation = "n" ] || [ $operation = "N" ]; then
echo "Goodbye!"
fi
rm -rf "${SDK_DIR}/${file}"
fi
mkdir "${SDK_DIR}/${file}"
echo "Unpacking ${file}.spa..."
unzip -q "${APP_DIR}/${file}.spa" -d "${SDK_DIR}/${file}"
echo "Done! Check ${SDK_DIR}/${file} for your unpacked app"
done
elif [ "$1" = $PACK_ARG ]; then
if [ "$2" != "" ]; then
if [ ! -d "${SDK_DIR}/${2}" ]; then
echo "${SDK_DIR}/${2} does not exist"
exit 1
fi
if [ -f "${APP_DIR}/${2}.spa" ]; then
CURR_TIMESTAMP=$(timestamp);
echo "${APP_DIR}/${2}.spa exists - moving to ${BACKUP_DIR}"
mv "${APP_DIR}/${2}.spa" "${BACKUP_DIR}/${2}.${CURR_TIMESTAMP}.spa"
fi
echo "Packaging..."
pushd "${SDK_DIR}/${2}" >> /dev/null
zip -Rq "${APP_DIR}/${2}.spa" "*"
popd >> /dev/null
echo "Done!"
fi
elif [ "$1" = $LIST_ARG ]; then
ls -p $APP_DIR | grep -v /
else
echo $BAD_ARGS
fi
@EricRabil
Copy link
Author

Updated packager to ignore directory structure, fixed fatal spotify bricks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment