From 2f7c2ef4ad9d0d15f1efbcc61cfb237a55eb531c Mon Sep 17 00:00:00 2001 From: Reggie Torres Date: Sat, 9 Mar 2024 22:52:39 -0500 Subject: [PATCH 1/4] fix samedec check (again) (very dumb fix someone make it better soon) (#39) * Add Contribution Tutorial * Fix Samedec Check (very dumb fix someone edit it later) * fix the fatal mistake called a string is always true * gitignore update * make it less dumb --- .gitignore | 7 +++++++ asmara.py | 25 ++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 .gitignore 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..beba5e0 100644 --- a/asmara.py +++ b/asmara.py @@ -243,21 +243,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 +252,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.", From 4361c406289e67895eaf40eed5b70ab55f72aa10 Mon Sep 17 00:00:00 2001 From: Skylar Gray Date: Wed, 26 Jun 2024 02:08:13 -0700 Subject: [PATCH 2/4] Added leap year detection and correction. --- asmara.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/asmara.py b/asmara.py index beba5e0..bf84a42 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 @@ -33,6 +35,9 @@ from pydub.utils import make_chunks, mediainfo from requests import get, exceptions +#couldnt find the aboslute import for the function used here +import calendar as Calendar + # First-Party from utilities import utilities, severity @@ -322,6 +327,18 @@ def __decoder__(self): decode.split("-")[-3], "%j%H%M" ) timeStamp = decode.split("-")[-4].split("+")[1] + currDate = DT.now(TZ.utc) + currYear = currDate.today().year + leapDate = f"2/29/{currYear}" + if Calendar.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, @@ -335,7 +352,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, From cc40f8f2993f75e380c40ad73556babd17936344 Mon Sep 17 00:00:00 2001 From: Skylar Gray Date: Wed, 26 Jun 2024 02:14:36 -0700 Subject: [PATCH 3/4] Making expiryOffset equal 0 before setting to make sure non-leap years don't break --- asmara.py | 1 + 1 file changed, 1 insertion(+) diff --git a/asmara.py b/asmara.py index bf84a42..6b7d366 100644 --- a/asmara.py +++ b/asmara.py @@ -326,6 +326,7 @@ 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 From 7dcfe25ced0b6dd5458301d5d4ed28d125e7b6f3 Mon Sep 17 00:00:00 2001 From: Skylar Gray Date: Wed, 26 Jun 2024 14:37:22 -0700 Subject: [PATCH 4/4] making requested changes --- asmara.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/asmara.py b/asmara.py index 6b7d366..7676447 100644 --- a/asmara.py +++ b/asmara.py @@ -34,9 +34,7 @@ from pydub.generators import Sine from pydub.utils import make_chunks, mediainfo from requests import get, exceptions - -#couldnt find the aboslute import for the function used here -import calendar as Calendar +from calendar import isleap # First-Party from utilities import utilities, severity @@ -331,7 +329,7 @@ def __decoder__(self): currDate = DT.now(TZ.utc) currYear = currDate.today().year leapDate = f"2/29/{currYear}" - if Calendar.isleap(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'):