mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
except TypeError
This commit is contained in:
@@ -185,20 +185,20 @@ def get_image_info(item: str, folder: str) -> dict[str, Any]:
|
|||||||
xmp = None
|
xmp = None
|
||||||
if xmpdata:
|
if xmpdata:
|
||||||
logger.info("extracting XMP data", extra={"file": file})
|
logger.info("extracting XMP data", extra={"file": file})
|
||||||
if xmpdata.get("xmpmeta", False):
|
try:
|
||||||
if isinstance(xmpdata["xmpmeta"]["RDF"]["Description"], dict):
|
|
||||||
if xmpdata["xmpmeta"]["RDF"]["Description"].get("subject", False):
|
|
||||||
tags = xmpdata["xmpmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"]
|
tags = xmpdata["xmpmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"]
|
||||||
if isinstance(tags, str):
|
if isinstance(tags, str):
|
||||||
tags = [tags]
|
tags = [tags]
|
||||||
xmp = xmpdata
|
xmp = xmpdata
|
||||||
if xmpdata.get("xapmeta", False):
|
except TypeError:
|
||||||
if isinstance(xmpdata["xapmeta"]["RDF"]["Description"], dict):
|
...
|
||||||
if xmpdata["xapmeta"]["RDF"]["Description"].get("subject", False):
|
try:
|
||||||
tags = xmpdata["xapmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"]
|
tags = xmpdata["xapmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"]
|
||||||
if isinstance(tags, str):
|
if isinstance(tags, str):
|
||||||
tags = [tags]
|
tags = [tags]
|
||||||
xmp = xmpdata
|
xmp = xmpdata
|
||||||
|
except TypeError:
|
||||||
|
...
|
||||||
if None in tags:
|
if None in tags:
|
||||||
tags.remove(None)
|
tags.remove(None)
|
||||||
return {"width": width, "height": height, "tags": tags, "exifdata": exifdata, "xmp": xmp}
|
return {"width": width, "height": height, "tags": tags, "exifdata": exifdata, "xmp": xmp}
|
||||||
@@ -219,18 +219,20 @@ def get_tags(sidecarfile: str) -> list[str]:
|
|||||||
strbuffer = sidecar.read()
|
strbuffer = sidecar.read()
|
||||||
xmpdata = getxmp(strbuffer)
|
xmpdata = getxmp(strbuffer)
|
||||||
tags = []
|
tags = []
|
||||||
if xmpdata.get("xmpmeta", False):
|
try:
|
||||||
if isinstance(xmpdata["xmpmeta"]["RDF"]["Description"], dict):
|
|
||||||
if xmpdata["xmpmeta"]["RDF"]["Description"].get("subject", False):
|
|
||||||
tags = xmpdata["xmpmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"]
|
tags = xmpdata["xmpmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"]
|
||||||
if isinstance(tags, str):
|
if isinstance(tags, str):
|
||||||
tags = [tags]
|
tags = [tags]
|
||||||
if xmpdata.get("xapmeta", False):
|
xmp = xmpdata
|
||||||
if isinstance(xmpdata["xapmeta"]["RDF"]["Description"], dict):
|
except TypeError:
|
||||||
if xmpdata["xapmeta"]["RDF"]["Description"].get("subject", False):
|
...
|
||||||
|
try:
|
||||||
tags = xmpdata["xapmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"]
|
tags = xmpdata["xapmeta"]["RDF"]["Description"]["subject"]["Bag"]["li"]
|
||||||
if isinstance(tags, str):
|
if isinstance(tags, str):
|
||||||
tags = [tags]
|
tags = [tags]
|
||||||
|
xmp = xmpdata
|
||||||
|
except TypeError:
|
||||||
|
...
|
||||||
if None in tags:
|
if None in tags:
|
||||||
tags.remove(None)
|
tags.remove(None)
|
||||||
return tags
|
return tags
|
||||||
|
|||||||
Reference in New Issue
Block a user