mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
added sizelist cache
This commit is contained in:
@@ -63,7 +63,7 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Python Debugger: Current File",
|
"name": "Testfolder",
|
||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/builder.py",
|
"program": "${workspaceFolder}/builder.py",
|
||||||
@@ -81,6 +81,26 @@
|
|||||||
"-n"
|
"-n"
|
||||||
],
|
],
|
||||||
"postDebugTask": "Delete Lockfile"
|
"postDebugTask": "Delete Lockfile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "woek",
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/builder.py",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"args": [
|
||||||
|
"-p",
|
||||||
|
"/home/user/woek/Pictures",
|
||||||
|
"-w",
|
||||||
|
"file:///home/user/woek/Pictures",
|
||||||
|
"-t",
|
||||||
|
"Pictures",
|
||||||
|
"--theme",
|
||||||
|
"themes/kjoe.css",
|
||||||
|
"--use-fancy-folders",
|
||||||
|
"-n"
|
||||||
|
],
|
||||||
|
"postDebugTask": "Delete Lockfile 2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -93,6 +113,13 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"isBackground": true
|
"isBackground": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Delete Lockfile 2",
|
||||||
|
"command": "rm -f /home/user/woek/Pictures/.lock",
|
||||||
|
"type": "shell",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"isBackground": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
13
builder.py
13
builder.py
@@ -26,7 +26,7 @@ DEFAULT_AUTHOR = "Author"
|
|||||||
VERSION = "1.8.0"
|
VERSION = "1.8.0"
|
||||||
RAW_EXTENSIONS = [".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr", ".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".tif", ".tiff", ".x3f"]
|
RAW_EXTENSIONS = [".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr", ".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".tif", ".tiff", ".x3f"]
|
||||||
IMG_EXTENSIONS = [".jpg", ".jpeg"]
|
IMG_EXTENSIONS = [".jpg", ".jpeg"]
|
||||||
EXCLUDES = [".lock", "index.html", ".thumbnails", ".static"]
|
EXCLUDES = [".lock", "index.html", "sizelist.json", ".thumbnails", ".static"]
|
||||||
NOT_LIST = ["*/Galleries/*", "Archives"]
|
NOT_LIST = ["*/Galleries/*", "Archives"]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
@@ -141,8 +141,11 @@ def get_total_folders(folder: str, _total: int = 0) -> int:
|
|||||||
|
|
||||||
def list_folder(folder: str, title: str) -> None:
|
def list_folder(folder: str, title: str) -> None:
|
||||||
sizelist: Dict[Dict[str, int], Dict[str, int]] = {}
|
sizelist: Dict[Dict[str, int], Dict[str, int]] = {}
|
||||||
with open(os.path.join(folder, "sizelist.json"), "w+", encoding="utf-8") as sizelistfile:
|
with open(os.path.join(folder, "sizelist.json"), "r+", encoding="utf-8") as sizelistfile:
|
||||||
sizelist = json.loads(sizelistfile.read())
|
try:
|
||||||
|
sizelist = json.loads(sizelistfile.read())
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
sizelist = {}
|
||||||
items = os.listdir(folder)
|
items = os.listdir(folder)
|
||||||
items.sort()
|
items.sort()
|
||||||
images: List[Dict[str, Any]] = []
|
images: List[Dict[str, Any]] = []
|
||||||
@@ -172,11 +175,9 @@ def list_folder(folder: str, title: str) -> None:
|
|||||||
contains_files = True
|
contains_files = True
|
||||||
if extsplit[1].lower() in args.file_extensions:
|
if extsplit[1].lower() in args.file_extensions:
|
||||||
if not sizelist.get(item):
|
if not sizelist.get(item):
|
||||||
print("fuck")
|
|
||||||
with Image.open(os.path.join(folder, item)) as img:
|
with Image.open(os.path.join(folder, item)) as img:
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
sizelist[item] = {"width": width, "height": height}
|
sizelist[item] = {"width": width, "height": height}
|
||||||
print(sizelist)
|
|
||||||
|
|
||||||
image = {
|
image = {
|
||||||
"url": f"{args.web_root_url}{baseurl}{urllib.parse.quote(item)}",
|
"url": f"{args.web_root_url}{baseurl}{urllib.parse.quote(item)}",
|
||||||
@@ -202,7 +203,9 @@ def list_folder(folder: str, title: str) -> None:
|
|||||||
if not args.non_interactive_mode:
|
if not args.non_interactive_mode:
|
||||||
imgpbar.update(1)
|
imgpbar.update(1)
|
||||||
pbar.update(0)
|
pbar.update(0)
|
||||||
|
sizelistfile.seek(0)
|
||||||
sizelistfile.write(json.dumps(sizelist, indent=4))
|
sizelistfile.write(json.dumps(sizelist, indent=4))
|
||||||
|
sizelistfile.truncate()
|
||||||
if not contains_files and not args.use_fancy_folders:
|
if not contains_files and not args.use_fancy_folders:
|
||||||
return
|
return
|
||||||
if images or (args.use_fancy_folders and not contains_files) or (args.use_fancy_folders and args.ignore_other_files):
|
if images or (args.use_fancy_folders and not contains_files) or (args.use_fancy_folders and args.ignore_other_files):
|
||||||
|
|||||||
Reference in New Issue
Block a user