Last active
October 10, 2020 20:12
-
-
Save tjluoma/8b615925a47b5a3077abd31967fda5a6 to your computer and use it in GitHub Desktop.
If you customize one line in this script, it will download and install / update Skype Call Recorder.
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
#!/usr/bin/env zsh -f | |
# Purpose: Download and install the latest version of Skype Call Recorder | |
# | |
# From: Timothy J. Luoma | |
# Mail: luomat at gmail dot com | |
# Date: 2018-08-22 | |
# you MUST customize this URL to be your URL from ECamm | |
# it ends with your email address (URL encoded) and a 6 digit personal code | |
# replace USER and EXAMPLE and COM with your email address | |
# replace XXXXXX with your code from when you bought Skype Call Recorder | |
PRIVATE_URL='https://www.ecamm.com/cgi-bin/customercenter?u=USER%40EXAMPLE%2ECOM&c=XXXXXX' | |
## you should not have to change anything below this line | |
# This is the public RSS feed for call recorder which we use for release notes | |
XML_FEED='https://www.ecamm.com/appcasts/callrecorder.xml' | |
# this helps curl pretend that it's Safari | |
UA='Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15' | |
if [[ -e "$HOME/.path" ]] | |
then | |
source "$HOME/.path" | |
else | |
PATH='/usr/local/scripts:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin' | |
fi | |
# this will get us the actual URL for the actual download | |
URL=$(curl --user-agent "$UA" -sfLS "$PRIVATE_URL" | tr '"' '\012' | egrep -i '^https://www.ecamm.com/.*/CallRecorder.*\.zip') | |
# we parse out the version number from that URL | |
LATEST_VERSION=$(echo "$URL:t:r" | tr -dc '[0-9]\.') | |
# this is the URL to the release notes | |
RELEASE_NOTES_URL=$(curl --user-agent "$UA" -sfL "$XML_FEED" \ | |
| fgrep '<sparkle:releaseNotesLink>' \ | |
| head -1 \ | |
| sed 's#.*<sparkle:releaseNotesLink>##g ; s#</sparkle:releaseNotesLink>##g') | |
if [[ "$LATEST_VERSION" == "" ]] | |
then | |
echo "Unable to determine latest version of Skype Call Recorder" | |
exit 0 | |
fi | |
if [[ "$URL" == "" ]] | |
then | |
echo "Unable to determine actual URL for Skype Call Recorder" | |
exit 0 | |
fi | |
# this is where Call Recorder gets installed to | |
INSTALL_TO="/Library/Application Support/EcammVideoPlugins/CallRecorder.plugin" | |
## if Call Recorder is already installed | |
if [[ -e "$INSTALL_TO" ]] | |
then | |
INSTALLED_VERSION=$(defaults read "${INSTALL_TO}/Contents/Info" CFBundleVersion) | |
autoload is-at-least | |
is-at-least "$LATEST_VERSION" "$INSTALLED_VERSION" | |
VERSION_COMPARE="$?" | |
if [[ "$VERSION_COMPARE" == "0" ]] | |
then | |
echo "Call Recorder Up-To-Date ($INSTALLED_VERSION)" | |
exit 0 | |
fi | |
fi | |
FILENAME="$HOME/Downloads/SkypeCallRecorder-${LATEST_VERSION}.zip" | |
if (( $+commands[lynx] )) | |
then | |
# if you have Lynx installed, this will show you release notes | |
(lynx -dump -nomargins -width='10000' -assume_charset=UTF-8 -pseudo_inlines "$RELEASE_NOTES_URL" ; | |
echo "\nSource: <$RELEASE_NOTES_URL>") | tee "$FILENAME:r.txt" | |
else | |
# if you don't have Lynx, a URL to the release notes | |
echo "Release Notes can be found at $RELEASE_NOTES_URL" | tee "$FILENAME:r.txt" | |
fi | |
# The server doesn't do continued downloads, so if we find something where our download is supposed to go, | |
# we need to test it to see if it is a) a working zip file -- which probably means that they've previously | |
# downloaded the file, so we don't need to download it again, or b) an incomplete zip -- which probably | |
# means that the file download has started previously, but did not complete. | |
if [[ -e "$FILENAME" ]] | |
then | |
(command unzip -qqt "$FILENAME" 2>&1) >/dev/null | |
EXIT="$?" | |
if [ "$EXIT" = "0" ] | |
then | |
# echo "$NAME: $FILENAME already exists as valid .zip. Using it." | |
: | |
else | |
# echo "'$FILENAME' exists but is not a valid .zip file. Renaming it and re-downloading it." | |
# Really, we should just delete / trash the file, but I'm loathe to do that on someone else's computer. | |
# so we'll rename it and let them deal with it. | |
zmodload zsh/datetime | |
TIME=`strftime "%Y-%m-%d--%H.%M.%S" "$EPOCHSECONDS"` | |
function timestamp { strftime "%Y-%m-%d--%H.%M.%S" "$EPOCHSECONDS" } | |
mv -vn "$FILENAME" "$HOME/Downloads/SkypeCallRecorder-BROKEN-EXAMINE.${TIME}.${LATEST_VERSION}.zip" | |
exec "$0" | |
fi | |
fi | |
# If we don't have the file, download the file | |
if [[ ! -e "$FILENAME" ]] | |
then | |
# echo "$NAME: Downloading '$URL' to '$FILENAME':" | |
curl --silent -S --continue-at - --fail --location --output "$FILENAME" "$URL" | |
EXIT="$?" | |
## exit 22 means 'the file was already fully downloaded' | |
[ "$EXIT" != "0" -a "$EXIT" != "22" ] && echo "Download failed (EXIT = $EXIT)" && exit 0 | |
[[ ! -e "$FILENAME" ]] && echo "$FILENAME does not exist." && exit 0 | |
[[ ! -s "$FILENAME" ]] && echo "$FILENAME is zero bytes." && rm -f "$FILENAME" && exit 0 | |
fi | |
# Now that we have it downloaded, lets unpack it | |
UNZIP_TO=$(mktemp -d "${TMPDIR-/tmp/}${NAME}-XXXXXXXX") | |
ditto -xk --noqtn "$FILENAME" "$UNZIP_TO" | |
EXIT="$?" | |
if [[ "$EXIT" != "0" ]] | |
then | |
echo "Failed to unzip '$FILENAME'" | |
# show it in Finder | |
open -R "$FILENAME" | |
exit 0 | |
fi | |
# we look for the installer app in the folder we unpacked it to | |
APP=$(find "$UNZIP_TO" -maxdepth 2 -type d -iname 'Install Call Recorder.app' -print) | |
if [[ "$APP" == "" ]] | |
then | |
echo "Failed to find 'Install Call Recorder.app' in '$UNZIP_TO'" | |
exit 0 | |
fi | |
# the app is an installer which needs user intervention, so the most we can do is just open it | |
# if it doesn't open, at least reveal it in the Finder | |
open -W "$APP" || open -R "$APP" | |
exit 0 | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated 2020-10-10 with some better error messaging more suitable for us with Keyboard Maestro.
See https://forum.keyboardmaestro.com/t/call-recorder-update-when-skype-quits-macro-v9-0-6/19812 for more details on how to use this with Keyboard Maestro.