-
-
Save jvuori/b595b201dbb6bfdbb95d632efaf6474a 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
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
import os | |
import re | |
import requests | |
import sys | |
FORUM_PAGE = 'https://www.makemkv.com/forum/viewtopic.php?f=3&t=224' | |
DOWNLOAD_SITE = 'https://www.makemkv.com/download' | |
FORUM_PAGE_BETA_KEY = 'https://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) | |
# For some reason the server has started to send Loop Detected (HTTP 508) | |
# error code but when ignoring it everything seems to be still working. | |
if page_request.status_code != 508: | |
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'<code>(.*?)</code>', | |
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: | |
os.makedirs(os.path.dirname(CONFIG_FILE)) | |
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() |
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 | |
set -e | |
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 -y build-essential pkg-config libc6-dev libssl-dev libexpat1-dev libavcodec-dev libgl1-mesa-dev qtbase5-dev zlib1g-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 |
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
requests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment