update MakeMKV beta-key on a Mac

During the beta phase (now ongoing since 2010) a beta key to use MakeMKV without paying a license fee is available in the forum. It usually expires every few weeks and has to be renewed.
I found several scripts and that updated the key on other platforms, in docker-containers or such, but none of them for a Mac. So I started my own. Thanks to @schiermi for providing the right regex for sed (I previously had to use gnu-grep -P from homebrew to adapt a different regex, but rather stick with tools that are part of MacOS):

SETTINGS=~/Library/MakeMKV/settings.conf
cp $SETTINGS $SETTINGS.bak
KEY=$(curl --silent 'https://forum.makemkv.com/forum/viewtopic.php?f=5&t=1053' | sed -n '/code/ { s/.*<code>//; s/<.code>.*//; p; }')
OKEY=$(grep 'app_Key' $SETTINGS| cut -d\" -f2)
if [ "$KEY" = "$OKEY" ]
then
#	echo "Keys identisch"
	exit 0
else
	grep -v 'app_Key' $SETTINGS > $SETTINGS.tmp
	echo 'app_Key = "'$KEY'"' >>$SETTINGS.tmp
	mv $SETTINGS.tmp $SETTINGS
fi

Careful: the script is not thoroughly tested, but works ok here. Feedback highly appreciated. Make sure after copying the script that the line starting with “OKEY” directly follows the line starting with “KEY”, no line breaks in between.

Dec 21st, 2022: had to update the URL to the forum-post


Posted

in

by

Tags: