Skip to content

Instantly share code, notes, and snippets.

@SAL-e
Forked from jvuori/install_makemkv.py
Created October 25, 2017 20:45
Show Gist options
  • Save SAL-e/a95bbd8018879475693182df140cbc42 to your computer and use it in GitHub Desktop.
Save SAL-e/a95bbd8018879475693182df140cbc42 to your computer and use it in GitHub Desktop.
A convenient little script to install MakeMKV on Linux + Python wrapper which determines the version number automatically
import os
import re
import requests
import sys
FORUM_PAGE = 'https://www.makemkv.com/forum2/viewtopic.php?f=3&t=224'
DOWNLOAD_SITE = 'http://www.makemkv.com/download'
FORUM_PAGE_BETA_KEY = 'http://www.makemkv.com/forum2/viewtopic.php?f=5&t=1053'
CONFIG_FILE = os.path.join(
os.path.expanduser('~'),
'.MakeMKV',
'settings.conf')
def get_version():
page_request = requests.get(FORUM_PAGE)
page_request.raise_for_status()
r = re.search(
r'a href="%s/makemkv-bin-(.*?)\.tar\.gz"' % (DOWNLOAD_SITE),
page_request.text)
if not r:
raise RuntimeError('No version found.')
return r.group(1)
def get_beta_key():
page_request = requests.get(FORUM_PAGE_BETA_KEY)
page_request.raise_for_status()
r = re.search(
r'<div class="codecontent">(.*?)</div>',
page_request.text)
if not r:
raise RuntimeError('No beta key found.')
return r.group(1)
def write_beta_key(beta_key):
if os.path.exists(CONFIG_FILE):
with open(CONFIG_FILE) as config_file_obj:
cont = config_file_obj.read()
new_cont = re.sub(
'app_Key = ".*?"',
'app_Key = "%s"' % (beta_key),
cont)
else:
cont = ''
new_cont = 'app_Key = "%s"\n' % (beta_key)
if cont != new_cont:
with open(CONFIG_FILE, 'w') as config_file_obj:
config_file_obj.write(new_cont)
def main():
print('Getting version info from', FORUM_PAGE)
version = get_version()
print('Found version:', version)
print('Getting beta key from', FORUM_PAGE_BETA_KEY)
beta_key = get_beta_key()
print('Found beta key:', beta_key)
print('Installing MakeMKV')
os.system('bash install_makemkv.sh %s' % (version))
print('Writing beta key to', CONFIG_FILE)
write_beta_key(beta_key)
print('All done.')
if __name__ == '__main__':
main()
#!/bin/bash
if [ "$1" == "" ]; then
echo "Usage: $0 1.8.0"
echo "to download and install MakeMKV 1.8.0"
exit 1
fi
# Collect sudo credentials
sudo -v
VER="$1"
TMPDIR=`mktemp -d`
# Install prerequisites
sudo apt-get install build-essential pkg-config libc6-dev libssl-dev libexpat1-dev libavcodec-dev libgl1-mesa-dev libqt4-dev
# Install this version of MakeMKV
pushd $TMPDIR
for PKG in bin oss; do
PKGDIR="makemkv-$PKG-$VER"
PKGFILE="$PKGDIR.tar.gz"
wget "http://www.makemkv.com/download/$PKGFILE"
tar xzf $PKGFILE
pushd $PKGDIR
# pre-1.8.6 version
if [ -e "./makefile.linux" ]; then
make -f makefile.linux
sudo make -f makefile.linux install
# post-1.8.6 version
else
if [ -e "./configure" ]; then
./configure
fi
mkdir tmp
echo -n accepted >tmp/eula_accepted
make
sudo make install
fi
popd
done
popd
# Remove temporary directory
if [ -e "$TMPDIR" ]; then rm -rf $TMPDIR; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment