-
-
Save EricRabil/c529daddd09124fb6d274df463d59d63 to your computer and use it in GitHub Desktop.
Spotify Development Kit Helper - Simplifies de/recompilation of Spotify components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated packager to ignore directory structure, fixed fatal spotify bricks