Initial shared photos code for Photos 5
This commit is contained in:
@@ -21,3 +21,6 @@ _TESTED_OS_VERSIONS = ["12", "13", "14", "15"]
|
|||||||
_UNKNOWN_PERSON = "_UNKNOWN_"
|
_UNKNOWN_PERSON = "_UNKNOWN_"
|
||||||
|
|
||||||
_EXIF_TOOL_URL = "https://exiftool.org/"
|
_EXIF_TOOL_URL = "https://exiftool.org/"
|
||||||
|
|
||||||
|
# Where are shared iCloud photos located?
|
||||||
|
_PHOTOS_5_SHARED_PHOTO_PATH = "resources/cloudsharing/data"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from pprint import pformat
|
|||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from ._constants import _PHOTOS_5_VERSION
|
from ._constants import _PHOTOS_5_VERSION, _PHOTOS_5_SHARED_PHOTO_PATH
|
||||||
from .utils import _get_resource_loc, dd_to_dms_str
|
from .utils import _get_resource_loc, dd_to_dms_str
|
||||||
|
|
||||||
# TODO: check pylint output
|
# TODO: check pylint output
|
||||||
@@ -62,7 +62,10 @@ class PhotoInfo:
|
|||||||
@property
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
""" absolute path on disk of the original picture """
|
""" absolute path on disk of the original picture """
|
||||||
photopath = ""
|
|
||||||
|
photopath = None
|
||||||
|
if self._info["isMissing"] == 1:
|
||||||
|
return photopath # path would be meaningless until downloaded
|
||||||
|
|
||||||
if self._db._db_version < _PHOTOS_5_VERSION:
|
if self._db._db_version < _PHOTOS_5_VERSION:
|
||||||
vol = self._info["volume"]
|
vol = self._info["volume"]
|
||||||
@@ -72,33 +75,38 @@ class PhotoInfo:
|
|||||||
photopath = os.path.join(
|
photopath = os.path.join(
|
||||||
self._db._masters_path, self._info["imagePath"]
|
self._db._masters_path, self._info["imagePath"]
|
||||||
)
|
)
|
||||||
|
return photopath
|
||||||
|
# TODO: Is there a way to use applescript or PhotoKit to force the download in this
|
||||||
|
|
||||||
if self._info["isMissing"] == 1:
|
if self._info["masterFingerprint"]:
|
||||||
photopath = None # path would be meaningless until downloaded
|
# if masterFingerprint is not null, path appears to be valid
|
||||||
# TODO: Is there a way to use applescript or PhotoKit to force the download in this
|
if self._info["directory"].startswith("/"):
|
||||||
else:
|
photopath = os.path.join(
|
||||||
if self._info["masterFingerprint"]:
|
self._info["directory"], self._info["filename"]
|
||||||
# if masterFingerprint is not null, path appears to be valid
|
)
|
||||||
if self._info["directory"].startswith("/"):
|
|
||||||
photopath = os.path.join(
|
|
||||||
self._info["directory"], self._info["filename"]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
photopath = os.path.join(
|
|
||||||
self._db._masters_path,
|
|
||||||
self._info["directory"],
|
|
||||||
self._info["filename"],
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
photopath = None
|
photopath = os.path.join(
|
||||||
logging.debug(f"WARNING: masterFingerprint null {pformat(self._info)}")
|
self._db._masters_path,
|
||||||
|
self._info["directory"],
|
||||||
|
self._info["filename"],
|
||||||
|
)
|
||||||
|
return photopath
|
||||||
|
|
||||||
# TODO: fix the logic for isMissing
|
if self._info["shared"]:
|
||||||
if self._info["isMissing"] == 1:
|
# shared photo
|
||||||
photopath = None # path would be meaningless until downloaded
|
photopath = os.path.join(
|
||||||
|
self._db._library_path,
|
||||||
logging.debug(photopath)
|
_PHOTOS_5_SHARED_PHOTO_PATH,
|
||||||
|
self._info["directory"],
|
||||||
|
self._info["filename"],
|
||||||
|
)
|
||||||
|
return photopath
|
||||||
|
|
||||||
|
# if all else fails, photopath = None
|
||||||
|
photopath = None
|
||||||
|
logging.debug(
|
||||||
|
f"WARNING: photopath None, masterFingerprint null, not shared {pformat(self._info)}"
|
||||||
|
)
|
||||||
return photopath
|
return photopath
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -250,6 +258,15 @@ class PhotoInfo:
|
|||||||
""" returns (latitude, longitude) as float in degrees or None """
|
""" returns (latitude, longitude) as float in degrees or None """
|
||||||
return (self._latitude, self._longitude)
|
return (self._latitude, self._longitude)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def shared(self):
|
||||||
|
""" returns True if photos is in a shared iCloud album otherwise false
|
||||||
|
Only valid on Photos 5; returns None on older versions """
|
||||||
|
if self._db._db_version >= _PHOTOS_5_VERSION:
|
||||||
|
return self._info["shared"]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def export(
|
def export(
|
||||||
self,
|
self,
|
||||||
dest,
|
dest,
|
||||||
|
|||||||
@@ -900,7 +900,9 @@ class PhotosDB:
|
|||||||
self._dbphotos[uuid]["longitude"] = row[14]
|
self._dbphotos[uuid]["longitude"] = row[14]
|
||||||
|
|
||||||
self._dbphotos[uuid]["hasAdjustments"] = row[15]
|
self._dbphotos[uuid]["hasAdjustments"] = row[15]
|
||||||
|
|
||||||
self._dbphotos[uuid]["cloudOwnerHashedPersonID"] = row[16]
|
self._dbphotos[uuid]["cloudOwnerHashedPersonID"] = row[16]
|
||||||
|
self._dbphotos[uuid]["shared"] = True if row[16] is not None else False
|
||||||
|
|
||||||
# these will get filled in later
|
# these will get filled in later
|
||||||
# init to avoid key errors
|
# init to avoid key errors
|
||||||
|
|||||||
Reference in New Issue
Block a user