diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b615254 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +qrcodes/ +__pycache__ +secret_key.txt +ssl_cert.pem +ssl_key.key +.log +.config \ No newline at end of file diff --git a/asmara.py b/asmara.py index f5d8f8b..7676447 100644 --- a/asmara.py +++ b/asmara.py @@ -3,6 +3,8 @@ """ # Standard Library from datetime import datetime as DT +from datetime import timezone as TZ +from datetime import timedelta as timedelta from json import dump, load from multiprocessing import Process, active_children from os import getcwd, path, remove, walk @@ -32,6 +34,7 @@ from pydub.generators import Sine from pydub.utils import make_chunks, mediainfo from requests import get, exceptions +from calendar import isleap # First-Party from utilities import utilities, severity @@ -243,21 +246,8 @@ def __decoder__(self): sev=severity.trace, ) try: - if not ( - "samedec 0.1." - in Popen(["samedec", "-V"], stdout=PIPE) - .communicate()[0] - .decode("UTF-8") - .strip() - ): - utilities.autoPrint( - text=f"SAMEDEC is not version 0.2 or higher! Recommended version is 0.2.3.", - classType="DECODER", - sev=severity.fatal, - ) - AS_MAN.killAsmara() - exit(1) - else: + samedec_version = Popen(["samedec", "-V"], stdout=PIPE).communicate()[0].decode("UTF-8").strip() + if not samedec_version.startswith("samedec 0.1."): self.__decode__ = Popen( ["samedec", "-r", "24000"], stdout=PIPE, @@ -265,6 +255,14 @@ def __decoder__(self): stderr=PIPE, bufsize=1, ) + else: + utilities.autoPrint( + text=f"SAMEDEC is not version 0.2 or higher! Recommended version is 0.2.3.", + classType="DECODER", + sev=severity.fatal, + ) + AS_MAN.killAsmara() + exit(1) except FileNotFoundError: utilities.autoPrint( text=f"Samedec is not installed on the computer. Please install SAMEDEC 0.2.3 or higher.", @@ -326,7 +324,20 @@ def __decoder__(self): x = DT.strptime( decode.split("-")[-3], "%j%H%M" ) + expiryOffset = 0 timeStamp = decode.split("-")[-4].split("+")[1] + currDate = DT.now(TZ.utc) + currYear = currDate.today().year + leapDate = f"2/29/{currYear}" + if isleap(currYear): + if DT.now(TZ.utc).strftime('%Y-%m-%d') > DT.strptime(leapDate,"%m/%d/%Y").strftime('%Y-%m-%d'): + expiryOffset = 86400 + elif DT.now(TZ.utc).strftime('%Y-%m-%d') == DT.strptime(leapDate,"%m/%d/%Y").strftime('%Y-%m-%d'): + midnight = (DT.now(TZ.utc) + timedelta(days=1)).replace(hour=0, minute=0, microsecond=0, second=0) + expiryOffset = 86400 - (DT.now(TZ.utc) - midnight).seconds + print(expiryOffset) + else: + expiryOffset = 0 startTime = mktime( DT( DT.utcnow().year, @@ -340,7 +351,7 @@ def __decoder__(self): (int(timeStamp[:2]) * 60) * 60 + int(timeStamp[2:]) * 60 ) - now = mktime(DT.utcnow().timetuple()) + now = mktime(DT.utcnow().timetuple()) + expiryOffset filt = self.__FilterManager__( headerTranslation.org, headerTranslation.evnt,