Merge pull request #196 from hockeygoalie35/main

ARLChecker v1.4 - Python script shows correct version
This commit is contained in:
RandomNinjaAtk 2024-02-13 10:18:46 -05:00 committed by GitHub
commit eee29c3d5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 14 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/with-contenv bash #!/usr/bin/with-contenv bash
### Default values ### Default values
scriptVersion="1.3" scriptVersion="1.4"
scriptName="ARLChecker" scriptName="ARLChecker"
sleepInterval='24h' sleepInterval='24h'
### Import Settings ### Import Settings

View file

@ -11,8 +11,12 @@ import logging
import os import os
from datetime import datetime from datetime import datetime
# Pull script version from bash script. will likely change this to a var passthrough
with open("/custom-services.d/ARLChecker", "r") as r:
for line in r:
if 'scriptVersion' in line:
VERSION = re.search(r'"([A-Za-z0-9_\./\\-]*)"', line)[0].replace('"','')
VERSION = 0.1
# Logging Setup # Logging Setup
logging.basicConfig( logging.basicConfig(
@ -86,7 +90,7 @@ class DeezerPlatformProvider:
) )
res.raise_for_status() res.raise_for_status()
except Exception as error: except Exception as error:
logger.error(Fore.RED + 'Could not connect! Service down, API changed, wrong credentials or code-related issue.' + Fore.WHITE) logger.error(Fore.RED + 'Could not connect! Service down, API changed, wrong credentials or code-related issue.' + Fore.LIGHTWHITE_EX)
raise ConnectionError() raise ConnectionError()
self.session.cookies.clear() self.session.cookies.clear()
@ -94,17 +98,17 @@ class DeezerPlatformProvider:
try: try:
res = res.json() res = res.json()
except Exception as error: except Exception as error:
logger.error(Fore.RED + "Could not parse JSON response from DEEZER!" + Fore.WHITE) logger.error(Fore.RED + "Could not parse JSON response from DEEZER!" + Fore.LIGHTWHITE_EX)
raise ParseError() raise ParseError()
if 'error' in res and res['error']: if 'error' in res and res['error']:
logger.error(Fore.RED + "Deezer returned the following error:{}".format(res["error"]) + Fore.WHITE) logger.error(Fore.RED + "Deezer returned the following error:{}".format(res["error"]) + Fore.LIGHTWHITE_EX)
raise ServiceError() raise ServiceError()
res = res['results'] res = res['results']
if res['USER']['USER_ID'] == 0: if res['USER']['USER_ID'] == 0:
logger.error(Fore.RED+"ARL Token Expired. Update the token in extended.conf"+Fore.WHITE) logger.error(Fore.RED+"ARL Token Expired. Update the token in extended.conf"+Fore.LIGHTWHITE_EX)
raise AuthError() raise AuthError()
return Account(username, secret, res['COUNTRY'], Plan( return Account(username, secret, res['COUNTRY'], Plan(
@ -199,7 +203,7 @@ class LidarrExtendedAPI:
def check_token(self, token=None): def check_token(self, token=None):
logger.info('Checking ARL Token Validity...') logger.info('Checking ARL Token Validity...')
if token == '""': if token == '""':
logger.info(Fore.YELLOW+"No ARL Token set in Extended.conf"+Fore.WHITE) logger.info(Fore.YELLOW+"No ARL Token set in Extended.conf"+Fore.LIGHTWHITE_EX)
self.report_status("NOT SET") self.report_status("NOT SET")
exit(0) exit(0)
if token is None: if token is None:
@ -209,14 +213,14 @@ class LidarrExtendedAPI:
deezer_check = DeezerPlatformProvider() deezer_check = DeezerPlatformProvider()
account = deezer_check.login('', token.replace('"','')) account = deezer_check.login('', token.replace('"',''))
if account.plan: if account.plan:
logger.info(Fore.GREEN + f'Deezer Account Found.'+ Fore.WHITE) logger.info(Fore.GREEN + f'Deezer Account Found.'+ Fore.LIGHTWHITE_EX)
logger.info('-------------------------------') logger.info('-------------------------------')
logger.info(f'Plan: {account.plan.name}') logger.info(f'Plan: {account.plan.name}')
logger.info(f'Expiration: {account.plan.expires}') logger.info(f'Expiration: {account.plan.expires}')
logger.info(f'Active: {Fore.GREEN+"Y" if account.plan.active else "N"}'+Fore.WHITE) logger.info(f'Active: {Fore.GREEN+"Y" if account.plan.active else "N"}'+Fore.LIGHTWHITE_EX)
logger.info(f'Download: {Fore.GREEN+"Y" if account.plan.download else Fore.RED+"N"}'+Fore.WHITE) logger.info(f'Download: {Fore.GREEN+"Y" if account.plan.download else Fore.RED+"N"}'+Fore.LIGHTWHITE_EX)
logger.info(f'Lossless: {Fore.GREEN+"Y" if account.plan.lossless else Fore.RED+"N"}'+Fore.WHITE) logger.info(f'Lossless: {Fore.GREEN+"Y" if account.plan.lossless else Fore.RED+"N"}'+Fore.LIGHTWHITE_EX)
logger.info(f'Explicit: {Fore.GREEN+"Y" if account.plan.explicit else Fore.RED+"N"}'+Fore.WHITE) logger.info(f'Explicit: {Fore.GREEN+"Y" if account.plan.explicit else Fore.RED+"N"}'+Fore.LIGHTWHITE_EX)
logger.info('-------------------------------') logger.info('-------------------------------')
self.report_status('VALID') self.report_status('VALID')
return True return True
@ -353,9 +357,9 @@ def main(arlToken = None):
arlToken_instance.check_token(arlToken_instance.arlToken) arlToken_instance.check_token(arlToken_instance.arlToken)
except Exception as e: except Exception as e:
if 'Chat not found' in str(e): if 'Chat not found' in str(e):
logger.error(Fore.RED + "Chat not found. Check your chat ID in extended.conf, or start a chat with your bot."+Fore.WHITE) logger.error(Fore.RED + "Chat not found. Check your chat ID in extended.conf, or start a chat with your bot."+Fore.LIGHTWHITE_EX)
elif 'The token' in str(e): elif 'The token' in str(e):
logger.error(Fore.RED + "Check your Bot Token in extended.conf."+Fore.WHITE) logger.error(Fore.RED + "Check your Bot Token in extended.conf."+Fore.LIGHTWHITE_EX)
else: else:
print(e) print(e)
exit(1) exit(1)