preformence improvement

This commit is contained in:
2023-04-25 12:11:12 +03:00
parent 116858bf48
commit d9dfaaa68c
2 changed files with 9 additions and 5 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.vscode/
venv/
venv/
ignore/

View File

@@ -76,7 +76,10 @@ def do_action_now(index: int):
files = list(SOURCES[index])
for s in SOURCES[index]:
if SOURCES[index][s]:
files[files.index(s)] = urllib3.PoolManager().request("GET", SOURCES[index][s]).data
if not os.path.exists(f"ignore/{files.index(s):04}.jpg"):
with open(f"ignore/{files.index(s):04}.jpg","wb") as F:
F.write(urllib3.PoolManager().request("GET", SOURCES[index][s]).data)
# files[files.index(s)] = urllib3.PoolManager().request("GET", SOURCES[index][s]).data
return files
# def check_and_act(index: int,last):
@@ -110,15 +113,15 @@ def act_now(index: int, path: str = None):
url_now = url_now[:url_now.find("#")+1] + save_first
if SOURCES[index][last] and "" in SOURCES[index].values():
ACTS[index]._driver.get(url_now)
pages = do_action_now(index)
do_action_now(index)
SOURCES[index][last] = ""
else:
pages = do_action_now(index)
do_action_now(index)
if SOURCES[index] and "" not in SOURCES[index].values():
couters += 1
pathus = f'{path}/{name}.pdf' if path else f"ignore/{name}/{name}.pdf"
with open(pathus, "wb") as file:
file.write(img2pdf.convert(pages))
file.write(img2pdf.convert(glob.glob(f"ignore/{name}/*jpg")))
ACTS[index]._driver.quit()
remove_text(OLD_REMOVE[index])
treads -= 1