diff --git a/bot/__init__.py b/bot/__init__.py index 62ceb9f8..fd84842c 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -233,33 +233,21 @@ def aria2c_init(): Thread(target=aria2c_init).start() try: - MEGA_KEY = getConfig('MEGA_API_KEY') - if len(MEGA_KEY) == 0: + MEGA_API_KEY = getConfig('MEGA_API_KEY') + if len(MEGA_API_KEY) == 0: raise KeyError except: - MEGA_KEY = None - LOGGER.info('MEGA_API_KEY not provided!') -if MEGA_KEY is not None: - # Start megasdkrest binary - Popen(["megasdkrest", "--apikey", MEGA_KEY]) - sleep(3) # Wait for the mega server to start listening - mega_client = MegaSdkRestClient('http://localhost:6090') - try: - MEGA_USERNAME = getConfig('MEGA_EMAIL_ID') - MEGA_PASSWORD = getConfig('MEGA_PASSWORD') - if len(MEGA_USERNAME) > 0 and len(MEGA_PASSWORD) > 0: - try: - mega_client.login(MEGA_USERNAME, MEGA_PASSWORD) - except mega_err.MegaSdkRestClientException as e: - log_error(e.message['message']) - exit(0) - else: - log_info("Mega API KEY provided but credentials not provided. Starting mega in anonymous mode!") - except: - log_info("Mega API KEY provided but credentials not provided. Starting mega in anonymous mode!") -else: - sleep(1.5) - + log_warning('MEGA API KEY not provided!') + MEGA_API_KEY = None +try: + MEGA_EMAIL_ID = getConfig('MEGA_EMAIL_ID') + MEGA_PASSWORD = getConfig('MEGA_PASSWORD') + if len(MEGA_EMAIL_ID) == 0 or len(MEGA_PASSWORD) == 0: + raise KeyError +except: + log_warning('MEGA Credentials not provided!') + MEGA_EMAIL_ID = None + MEGA_PASSWORD = None try: BASE_URL = getConfig('BASE_URL_OF_BOT').rstrip("/") if len(BASE_URL) == 0: