Created
November 24, 2022 11:49
-
-
Save camjac251/6f991aafc9a57eed8f9a74336c4888bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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/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