Skip to content

Instantly share code, notes, and snippets.

@camjac251
Created November 24, 2022 11:49
Show Gist options
  • Save camjac251/6f991aafc9a57eed8f9a74336c4888bf to your computer and use it in GitHub Desktop.
Save camjac251/6f991aafc9a57eed8f9a74336c4888bf to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import json
import re
import requests
from os import environ, path
# Environment configurations
APP_KEY = environ.get('APP_KEY')
APP_KEY_FILE = '/BETA_KEY'
SETTINGS_FILE = path.join(path.expanduser('~'), '.MakeMKV/settings.conf')
settings = {}
if not APP_KEY:
try:
with open(APP_KEY_FILE, 'r') as fh:
APP_KEY = fh.read().strip()
except IOError:
# Key file is not present
pass
if not APP_KEY:
response = requests.get(
'http://www.makemkv.com/forum/viewtopic.php?f=5&t=1053',
)
matches = re.search(
'<code>(?P<key>.+?)</code>',
response.text,
)
APP_KEY = matches.group('key')
settings.update({
'app_Key': APP_KEY,
})
with open(SETTINGS_FILE, 'w') as fh:
for key, val in settings.items():
fh.write('%s = "%s"' % (key, val))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment