diff --git a/osxphotos/__init__.py b/osxphotos/__init__.py
index 7a999cee..9a6f21e4 100644
--- a/osxphotos/__init__.py
+++ b/osxphotos/__init__.py
@@ -162,7 +162,6 @@ class PhotosDB:
logging.debug(f"library = {library_path}, masters = {masters_path}")
-
if int(self._db_version) < int(_PHOTOS_5_VERSION):
self._process_database4()
else:
@@ -487,7 +486,7 @@ class PhotosDB:
+ "RKVersion.lastmodifieddate, RKVersion.imageDate, RKVersion.mainRating, "
+ "RKVersion.hasAdjustments, RKVersion.hasKeywords, RKVersion.imageTimeZoneOffsetSeconds, "
+ "RKMaster.volumeId, RKMaster.imagePath, RKVersion.extendedDescription, RKVersion.name, "
- + "RKMaster.isMissing, RKMaster.originalFileName "
+ + "RKMaster.isMissing, RKMaster.originalFileName, RKVersion.isFavorite, RKVersion.isHidden "
+ "from RKVersion, RKMaster where RKVersion.isInTrash = 0 and RKVersion.type = 2 and "
+ "RKVersion.masterUuid = RKMaster.uuid and RKVersion.filename not like '%.pdf'"
)
@@ -523,6 +522,8 @@ class PhotosDB:
self._dbphotos[uuid]["name"] = row[13]
self._dbphotos[uuid]["isMissing"] = row[14]
self._dbphotos[uuid]["originalFilename"] = row[15]
+ self._dbphotos[uuid]["favorite"] = row[16]
+ self._dbphotos[uuid]["hidden"] = row[17]
conn.close()
@@ -580,7 +581,6 @@ class PhotosDB:
logging.debug("Photos:")
logging.debug(pformat(self._dbphotos))
-
def _process_database5(self):
""" process the Photos database to extract info """
""" works on Photos version >= 5.0 """
@@ -639,7 +639,6 @@ class PhotosDB:
logging.debug(pformat(self._dbfaces_person))
logging.debug(self._dbfaces_uuid)
-
i = 0
c.execute(
"SELECT COUNT(*)"
@@ -904,15 +903,13 @@ class PhotosDB:
logging.debug("Photos:")
logging.debug(pformat(self._dbphotos))
-
- """
- Return a list of PhotoInfo objects
- If called with no args, returns the entire database of photos
- If called with args, returns photos matching the args (e.g. keywords, persons, etc.)
- If more than one arg, returns photos matching all the criteria (e.g. keywords AND persons)
- """
-
def photos(self, keywords=[], uuid=[], persons=[], albums=[]):
+ """
+ Return a list of PhotoInfo objects
+ If called with no args, returns the entire database of photos
+ If called with args, returns photos matching the args (e.g. keywords, persons, etc.)
+ If more than one arg, returns photos matching all the criteria (e.g. keywords AND persons)
+ """
photos_sets = [] # list of photo sets to perform intersection of
if not keywords and not uuid and not persons and not albums:
# return all the photos
@@ -964,6 +961,7 @@ class PhotoInfo:
Info about a specific photo, contains all the details about the photo
including keywords, persons, albums, uuid, path, etc.
"""
+
def __init__(self, db=None, uuid=None, info=None):
self.__uuid = uuid
self.__info = info
@@ -1072,6 +1070,14 @@ class PhotoInfo:
""" TODO: not accurate for Photos version >= 5 """
return True if self.__info["hasAdjustments"] == 1 else False
+ def favorite(self):
+ """ True if picture is marked as favorite """
+ return True if self.__info["favorite"] == 1 else False
+
+ def hidden(self):
+ """ True if picture is hidden """
+ return True if self.__info["hidden"] == 1 else False
+
def __repr__(self):
return f"osxphotos.PhotoInfo(db={self.__db}, uuid='{self.__uuid}', info={self.__info})"
diff --git a/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite b/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite
index 8f1e7690..1b4f53ff 100644
Binary files a/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite and b/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite differ
diff --git a/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite-shm b/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite-shm
index 284f2dae..42a0273e 100644
Binary files a/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite-shm and b/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite-shm differ
diff --git a/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite-wal b/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite-wal
index f1744bd7..f1260fa0 100644
Binary files a/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite-wal and b/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite-wal differ
diff --git a/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite.lock b/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite.lock
index 55e14341..52c35c51 100644
--- a/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite.lock
+++ b/tests/Test-10.15.1.photoslibrary/database/Photos.sqlite.lock
@@ -7,7 +7,7 @@
hostuuid
9575E48B-8D5F-5654-ABAC-4431B1167324
pid
- 3490
+ 1368
processname
photolibraryd
uid
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db b/tests/Test-10.15.1.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db
index ed183abf..3508c5d8 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db and b/tests/Test-10.15.1.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db-shm b/tests/Test-10.15.1.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db-shm
index ef740820..c4b01dbf 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db-shm and b/tests/Test-10.15.1.photoslibrary/private/com.apple.mediaanalysisd/MediaAnalysis/mediaanalysis.db-shm differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.AOI.sqlite-shm b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.AOI.sqlite-shm
index c1fbd76f..408e7171 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.AOI.sqlite-shm and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.AOI.sqlite-shm differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.AOI.sqlite-wal b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.AOI.sqlite-wal
index 8eb5b8a9..952b0d6c 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.AOI.sqlite-wal and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.AOI.sqlite-wal differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.Nature.sqlite-shm b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.Nature.sqlite-shm
index 463e95f5..174d7b47 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.Nature.sqlite-shm and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.Nature.sqlite-shm differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.Nature.sqlite-wal b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.Nature.sqlite-wal
index 92ebc027..1c6e47e8 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.Nature.sqlite-wal and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.Nature.sqlite-wal differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm
index 86da471c..b7eee96b 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal
index 766fb07d..54516d7a 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.ROI.sqlite-shm b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.ROI.sqlite-shm
index f6099ab0..bd30baab 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.ROI.sqlite-shm and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.ROI.sqlite-shm differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.ROI.sqlite-wal b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.ROI.sqlite-wal
index e722ceff..e5db69fc 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.ROI.sqlite-wal and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.ROI.sqlite-wal differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSPublicEventCache.sqlite-shm b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSPublicEventCache.sqlite-shm
index de51fe63..ea472c6b 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSPublicEventCache.sqlite-shm and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSPublicEventCache.sqlite-shm differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSPublicEventCache.sqlite-wal b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSPublicEventCache.sqlite-wal
index 0328e4cb..7f60bb40 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSPublicEventCache.sqlite-wal and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSPublicEventCache.sqlite-wal differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/PGCurationCache.sqlite.sqlite-shm b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/PGCurationCache.sqlite.sqlite-shm
index 4e63aaa0..1c0ba8fa 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/PGCurationCache.sqlite.sqlite-shm and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/PGCurationCache.sqlite.sqlite-shm differ
diff --git a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist
index 6831ef4d..986763a8 100644
Binary files a/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist and b/tests/Test-10.15.1.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist differ
diff --git a/tests/Test-10.15.1.photoslibrary/resources/journals/Asset-change.plj b/tests/Test-10.15.1.photoslibrary/resources/journals/Asset-change.plj
index 4d69103f..af24ba23 100644
Binary files a/tests/Test-10.15.1.photoslibrary/resources/journals/Asset-change.plj and b/tests/Test-10.15.1.photoslibrary/resources/journals/Asset-change.plj differ
diff --git a/tests/Test-10.15.1.photoslibrary/resources/journals/HistoryToken.plist b/tests/Test-10.15.1.photoslibrary/resources/journals/HistoryToken.plist
index 19ee58cd..7b5e2e60 100644
Binary files a/tests/Test-10.15.1.photoslibrary/resources/journals/HistoryToken.plist and b/tests/Test-10.15.1.photoslibrary/resources/journals/HistoryToken.plist differ
diff --git a/tests/test_catalina_10_15_1.py b/tests/test_catalina_10_15_1.py
index e7190415..d8ef2115 100644
--- a/tests/test_catalina_10_15_1.py
+++ b/tests/test_catalina_10_15_1.py
@@ -142,6 +142,26 @@ def test_missing():
assert p.ismissing() == True
+def test_favorite():
+ import osxphotos
+
+ photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
+ photos = photosdb.photos(uuid=["E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51"])
+ assert len(photos) == 1
+ p = photos[0]
+ assert p.favorite() == True
+
+
+def test_hidden():
+ import osxphotos
+
+ photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
+ photos = photosdb.photos(uuid=["A1DD1F98-2ECD-431F-9AC9-5AFEFE2D3A5C"])
+ assert len(photos) == 1
+ p = photos[0]
+ assert p.hidden() == True
+
+
def test_count():
import osxphotos