mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-01-23 09:16:25 +01:00
check search pdfs
This commit is contained in:
parent
9a6d08d2e1
commit
3f83f1c44a
@ -8,6 +8,7 @@ import threading
|
||||
import socket
|
||||
import os
|
||||
|
||||
import pypdf
|
||||
import googlesearch
|
||||
|
||||
from .db import get_db
|
||||
@ -52,12 +53,17 @@ def local_search(query, partitions):
|
||||
def download_search_result(element, instance_path):
|
||||
uuid = element["uuid"]
|
||||
url = element["url"]
|
||||
filename = f"{instance_path}/search-partitions/{uuid}.pdf"
|
||||
|
||||
try:
|
||||
urllib.request.urlretrieve(url, f"{instance_path}/search-partitions/{uuid}.pdf")
|
||||
urllib.request.urlretrieve(url, filename)
|
||||
pypdf.PdfReader(filename)
|
||||
|
||||
except (urllib.error.HTTPError, urllib.error.URLError):
|
||||
with open(f"{instance_path}/search-partitions/{uuid}.pdf", 'a', encoding="utf8") as _:
|
||||
except (urllib.error.HTTPError, urllib.error.URLError,
|
||||
pypdf.errors.PdfReadError, pypdf.errors.PdfStreamError):
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
with open(filename, 'a', encoding="utf8") as _:
|
||||
pass # Create empty file
|
||||
|
||||
|
||||
|
@ -2,4 +2,5 @@ flask
|
||||
flask-babel
|
||||
google
|
||||
colorama
|
||||
pypdf
|
||||
qrcode
|
@ -179,4 +179,12 @@ def move_thumbnails():
|
||||
|
||||
|
||||
def install_babel():
|
||||
utils.install_package("flask-babel")
|
||||
utils.install_package("flask-babel")
|
||||
|
||||
|
||||
"""
|
||||
v1.8.*
|
||||
"""
|
||||
|
||||
def install_pypdf():
|
||||
utils.install_package("pypdf")
|
@ -35,7 +35,8 @@ hooks = [
|
||||
("v1.4.1", [("Install qrcode", v1_hooks.install_qrcode)]),
|
||||
("v1.5.0", [("Move to instance directory", v1_hooks.move_instance)]),
|
||||
("v1.5.1", [("Move thumbnails", v1_hooks.move_thumbnails)]),
|
||||
("v1.7.0", [("Install babel", v1_hooks.install_babel)])
|
||||
("v1.7.0", [("Install babel", v1_hooks.install_babel)]),
|
||||
("v1.8.2", [("Install pypdf", v1_hooks.install_pypdf)])
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user