Handle blank persons in Photos 5
This commit is contained in:
parent
591336673a
commit
da320e4f56
@ -12,10 +12,9 @@ from plistlib import load as plistload
|
||||
from pprint import pformat
|
||||
from shutil import copyfile
|
||||
|
||||
import yaml
|
||||
|
||||
import CoreFoundation
|
||||
import objc
|
||||
import yaml
|
||||
from Foundation import *
|
||||
|
||||
# from . import _applescript
|
||||
@ -46,6 +45,9 @@ _PHOTOS_5_VERSION = "6000"
|
||||
# which major version operating systems have been tested
|
||||
_TESTED_OS_VERSIONS = ["12", "13", "14", "15"]
|
||||
|
||||
# Photos 5 has persons who are empty string if unidentified face
|
||||
_UNKNOWN_PERSON = "_UNKNOWN_"
|
||||
|
||||
# set _DEBUG = True to enable debug output
|
||||
_DEBUG = False
|
||||
|
||||
@ -776,14 +778,19 @@ class PhotosDB:
|
||||
"AND ZGENERICASSET.ZTRASHEDSTATE = 0 AND ZGENERICASSET.ZKIND = 0 "
|
||||
)
|
||||
for person in c:
|
||||
person_name = None
|
||||
if person[0] is None:
|
||||
continue
|
||||
if person[0] == "":
|
||||
person_name = _UNKNOWN_PERSON
|
||||
else:
|
||||
person_name = person[0]
|
||||
if not person[1] in self._dbfaces_uuid:
|
||||
self._dbfaces_uuid[person[1]] = []
|
||||
if not person[0] in self._dbfaces_person:
|
||||
self._dbfaces_person[person[0]] = []
|
||||
self._dbfaces_uuid[person[1]].append(person[0])
|
||||
self._dbfaces_person[person[0]].append(person[1])
|
||||
if not person_name in self._dbfaces_person:
|
||||
self._dbfaces_person[person_name] = []
|
||||
self._dbfaces_uuid[person[1]].append(person_name)
|
||||
self._dbfaces_person[person_name].append(person[1])
|
||||
i = i + 1
|
||||
logging.debug(f"Finished walking through persons")
|
||||
logging.debug(pformat(self._dbfaces_person))
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
""" version info """
|
||||
|
||||
__version__ = "0.14.17"
|
||||
__version__ = "0.14.18"
|
||||
|
||||
|
||||
@ -102,14 +102,16 @@ def info(cli_obj):
|
||||
info["albums"] = albums
|
||||
|
||||
persons = pdb.persons_as_dict()
|
||||
|
||||
# handle empty person names (added by Photos 5.0+ when face detected but not identified)
|
||||
noperson = "UNKNOWN"
|
||||
if "" in persons:
|
||||
if noperson in persons:
|
||||
persons[noperson].append(persons[""])
|
||||
else:
|
||||
persons[noperson] = persons[""]
|
||||
persons.pop("", None)
|
||||
# TODO: remove this
|
||||
# noperson = "UNKNOWN"
|
||||
# if "" in persons:
|
||||
# if noperson in persons:
|
||||
# persons[noperson].append(persons[""])
|
||||
# else:
|
||||
# persons[noperson] = persons[""]
|
||||
# persons.pop("", None)
|
||||
|
||||
info["persons_count"] = len(persons)
|
||||
info["persons"] = persons
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user