Skip to content

Commit eee29c3

Browse files
Merge pull request #196 from hockeygoalie35/main
ARLChecker v1.4 - Python script shows correct version
2 parents 4dc2284 + d60015a commit eee29c3

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

lidarr/ARLChecker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/with-contenv bash
22
### Default values
3-
scriptVersion="1.3"
3+
scriptVersion="1.4"
44
scriptName="ARLChecker"
55
sleepInterval='24h'
66
### Import Settings

lidarr/python/ARLChecker.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
import os
1212
from datetime import datetime
1313

14+
# Pull script version from bash script. will likely change this to a var passthrough
15+
with open("/custom-services.d/ARLChecker", "r") as r:
16+
for line in r:
17+
if 'scriptVersion' in line:
18+
VERSION = re.search(r'"([A-Za-z0-9_\./\\-]*)"', line)[0].replace('"','')
1419

15-
VERSION = 0.1
1620

1721
# Logging Setup
1822
logging.basicConfig(
@@ -86,25 +90,25 @@ def login(self, username, secret):
8690
)
8791
res.raise_for_status()
8892
except Exception as error:
89-
logger.error(Fore.RED + 'Could not connect! Service down, API changed, wrong credentials or code-related issue.' + Fore.WHITE)
93+
logger.error(Fore.RED + 'Could not connect! Service down, API changed, wrong credentials or code-related issue.' + Fore.LIGHTWHITE_EX)
9094
raise ConnectionError()
9195

9296
self.session.cookies.clear()
9397

9498
try:
9599
res = res.json()
96100
except Exception as error:
97-
logger.error(Fore.RED + "Could not parse JSON response from DEEZER!" + Fore.WHITE)
101+
logger.error(Fore.RED + "Could not parse JSON response from DEEZER!" + Fore.LIGHTWHITE_EX)
98102
raise ParseError()
99103

100104
if 'error' in res and res['error']:
101-
logger.error(Fore.RED + "Deezer returned the following error:{}".format(res["error"]) + Fore.WHITE)
105+
logger.error(Fore.RED + "Deezer returned the following error:{}".format(res["error"]) + Fore.LIGHTWHITE_EX)
102106
raise ServiceError()
103107

104108
res = res['results']
105109

106110
if res['USER']['USER_ID'] == 0:
107-
logger.error(Fore.RED+"ARL Token Expired. Update the token in extended.conf"+Fore.WHITE)
111+
logger.error(Fore.RED+"ARL Token Expired. Update the token in extended.conf"+Fore.LIGHTWHITE_EX)
108112
raise AuthError()
109113

110114
return Account(username, secret, res['COUNTRY'], Plan(
@@ -199,7 +203,7 @@ def parse_extended_conf(self):
199203
def check_token(self, token=None):
200204
logger.info('Checking ARL Token Validity...')
201205
if token == '""':
202-
logger.info(Fore.YELLOW+"No ARL Token set in Extended.conf"+Fore.WHITE)
206+
logger.info(Fore.YELLOW+"No ARL Token set in Extended.conf"+Fore.LIGHTWHITE_EX)
203207
self.report_status("NOT SET")
204208
exit(0)
205209
if token is None:
@@ -209,14 +213,14 @@ def check_token(self, token=None):
209213
deezer_check = DeezerPlatformProvider()
210214
account = deezer_check.login('', token.replace('"',''))
211215
if account.plan:
212-
logger.info(Fore.GREEN + f'Deezer Account Found.'+ Fore.WHITE)
216+
logger.info(Fore.GREEN + f'Deezer Account Found.'+ Fore.LIGHTWHITE_EX)
213217
logger.info('-------------------------------')
214218
logger.info(f'Plan: {account.plan.name}')
215219
logger.info(f'Expiration: {account.plan.expires}')
216-
logger.info(f'Active: {Fore.GREEN+"Y" if account.plan.active else "N"}'+Fore.WHITE)
217-
logger.info(f'Download: {Fore.GREEN+"Y" if account.plan.download else Fore.RED+"N"}'+Fore.WHITE)
218-
logger.info(f'Lossless: {Fore.GREEN+"Y" if account.plan.lossless else Fore.RED+"N"}'+Fore.WHITE)
219-
logger.info(f'Explicit: {Fore.GREEN+"Y" if account.plan.explicit else Fore.RED+"N"}'+Fore.WHITE)
220+
logger.info(f'Active: {Fore.GREEN+"Y" if account.plan.active else "N"}'+Fore.LIGHTWHITE_EX)
221+
logger.info(f'Download: {Fore.GREEN+"Y" if account.plan.download else Fore.RED+"N"}'+Fore.LIGHTWHITE_EX)
222+
logger.info(f'Lossless: {Fore.GREEN+"Y" if account.plan.lossless else Fore.RED+"N"}'+Fore.LIGHTWHITE_EX)
223+
logger.info(f'Explicit: {Fore.GREEN+"Y" if account.plan.explicit else Fore.RED+"N"}'+Fore.LIGHTWHITE_EX)
220224
logger.info('-------------------------------')
221225
self.report_status('VALID')
222226
return True
@@ -353,9 +357,9 @@ def main(arlToken = None):
353357
arlToken_instance.check_token(arlToken_instance.arlToken)
354358
except Exception as e:
355359
if 'Chat not found' in str(e):
356-
logger.error(Fore.RED + "Chat not found. Check your chat ID in extended.conf, or start a chat with your bot."+Fore.WHITE)
360+
logger.error(Fore.RED + "Chat not found. Check your chat ID in extended.conf, or start a chat with your bot."+Fore.LIGHTWHITE_EX)
357361
elif 'The token' in str(e):
358-
logger.error(Fore.RED + "Check your Bot Token in extended.conf."+Fore.WHITE)
362+
logger.error(Fore.RED + "Check your Bot Token in extended.conf."+Fore.LIGHTWHITE_EX)
359363
else:
360364
print(e)
361365
exit(1)

0 commit comments

Comments
 (0)