feat(integration): integration is fully finished, will refractor later

This commit is contained in:
devaine 2026-02-02 19:17:44 -06:00
commit 2491eae95f
Signed by: devaine
GPG key ID: 954B1DCAC6FF84EE
5 changed files with 171 additions and 47 deletions

View file

@ -12,7 +12,7 @@ LOGIN_LINK = os.getenv("LOGIN_LINK")
ACCOUNT_LINK = os.getenv("ACCOUNT_LINK")
def main(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
browser = playwright.chromium.launch(headless=True)
context = browser.new_context()
page = context.new_page()
@ -28,10 +28,27 @@ def main(playwright: Playwright) -> None:
page.get_by_role("button", name="Text").click()
page.get_by_test_id("text-field").click()
# Bank prompts 2FA (hopefully only once)
two_fac = input("2FA Code: ")
# Bank prompts 2FA (hopefully only once) in this meantime
page.get_by_test_id("text-field").fill(two_fac)
two_fac_code = ""
# Write/Overwrite an empty 2FA file
with open("./2fa", "w") as two_fac:
two_fac.write("")
with open("./2fa", "r") as two_fac:
line = two_fac.readline()
print(line)
while line == "":
print("2FA code hasn't been entered, make sure to enter code in ./2fa !")
print("Retrying in 5 seconds...")
sleep(5)
line = two_fac.readline()
two_fac_code = line
print("2FA Code Found: " + two_fac_code)
page.get_by_test_id("text-field").fill(two_fac_code)
page.get_by_test_id("private-button").click()
# Wait for everything to load...

View file

@ -1,49 +1,87 @@
from playwright.sync_api import sync_playwright
from threading import Thread
import os
import extract
#from datetime import datetime
import difflib
from datetime import datetime
from time import sleep
from multiprocessing import Process
# Playwright in the background
def playwright():
print("Starting Playwright")
with sync_playwright() as playwright:
extract.main(playwright)
def revise():
# Removes the OLDEST file on the list ()
file_count = 0
for file in os.scandir("./qfx"):
print(file_count)
if file_count > 1:
#print(os.listdir("./qfx"))
print("Removed: " + os.listdir("./qfx")[0])
os.remove("./qfx/" + os.listdir("./qfx")[0])
print("Starting Revision")
while (True):
with open("./data/output", "w") as output:
output.write("")
if file.is_file():
file_count += 1
# Removes the OLDEST file on the list ()
file_count = 0
for file in os.scandir("./qfx"):
#print(file_count)
if file_count > 1:
#print(os.listdir("./qfx"))
print("Removed: " + os.listdir("./qfx")[0])
os.remove("./qfx/" + os.listdir("./qfx")[0])
# Get the last two files
oldest_file = open("./qfx/" + os.listdir("./qfx")[0])
newest_file = open("./qfx/" + os.listdir("./qfx")[-1])
# Differs the two files
diff = difflib.ndiff(oldest_file.readlines(), newest_file.readlines())
if file.is_file():
file_count += 1
# Thanks to: https://stackoverflow.com/a/33657921
# Find the <DTEND> for the newest files
# Grabs all starting and ending transaction indexes aswell as the time of the latest transaction
start = []
end = []
latest_trans_time = datetime.now()
with open("./qfx/" + os.listdir("./qfx")[-1]) as newest_file:
num = 0
# Find the number and line under a object that supports iteration
for num, line in enumerate(newest_file, 1):
if "DTEND" in line:
time_string = line.strip()[7:-8]
year = int(time_string[0:4])
month = int(time_string[5:6])
day = int(time_string[6:8])
latest_trans_time.replace(year, month, day)
num = str(num)
# TODO: The idea is to find a way to grab all data relating to latest_trans_time WITHIN <STMTTRN>
if "<STMTTRN>" in line:
start.append(num-1)
if "</STMTTRN>" in line:
end.append(num)
# Seperates all transactions to the latest ones to ./data/output
with open("./qfx/" + os.listdir("./qfx")[-1]) as newest_file:
lines = newest_file.read().splitlines()
for i in range(len(start)):
ST_BEGINS = start[i]
ST_ENDS = end[i]
with open("./data/output", "a") as output:
# NOTE: Puts all data from <STMTTRN> to </STMTTRN> into its individual line
output.write("\n".join(lines[ST_BEGINS:ST_ENDS]).replace(" ", "").replace("\t", ""))
output.write("\n")
# Wait a minute before executing again
print("Done with revision!")
sleep(60)
# Grabs only changes
# Thanks to: https://stackoverflow.com/a/15864920
changes = [l for l in diff if l.startswith("+ ") or l.startswith('- ')]
print("RESULT:")
for change in changes:
print(change[2:])
def main():
revise_thread = Thread(target=revise())
#pw_thread = Thread(target=playwright())
#pw_thread.start()
revise_thread.start()
pw_proc = Process(target=playwright)
pw_proc.start()
revise_proc = Process(target=revise)
revise_proc.start()
if __name__ == "__main__":